Convex hull intersection test in broadphase

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Convex hull intersection test in broadphase

Postby Bird » Mon Aug 12, 2013 12:24 pm

In my project I'm trying to detect collisions while the user is dragging a body around the world *before* the engine is running. I'm successfully using NewtonWorldForEachBodyInAABBDo to have Newton tell me which other bodies are inside the dragged body's AABB. Now I'd like to go a step further and find out if the dragged body's convex hull is intersecting the convex hull is of any of the bodies within it's AABB.

Is there a way to do that in Newton? I tried using NewtonCollisionIntersectionTest to refine my collision test but I guess that won't work unless the engine is running.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Convex hull intersection test in broadphase

Postby Julio Jerez » Mon Aug 12, 2013 1:31 pm

yes, there is a while familty of those functions, in fact thsoe are teh exact same funtion the engine uses internally for collision

int NewtonCollisionPointDistance (const NewtonWorld* const newtonWorld, const dFloat* const point,
const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const contact, dFloat* const normal, int threadIndex);

int NewtonCollisionClosestPoint (const NewtonWorld* const newtonWorld,
const NewtonCollision* const collisionA, const dFloat* const matrixA,
const NewtonCollision* const collisionB, const dFloat* const matrixB,
dFloat* const contactA, dFloat* const contactB, dFloat* const normalAB, int threadIndex);

int NewtonCollisionCollide (const NewtonWorld* const newtonWorld, int maxSize,
const NewtonCollision* const collisionA, const dFloat* const matrixA,
const NewtonCollision* const collisionB, const dFloat* const matrixB,
dFloat* const contacts, dFloat* const normals, dFloat* const penetration,
dLong* const attributeA, dLong* const attributeB, int threadIndex);

int NewtonCollisionCollideContinue (const NewtonWorld* const newtonWorld, int maxSize, dFloat timestep,
const NewtonCollision* const collisionA, const dFloat* const matrixA, const dFloat* const velocA, const dFloat* omegaA,
const NewtonCollision* const collisionB, const dFloat* const matrixB, const dFloat* const velocB, const dFloat* const omegaB,
dFloat* const timeOfImpact, dFloat* const contacts, dFloat* const normals, dFloat* const penetration,
dLong* const attributeA, dLong* const attributeB, int threadIndex);

void NewtonCollisionSupportVertex (const NewtonCollision* const collision, const dFloat* const dir, dFloat* const vertex);
dFloat NewtonCollisionRayCast (const NewtonCollision* const collision, const dFloat* const p0, const dFloat* const p1, dFloat* const normal, dLong* const attribute);
NEWTON_API void NewtonCollisionCalculateAABB (const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const p0, dFloat* const p1);
NEWTON_API void NewtonCollisionForEachPolygonDo (const NewtonCollision* const collision, const dFloat* const matrix, NewtonCollisionIterator callback, void* const userData);

...
...

one function that is very handy, and perhap better fo wha to want supportVertex and closet distance.
there are some more new in newton list collisiontest, thsi oen I added fo rth ep[layer colntroller

you do not have to run the engine update to use any of them. they can be called from any where, and from any thread even in parallel.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Convex hull intersection test in broadphase

Postby Bird » Mon Aug 12, 2013 4:37 pm

Wow, that's excellent!!! I had a stupid bug in my code so NewtonCollisionIntersectionTest() wasn't working and I assumed all those functions required a physics update. But I have them working now.

Thanks for the help!

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron