Gandi Posted November 16, 2012 Share Posted November 16, 2012 Hi, I need to get all Entities which are inside, or partially inside a bounding box. Is there a fast way of archieving this (also entities without any collission or bodies would be great). Quote Link to comment Share on other sites More sharing options...
Rick Posted November 16, 2012 Share Posted November 16, 2012 I use http://www.leadwerks...tyinaabbdo-r164 If doing this from C++ I pass in a pointer to the class that calls this function to the extra parameter. Then inside the C function, that you have to specify as the callback, I cast back the extra pointer to the class and expose a public method that adds an entity to a list inside that class. Then after this function is finished being called my list is populated and I can use it. Something like below. It's from memory so I might have screwed something up but you get the idea. void _stdcall myfunc( TEntity entity, byte* extra) { MyClass* cls = (MyClass*)extra; cls->AddEntity(entity); } class MyClass { private: list<TEntity> _entities; public: void AddEntity(TEntity e) { _entities.push_back(e); } void Update() { _entities.clear(); ForEachEntityInAABBDo(aabb, myfunc, this, ENTITY_ALL) // now my _entities list is populated } }; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.