Problem with NewtonCollisionCollide

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Problem with NewtonCollisionCollide

Postby Sirithang » Mon Feb 15, 2010 1:33 pm

Hi!

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!
Sirithang
 
Posts: 2
Joined: Mon Feb 15, 2010 12:36 pm

Re: Problem with NewtonCollisionCollide

Postby JernejL » Mon Feb 15, 2010 2:22 pm

see: NewtonCollisionCollide
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Problem with NewtonCollisionCollide

Postby Sirithang » Mon Feb 15, 2010 4:01 pm

Well my bad honestly....it must be because of my poor undunstanding of english...

maxSize was for me the number of element you want to grab, but it was in fact the number of element in my scene...

Thanks for making me read again the wiki for the twentieth times, knowing that there is something to find make you find it ^^"....

Thanks again!

EDIT: Well....it doesn't seam to work very well...The bug occurs more rarely, but it still occurs without apparent reason (I know that there is one, i just cannot find it ^^")

Can someone please tell me exactly what i'm doing wrong? The code above is a test one, that's why my vector don't have the exact length, because i'd try to extend them to avoid access violation.... But in fact i'm made my vector as 3*maxSize, with a new, and delete them after the call to NewtonCollisionCollide...
Sirithang
 
Posts: 2
Joined: Mon Feb 15, 2010 12:36 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 396 guests

cron