NewtonBodyGetAABB

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

NewtonBodyGetAABB

Postby dehseth » Fri Dec 25, 2009 9:02 am

Can anybody explain NewtonBodyGetAABB function? I am confused with second and third paramerters.

Definition says:
# dFloat *p0 - pointer to an array of at least three floats to hold minimum value for the AABB.
# dFloat *p1 - pointer to an array of at least three floats to hold maximum value for the AABB.

At least :?: And I tried in code it returns 6 floats for each parameter? Well I expect 3 floats (x,y,z), a min point and a max point of box.

How can I define a box using 6 parameters, and is tehere any chance in a different version can return 9 floats instead of 6 :roll:
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am

Re: NewtonBodyGetAABB

Postby JernejL » Fri Dec 25, 2009 11:09 am

Interesting, it is possible in theory that if overwrites 6 floats (24 bytes) instead of 3 (12 bytes) if the documentation is wrong (let's wait for Julio to respond).

But are you sure you use the correct build of newton? if you use the double precision build, it should write 24 bytes as doubles are 8 bytes long..
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: NewtonBodyGetAABB

Postby dehseth » Fri Dec 25, 2009 11:25 am

I did not build it. I am using current lib and dll in sdk. There's a dFloat type def which is float and 4 bytes-length. And as I see double prec. is commented out:

Code: Select all
//#define __USE_DOUBLE_PRECISION__
#ifdef __USE_DOUBLE_PRECISION__
   #define dFloat double
#else
   #define dFloat float
#endif
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am

Re: NewtonBodyGetAABB

Postby Julio Jerez » Fri Dec 25, 2009 11:27 am

the function copy the minimu into the three adjecent floats at poiter p0
and copy the thre float for thr max point of teh aabb into thr three adjecent float at p1
it does no override memory, beyond those limits.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonBodyGetAABB

Postby dehseth » Fri Dec 25, 2009 2:31 pm

but it does...

here's my code:

Code: Select all
float floorMin[6], floorMax[6];
   NewtonBodyGetAABB(bodyFloor, &floorMin[0], &floorMax[0]);


And here's how memory changed after I called function:

for floorMin: 2.0000000 -2.7519531 0.00000000 -1.5000000 0.00000000 -1.5000000
for flooarMax: 2.0000000 2.7519531 0.00000000 1.5000000 0.00000000 1.5000000

And if I change my arrays size to 3 and run them:

Code: Select all
float floorMin[3], floorMax[3];
   NewtonBodyGetAABB(bodyFloor, &floorMin[0], &floorMax[0]);


On exit I got this message:

Run-Time Check Failure #2 - Stack around the variable 'floorMax' was corrupted.

It is corrupted cause each writes 6 floats...
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am

Re: NewtonBodyGetAABB

Postby Julio Jerez » Fri Dec 25, 2009 3:30 pm

that is not possible, this is the function

Code: Select all
void NewtonBodyGetAABB(const NewtonBody* bodyPtr, dFloat* p0, dFloat* p1)   
{
   dgBody *body;

   dgVector vector0;
   dgVector vector1;

   TRACE_FUNTION(__FUNCTION__);
   body = (dgBody *)bodyPtr;
   body->GetAABB (vector0, vector1);

   p0[0] = vector0.m_x;
   p0[1] = vector0.m_y;
   p0[2] = vector0.m_z;

   p1[0] = vector1.m_x;
   p1[1] = vector1.m_y;
   p1[2] = vector1.m_z;

}


the only way that can happens is if you are linking to the single presition library but you are using the double presition dll.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonBodyGetAABB

Postby dehseth » Fri Dec 25, 2009 4:30 pm

the only way that can happens is if you are linking to the single presition library but you are using the double presition dll.


yeah you are right, I was using this double dll presition :D

thank you :mrgreen:
Last edited by dehseth on Fri Dec 25, 2009 4:41 pm, edited 1 time in total.
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am

Re: NewtonBodyGetAABB

Postby Julio Jerez » Fri Dec 25, 2009 4:40 pm

double presition is for people how use very large worlds.
when using the exact solver the double presition is also more acurate, In the iterative mode it does not make difference at the solver level but the collision is much much better.

for you I believe you single presision is the right one.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonBodyGetAABB

Postby dehseth » Fri Dec 25, 2009 4:42 pm

I was just editing my text :) and I saw you replied

sorry it's kinda late in here and I didn't understand single means 4-byte float :)

thanks again...
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests