TriangleSelectors vs me.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

TriangleSelectors vs me.

Post by polylux »

Good evening everyone!

The following problem has been bothering me now for hours and I can't find out what the problem is.
The situation is: at startup I load an irr-scene putting all main objects into a meta triangle selector. Meta - so I can add and remove objects being subject to hit-testing.
As the very last scene node the terrain gets loaded from the irr scene for which a TerrainTriangleSelector is created (as in the tuts):

Code: Select all

case scene::ESNT_TERRAIN:
                tempSelector = sManager->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node);
                break;
The problem now is, when I want to add another triangle selector to the meta selector (at some later point), the new object is hit-tested correctly but the hit object returned is always the terrain scene node.
This is what's happening for new objects:

Code: Select all

g->selector = dev->getSceneManager()->createTriangleSelectorFromBoundingBox(g->model);
this->selector->addTriangleSelector(g->selector);
Note: "g" is my base object class, obviously storing pointers to an ISceneNode and TriangleSelector. The last LOC adds it to the meta selector.

Any hints greatly appreciated!

Cheers,
p.
beer->setMotivationCallback(this);
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

Apparently the problem seems to be related to this bug report (dated about a year back).

Edit:
I now found out that it has not to do with the proximity of the two objects (as supposed in the link above). I can also move the other obj about a hundred units away and still the terrain SN gets picket.
The code in charge of that:

Code: Select all

sManager->getSceneCollisionManager()->getCollisionPoint(hitTestLine, selector, collPoint, tri, hitObject)...
Where the out param hitObject constantly returns terrain instead of the correct object. Interestingly, objects added to the MetaTriangleSelector BEFORE the terrain are correctly picked.
beer->setMotivationCallback(this);
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

Ok, a possible workaround is the following:

1, store a pointer to the terrain's triangle selector
2, when a new object should be added, remove the terrain from the meta
3, create TS for the new object, add it to the meta
4, add the terrain's TS back again

Not the most beautiful solution but working and not too costly (just 2 array ops).
I am starting to think that this is probably not my fault but more a bug in the engine.
beer->setMotivationCallback(this);
Post Reply