Can we create a copy of the metaselector?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Can we create a copy of the metaselector?

Post by christianclavet »

Hi.
My objective with the copy of the metaselector:
I have a metaselector of the full scene (all the objects in my scene) and would like to work on a copy of it to remove triangle selectors and then apply the updated metaselector to the collision reponse animator.

Why:
I would like from the metaselector create a collision response animator for EACH NPC, but remove their own triangle selector so they won't collision with themselves.

Tries:
Try #1: I Tried to add back the removed triangles from the metaselector AFTER assigning it the current collision response animator, and the result seem that the collision is blocked (each objects seem to be stuck)

Try #2: From a search from google on duplicating an object I tried that:
IMetaTriangleSelector* meta is my current metaselector object: done this:

Code: Select all

IMetaTriangleSelector* meta2(meta);
From what I read, it should copy the object to "meta2", but it seem to reference it again, as each time I removed triangles from meta2, thoses triangles were also removed from meta.

My current solution: :?
Destroy and recreate the meta selector each time for each NPC. Creating the metaselector is pretty fast now, but this method is inneficient and could take more time with more NPCs or objects.

Question:
Could someone help me by showing me a way to copy the metaselector without having to rebuild it each time? I need to work from a copy and keep the "full scene" metaselector in memory.

Also: is there a way to update the meta selector on the collision response animator without destroying it and recreate it? Right now, I'm rebuilding everything (meta selector + collision response). When a NPC "dies", his collision triangles need to be removed from all the collision response animators from all NPC...
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

There is no way to copy the meta selector. Without modifying Irrlicht, the only solution is to create and populate all of the meta selectors individually.

Of course, the changes to Irrlicht wouldn't be that significant. You just need to add a clone() abstract method to the base class, and then implement that method in each of the base classes.

Travis
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Thanks Vitek. Then I'll keep it the way it is right now.

I'll put that on the wish list... :)
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

A more standard-conform alternative would be the implementation of a copy constructor to create a deep copy of the existing selector.
This could then be used in such a way:

Code: Select all

IMetaTriangleSelector* meta2 = new IMetaTriangleSelector(meta);
...which is - I guess - what you wanted to do in your first post, christianclavet.
The default copy constructor only creates "shallow copies", meaning just the pointers, not values themselves, are copied. That's why, changes in your "meta2" also affected "meta".
beer->setMotivationCallback(this);
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

polylux wrote:A more standard-conform alternative would be the implementation of a copy constructor to create a deep copy of the existing selector.
This could then be used in such a way:

Code: Select all

IMetaTriangleSelector* meta2 = new IMetaTriangleSelector(meta);
IMetaTriangleSelector is an abstract base class so you can't just add a copy constructor, the implementation is in CMetaTriangleSelector which isn't exposed to the user.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

lol, so true.
I should stop posting "smart" comments late at night after coming home from the bars... ;)
beer->setMotivationCallback(this);
Post Reply