Jump to content

get all entities in AABB


Gandi
 Share

Recommended Posts

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
}
};

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...