Jump to content

Iterator for entities


AggrorJorn
 Share

Recommended Posts

I am iterating through a list of LE3 Models. I had some trouble getting the position of every object during an iteration. I finnaly found something that works, but it looks really nasty. There must be a different way of accessing LE3 commands but I haven't found another way.

 

list<Model*>::iterator it;
for(it=roadBlocks.begin(); it != roadBlocks.end(); ++it)
{
 it._Ptr->_Myval->GetPosition()

 

Also when I debug, this is how it looks:

post-45-0-21499400-1364748096_thumb.jpg

Link to comment
Share on other sites

It's a pointer, so it's the same object. I usually do this:

list<Entity*>::iterator entity;        
for (entity = entities.begin(); entity != entities.end(); entity++)
{
   Vec3 position = (*entity)->GetPosition();
}

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

The problem is if you write " *it->MyMethod() " (example to show the problem) then c++ will try to use " * " (asterisk) on MyMethod but you want it on " it ", so you have to write (*it) to deferencing the iterator.

 

 

// Edit: to clarify

 

you could write something like this

 

Mycallback = &(*it)->GetMethodToCallBack();

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...