I try to use Newton only as a collision detector between two shapes. I don't use forces and other, i just do this:
- Code: Select all
GLfloat matrixA[4][4] = {{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{t->get_position().x(), t->get_position().y(), t->get_position().z(), 1}};
GLfloat matrixB[4][4]= {{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{s->get_position().x(), s->get_position().y(), s->get_position().z(), 1}};
//! Creation des colision Newton
Point3D* p;
p = t->getBB();
NewtonCollision* CollisionA = NewtonCreateSphere(m_world,
abs(p[1].x() - p[0].x())/2,
abs(p[1].y() - p[0].y())/2,
abs(p[1].z() - p[0].z())/2,
0,
NULL);
p = s->getBB();
NewtonCollision* CollisionB = NewtonCreateSphere(m_world,
abs(p[1].x() - p[0].x())/2,
abs(p[1].y() - p[0].y())/2,
abs(p[1].z() - p[0].z())/2,
0,
NULL);
int nbC = NewtonCollisionCollide(m_world, 1, CollisionA, &matrixA[0][0], CollisionB, &matrixB[0][0], &pCol[0], &pColNormal[0], &pts[0], 0);
NewtonReleaseCollision(m_world, CollisionA);
NewtonReleaseCollision(m_world, CollisionB);
getBB return the two extrem point of my shape, t and s are my two shape.
This is inside a loop who pass all mobiles of my scene (t), and inside it another loop who inventory all my object (s).
I create my collision shape for my two object, and check for a collision.
If i only have two object in my scene, no problem, the collision is well detected, nbC take the value one.
If i have more than two object, the game launch, but immediatly, it trigger an unhandled exception, access violation....I cannot see why, and it's NewtonCollisionCollide which trigger it...My call stack only have newton.dll, so it's impossible to see where the bug occurs...
I use the Windows SDK 2.16.
Thanks for the help!
