Collisions between kinematic and dynamic objects

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Collisions between kinematic and dynamic objects

Postby Pierre » Sun Jun 21, 2015 5:13 pm

Hi,

I have a problem with dynamic objects that should collide with kinematic objects (think kinematic platforms), but they don't. The dynamic objects go right through the kinematics.

Any idea what I'm doing wrong?

The setup for the objects is the same as in PEEL's Newton3.13 plugin.

Thanks.
Pierre
 
Posts: 21
Joined: Tue Jun 16, 2015 4:40 am

Re: Collisions between kinematic and dynamic objects

Postby JoeJ » Sun Jun 21, 2015 5:51 pm

Code: Select all
body = NewtonCreateKinematicBody (this->world, shape, &trans[0][0]);
NewtonBodySetMassProperties (body, mass, shape); //some mass recommended to avoid infinite collision forces
NewtonBodySetCollidable (body, true); // <-


Note that if you animate them, you also need to set their velocity yourself.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Collisions between kinematic and dynamic objects

Postby Pierre » Mon Jun 22, 2015 5:43 am

Thanks, I will try your suggestion ASAP.

Note that if you animate them, you also need to set their velocity yourself.

This is more surprising, I would have expected the engine to take care of that automatically (as in Havok, etc).

Is there a helper function that I can use to derive the velocities from a source & destination matrices? (I need both linear & angular velocities).
Pierre
 
Posts: 21
Joined: Tue Jun 16, 2015 4:40 am

Re: Collisions between kinematic and dynamic objects

Postby JoeJ » Mon Jun 22, 2015 7:47 am

I found that surprising too, but by setting velocity and not changing position, it's very easy to create a conveyor belt for example.
So it's more a cool than a missing feature :)

JoeJ wrote:Is there a helper function that I can use to derive the velocities from a source & destination matrices? (I need both linear & angular velocities).


Three is at least a utility to do it the other way:
void NewtonBodyIntegrateVelocity (const NewtonBody* const bodyPtr, dFloat timestep)
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Collisions between kinematic and dynamic objects

Postby Julio Jerez » Mon Jun 22, 2015 8:02 am

the reasoning is the by not having them animated automatically the app gets best of both.
the application can always move the body in various ways:
1-It can place then on its own app container and loop over the bodies an update the before the newton update
2-it can moves then in a dedicate transform call back.
3-It can make a engine listener to group then to collect and update them in the listener call back

to animate the body you call the procedure stated by Joe, but you need to calculate velocity and omega from the delta position and delta orientation, this is very simple.

for the position:
Code: Select all
let dt be the time step
Let p1 be the target position;
let  p0 b the current position
veloc = (p1 - p0) / dt


for the angular velocity is more complex but there is function in the math library for assistance.
Code: Select all
dQuaterion::CalcAverageOmega


Code: Select all
let q0 be the current orination
let q1 be the target orientation
then
omega = q0.CalcAverageOmega (q1, dt);


with veloc and omega you set those in the body, (any body with no zero mass)
and you can call
Code: Select all
NewtonBodySetVelocity(body, &velocity[0]);
NewtonBodySetOmega(body, &omega[0]);
NewtonBodyIntegrateVelocity (body, dt);

if the body was kinematic will only move when you call the function.
if the body is dynamics it moves and continue moving by its inertia as long as the velocity is not changed again.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Collisions between kinematic and dynamic objects

Postby Pierre » Mon Jun 22, 2015 8:33 am

Thanks, I will give it a try this evening :)
Pierre
 
Posts: 21
Joined: Tue Jun 16, 2015 4:40 am

Re: Collisions between kinematic and dynamic objects

Postby Pierre » Mon Jun 22, 2015 6:09 pm

I think I have a first version kind of working (only linear velocity for now). I had a lot of performance issues for a while but it all went away when I figured I had to update the "OnAABBOverlap" function (in PEEL's Newton plugin) to ignore kinematic pairs myself. There's still a one frame delay somewhere but I can work it out tomorrow or another day.
Pierre
 
Posts: 21
Joined: Tue Jun 16, 2015 4:40 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest