Hi,
I have some problem with ISceneCollisionManager::getCollisionResultPosition.
I use a meta triangle selector for the collision
In the function, there is some parameter outNode, which should give you the colliding node.
The collision works so far, but outNode gives me the first node, I added to the meta triangle selector, every time.
Is this a bug? Can anyone help me please?
Kind regards,
Squarefox
Problem with getCollisionResultPosition
-
- Competition winner
- Posts: 117
- Joined: Tue Aug 19, 2008 6:46 pm
- Location: Delta quadrant, Borg nexus 0001
- Contact:
Re: Problem with getCollisionResultPosition
HI,
I just found the error. The implementation is borked.
CCollisionManager::collideWithWorld:
CCollisionManager::collideEllipsoidWithWorld
The error is that the colData.triangleIndex is used for retrieving the colliding node,
but it's only a temporary counter that comes from colData.selector->getTriangles
and has nothing to do with the index in the MetaTriangleSelector.
Kind regards,
Squarefox
I just found the error. The implementation is borked.
CCollisionManager::collideWithWorld:
Code: Select all
colData.selector->getTriangles(Triangles.pointer(), totalTriangleCnt, triangleCnt, box, &scaleMatrix);
for (irr::s32 i=0; i<triangleCnt; ++i)
if(testTriangleIntersection(&colData, Triangles[i]))
colData.triangleIndex = i;
Code: Select all
if (colData.triangleHits)
{
triout = colData.intersectionTriangle;
triout.pointA *= colData.eRadius;
triout.pointB *= colData.eRadius;
triout.pointC *= colData.eRadius;
outNode = selector->getSceneNodeForTriangle(colData.triangleIndex);
int a = 5;
}
Code: Select all
//! Return the scene node associated with a given triangle.
ISceneNode* CMetaTriangleSelector::getSceneNodeForTriangle(u32 triangleIndex) const
{
u32 totalTriangles = 0;
for (u32 i=0; i<TriangleSelectors.size(); ++i)
{
totalTriangles += TriangleSelectors[i]->getTriangleCount();
if(totalTriangles > triangleIndex)
return TriangleSelectors[i]->getSceneNodeForTriangle(0);
}
// For lack of anything more sensible, return the first selector.
return TriangleSelectors[0]->getSceneNodeForTriangle(0);
}
but it's only a temporary counter that comes from colData.selector->getTriangles
and has nothing to do with the index in the MetaTriangleSelector.
Kind regards,
Squarefox
Re: Problem with getCollisionResultPosition
Sorry, not getting what's happening there so quickly. You could help if you could give me a complete examples which I can compile and use to reproduce the problem. I think CCollisionManager::collideWithWorld is not an Irrlicht function - so I know nothing about that and about which indices you are working with. Same with colData - it's not an Irrlicht structure and I know nothing about it or how you use it. testTriangleIntersection also doesn't look like an Irrlicht function. So the only thing I could go on was CMetaTriangleSelector::getSceneNodeForTriangle which on a quick look seemed correct to me - but maybe I would get the problem if I had an example which I could read.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm