Some troubles with sleeping and size of collision primitives

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Some troubles with sleeping and size of collision primitives

Postby FadeToBlack » Thu Sep 09, 2010 7:20 pm

Hi.
When i tried to migrate from newton version 1.xx to version 2.24, i get some problems.

1. there is problem with new sleeping functions.
Older version has function to unfreeze bodies, but new version have not this.
problem is appeared when i use NewtonBodySetMatrix. when i call it, it is don`t unfreeze bodies.
i need to set position of the body by call this function. in old version after call of NewtonBodySetMatrix function, i call NewtonWorldUnfreezeBody and it works fine. How can i awake a body after call of NewtonBodySetMatrix function?

2. when i use funcion like NewtonCreateBox with the size of primitive not equal to (1, 1, 1) and create body from it, or set it to body by calling NewtonBodySetCollision, i have some troubles. real body size it seems not the same as i want, and sometimes, body do some amazing tricks... like penetration in other bodies, or rotating too fast, when i set it position.
in older version it works fine.
FadeToBlack
 
Posts: 17
Joined: Thu Sep 09, 2010 7:00 pm

Re: Some troubles with sleeping and size of collision primitives

Postby Julio Jerez » Thu Sep 09, 2010 7:51 pm

check out the wiki tutorials
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some troubles with sleeping and size of collision primitives

Postby FadeToBlack » Thu Sep 09, 2010 10:50 pm

here is video & wrapper sources, _old - is version 1.xx
http://disk.tom.ru/ymnwn8w/1/0ad9e/Newton.rar
FadeToBlack
 
Posts: 17
Joined: Thu Sep 09, 2010 7:00 pm

Re: Some troubles with sleeping and size of collision primitives

Postby FadeToBlack » Fri Sep 10, 2010 8:04 pm

i think the bug is here.
i use NewtonBodyGetAABB to draw bbox of each body.
in version 153 it works perfect. when i try to do it in 224, i have been surprized.
i think, the reason is in bbox margin, it does not work properly.
just look at video > http://disk.tom.ru/r4hdevj
FadeToBlack
 
Posts: 17
Joined: Thu Sep 09, 2010 7:00 pm

Re: Some troubles with sleeping and size of collision primitives

Postby Julio Jerez » Fri Sep 10, 2010 8:17 pm

you must have a different bug NewtonBodyGetAABB, has being working for a long time.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some troubles with sleeping and size of collision primitives

Postby FadeToBlack » Fri Sep 10, 2010 9:16 pm

i cant understand, where is bug in my code. i do all the things as i do in old version(153).
FadeToBlack
 
Posts: 17
Joined: Thu Sep 09, 2010 7:00 pm

Re: Some troubles with sleeping and size of collision primitives

Postby FadeToBlack » Fri Sep 10, 2010 9:45 pm

ok, f..g scale. it works. one more problem to fix.. with sleeping..
FadeToBlack
 
Posts: 17
Joined: Thu Sep 09, 2010 7:00 pm

Re: Some troubles with sleeping and size of collision primitives

Postby Julio Jerez » Sat Sep 11, 2010 11:02 am

what does f--g scale means?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some troubles with sleeping and size of collision primitives

Postby FadeToBlack » Sun Sep 12, 2010 1:12 pm

when i use version, 153 i pass scaled matrix in NewtonBodySetMatrix, and it work properly - scale does not affect to collision object of a body.
but in 224 it cause some bugs with collision objects & calculating AABB.
FadeToBlack
 
Posts: 17
Joined: Thu Sep 09, 2010 7:00 pm

Re: Some troubles with sleeping and size of collision primitives

Postby Julio Jerez » Sun Sep 12, 2010 2:21 pm

neither 1.53 or 2.xx support scale in the body matrix of colliiosn offsset.

what you did workd in 1.53 because 1.53 was normalizing teh matrix when you call ste matrix.
but that break determinism with using newton in network, so it had to be removed

you should no pass matrix with scales.

if you are using 2.xx you can use teh dMatrix class to remove teh scale form a matrix

Code: Select all
dMatrix matrixWithScale;
dMatrix transformMatrix;
dVector scale;
dMatrix stretchAxis;
matrixWithScale.PolarDecomposition (transformMatrix, scale, stretchAxis);

//then use transformMatrix to set the body matrix
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Some troubles with sleeping and size of collision primitives

Postby ledahut » Sun Sep 12, 2010 2:32 pm

About freeze.
In Newton2 use: NewtonBodySetFreezeState and NewtonBodyGetFreezeState
The wiki is not up to date about freeze functions.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Some troubles with sleeping and size of collision primitives

Postby FadeToBlack » Sun Sep 12, 2010 4:19 pm

Julio Jerez wrote:you should no pass matrix with scales.

i do it my own way - i have function to normalize matrices:
Code: Select all
void Matrix::normalize() {
   Vector x(data[0][0],data[0][1],data[0][2]);
   Vector y(data[1][0],data[1][1],data[1][2]);
   Vector z;
   x.normalize();
   z = cross(x,y);
   z.normalize();
   y = cross(z,x);
   y.normalize();
   data[0][0] = x.x; data[1][0] = y.x; data[2][0] = z.x;
   data[0][1] = x.y; data[1][1] = y.y; data[2][1] = z.y;
   data[0][2] = x.z; data[1][2] = y.z; data[2][2] = z.z;
}


ledahut wrote:About freeze.In Newton2 use: NewtonBodySetFreezeState and NewtonBodyGetFreezeStateThe wiki is not up to date about freeze functions.

i attempt to try this functions, but it is not to awake frozen bodies.
i need function like NewtonWorldUnfreezeBody, wich is in version153.
FadeToBlack
 
Posts: 17
Joined: Thu Sep 09, 2010 7:00 pm

Re: Some troubles with sleeping and size of collision primitives

Postby ledahut » Sun Sep 12, 2010 5:01 pm

How you body become frozen? You call a function? When you create them? Or when they reach equilibrium [body is sleeping] ?
Be careful freeze and sleep is not the same thing. See NewtonBodySetAutoSleep.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Some troubles with sleeping and size of collision primitives

Postby FadeToBlack » Sun Sep 12, 2010 9:49 pm

ledahut wrote:How you body become frozen? You call a function? When you create them? Or when they reach equilibrium [body is sleeping] ?
Be careful freeze and sleep is not the same thing. See NewtonBodySetAutoSleep.

when i create body, i set NewtonBodySetAutoSleep to true and i use NewtonBodyGetSleepState to determine sleeping state. when body is go to sleep when equilibrium becomes reaced, i cannot to awake body by setting its matrix. when i call other functions, like NewtonBodySetVelocity, body becomes awaken.
it seems, body do not call private function like NewtonWorldUnfreezeBody when sleeping state is reaced.
FadeToBlack
 
Posts: 17
Joined: Thu Sep 09, 2010 7:00 pm

Re: Some troubles with sleeping and size of collision primitives

Postby Stucuk » Mon Sep 13, 2010 2:55 am

If your not going to give it any force/velocity then whats the point of waking it up? The point of sleep is so that objects that arn't moving enough won't have calculations done on them. Setting the matrix doesn't give the body any force/velocity so its not going to be moving.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 5 guests