Scaling A Compound Collision Body

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Scaling A Compound Collision Body

Postby Bird » Thu Jul 25, 2013 2:30 pm

Sync to SNV and build in debug mode let us see if the expection happen. when the number goes bad.


I've re-synced and tried again in debug mode but did not notice any difference. When scaling up Newton eventually hits the debug assert in dgVec.h at line 813. When scaling down Newton eventually crashes at dgCollisionInstance::GetChildShape()

This is just scaling of CompoundCollision shapes. All other collision types scale up and down interactively without any problem.

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

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Thu Jul 25, 2013 3:57 pm

can you export the file that produced the bug using the Mesh serilized so the I can load teh same exact file, and send it to me?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Thu Jul 25, 2013 4:21 pm

Julio Jerez wrote:can you export the file that produced the bug using the Mesh serilized so the I can load teh same exact file, and send it to me?


Here's a download link. http://hurleyworks.com/downloads/CompoundScale.zip

The serialized mesh is called "compoundMeshSerialized.bin"
And I exported the scene too "CompoundScaleScene.bin"

The scene loads and runs fine in DemoSandbox.exe. But DemoSandbox hangs here when trying to load the serialized mesh.

The mesh itself is just a simple open box like you use in the Simple Convex Decomposition demo

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

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Thu Jul 25, 2013 4:43 pm

Ok I loaded CompoundScaleScene.bin and tha seem to work fine.

on this
Bird wrote:
Julio Jerez wrote:And I exported the scene too "CompoundScaleScene.bin"
The scene loads and runs fine in DemoSandbox.exe. But DemoSandbox hangs here when trying to load the serialized mesh.
The mesh itself is just a simple open box like you use in the Simple Convex Decomposition demo


did you just try to load it by from the menu? if you did that, I do no know what teh resul woul be, because NewtonMesh Serialize does no save a scene.
The Newton Serailizaion routioen are no file format, they are for peopel to embeded sata in therie owne formats.

Tonog I will try to modifi a demo a load that Mesh, and try to do exactly what you are doing to it.

can you post here what operation are you doing on that hollow box that make the bug happens, so that I can do the same a see what is wrong?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Thu Jul 25, 2013 5:22 pm

did you just try to load it by from the menu?

Oops. Yes that's what I was trying to do. Would be a nice feature though. :)

can you post here what operation are you doing on that hollow box that make the bug happens, so that I can do the same a see what is wrong?

Here's what I'm doing.http://hurleyworks.com/media/flash/CompoundScaleCrash/CompoundScaleCrash.html
It seems odd that Newton crashes differently depending on whether I'm scaling up or down.

Here's the code that gets called while the user changes the Scale in LW's gui

-Bird

Code: Select all
bool NewtonScene::updateBodyProperties (const BodyID & bodyID)
{   TRACE("NewtonScene::updateBodyProperties")

   PhysicsBodies::iterator it = bodies_.find(bodyID);
   if ( it != bodies_.end() )
   {
      PhysicsBody::Ptr pBody = it->second;
      if( pBody && pBody->component )
      {
         const NewtonBody * const newtonBody = (NewtonBody*)pBody->component->userData;
         if( !newtonBody ) return false;

         NewtonCollision * const collision = NewtonBodyGetCollision(newtonBody);
         if( !collision ) return false;

         if( pBody->bodyDesc.bodyState & BodyState::ScaleChanged )
         {
            NewtonCollisionSetScale(collision, pBody->bodyDesc.scale[0], pBody->bodyDesc.scale[1], pBody->bodyDesc.scale[2] );
            pBody->bodyDesc.bodyState ^= BodyState::ScaleChanged;
         }

         dVector origin;
         dVector inertia;
         dFloat mass = pBody->bodyDesc.mass;
         NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);   
         dFloat Ixx = mass * inertia[0];
         dFloat Iyy = mass * inertia[1];
         dFloat Izz = mass * inertia[2];

         NewtonBodySetMassMatrix (newtonBody, mass, Ixx, Iyy, Izz);
      }
   }
   return true;
}
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Scaling A Compound Collision Body

Postby Bird » Thu Jul 25, 2013 5:26 pm

Ok I loaded CompoundScaleScene.bin and tha seem to work fine.

Yes it does. It even works properly if the Compound body has been scaled before being entered into the engine. The crash happens when the scale is changed interactively by the user.

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

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Fri Sep 06, 2013 8:58 am

Ok now I think I have uniform scale on compound, that is non destructive.
later I will add the nor uniform part, but you can test that an see if it works.

on this pass I am try to finish all of scaling stuff
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Fri Sep 06, 2013 12:35 pm

Julio Jerez wrote:Ok now I think I have uniform scale on compound, that is non destructive.
later I will add the nor uniform part, but you can test that an see if it works.

on this pass I am try to finish all of scaling stuff


I tried the latest sync but I'm hitting the assert on line 543 of dgCollisionInstance.cpp. I hit it for non-compound shapes too. The scale I'm passing in is 1.02 on all axis so it's uniform. But it looks like there's no case implemented for m_uniform yet.

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

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Fri Sep 06, 2013 1:01 pm

Oh I am sorry, the case was there unifirm and non uniform use the same code, but I deleted to mush commented out dead code.
It is fixed now, please try again
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Fri Sep 06, 2013 2:28 pm

Still having problems when interactively scaling compound shapes. If I save the scene and reload if works fine.

http://hurleyworks.com/media/flash/NewtonCompoundScale/NewtonCompoundScale.html

Also I'm still hitting debug asserts while scaling a CompoundCollision up. Usually the error is in dgVec.h line 813 Expression: ret.m_f[0] == dgFloor(m_f[0]

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

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Fri Sep 06, 2013 3:15 pm

It looks likes the collision is falling too.

can you show me the code you are using to do that.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Fri Sep 06, 2013 3:21 pm

some questions.
is the crash not happing any more?


I think I have an ide what is wrong, you are scaling teh collsion shape. by the teh body still thinks the collsion shape has no changed. and is no updation it location on teh broadphase.

please show me the code you are using to do that. I beleiev it need another function call to make sure the broadphase is also updated after the scale happened. I beleive thiss why it works when it is saved and then reloaded.
In fact I believe thsi apply to all shapes.

I still do not know why you are getting the assert, plase shwo me teh trace Stack when it happen again.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Fri Sep 06, 2013 3:50 pm

Here's the code I'm calling when the user scales the mesh in LW.

Code: Select all
// updateBodyProperties
bool NewtonScene::updateBodyProperties (const BodyID & bodyID)
{   TRACE("NewtonScene::updateBodyProperties")

   PhysicsBodies::iterator it = bodies_.find(bodyID);
   if ( it != bodies_.end() )
   {
      PhysicsBody::Ptr pBody = it->second;
      if( pBody && pBody->component )
      {
         const NewtonBody * const newtonBody = (NewtonBody*)pBody->component->userData;
         if( !newtonBody ) return false;

         NewtonCollision * const collision = NewtonBodyGetCollision(newtonBody);
         if( !collision ) return false;

         if( pBody->bodyDesc.bodyState & BodyState::ScaleChanged )
         {
            NewtonCollisionSetScale(collision, pBody->bodyDesc.scale[0], pBody->bodyDesc.scale[1], pBody->bodyDesc.scale[2] );
            pBody->bodyDesc.bodyState ^= BodyState::ScaleChanged;
         }

         dVector origin;
         dVector inertia;
         dFloat mass = pBody->bodyDesc.mass;
         NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);   
         dFloat Ixx = mass * inertia[0];
         dFloat Iyy = mass * inertia[1];
         dFloat Izz = mass * inertia[2];

         NewtonBodySetMassMatrix (newtonBody, mass, Ixx, Iyy, Izz);
      }
   }
   return true;
}


And here's the stack trace when the crash occurs while interactively scaling
Code: Select all
>   
    msvcr100d.dll!_CrtDbgReportWV(int nRptType, const wchar_t * szFile, int nLine, const wchar_t * szModule, const wchar_t * szFormat, char * arglist)  Line 242   C++
    msvcr100d.dll!_CrtDbgReportW(int nRptType, const wchar_t * szFile, int nLine, const wchar_t * szModule, const wchar_t * szFormat, ...)  Line 258 + 0x2c bytes   C++
    AdvancedPlacement090_64d.dll!dgVector::Floor()  Line 813 + 0x46 bytes   C++
    AdvancedPlacement090_64d.dll!dgBroadPhase::dgNode::SetAABB(const dgVector & minBox, const dgVector & maxBox)  Line 126 + 0x12 bytes   C++
    AdvancedPlacement090_64d.dll!dgBroadPhase::UpdateBodyBroadphase(dgBody * const body, int threadIndex)  Line 1086   C++
    AdvancedPlacement090_64d.dll!dgBody::UpdateCollisionMatrix(float timestep, int threadIndex)  Line 216   C++
    AdvancedPlacement090_64d.dll!dgBody::SetMatrix(const dgMatrix & matrix)  Line 183   C++
    AdvancedPlacement090_64d.dll!dgBody::SetMatrixIgnoreSleep(const dgMatrix & matrix)  Line 189   C++
    AdvancedPlacement090_64d.dll!dgDynamicBody::SetMatrixIgnoreSleep(const dgMatrix & matrix)  Line 95   C++
    AdvancedPlacement090_64d.dll!NewtonBodySetMatrix(const NewtonBody * const bodyPtr, const float * const matrixPtr)  Line 4920   C++
    AdvancedPlacement090_64d.dll!IPhysics::NewtonScene::setBodyPose(const unsigned __int64 & bodyID, bool testForCollisions)  Line 341   C++
    AdvancedPlacement090_64d.dll!IPhysics::PhysicsModel::setBodyPose(const unsigned __int64 & bodyID, bool testForCollision)  Line 181   C++
    AdvancedPlacement090_64d.dll!EventHandler::onMotionUpdateComplete(void * const & itemID, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & itemName, const double & newTime)  Line 222   C++
    AdvancedPlacement090_64d.dll!MasterHandler::onMasterEvent(void * __formal, const st_LWMasterAccess * access)  Line 296 + 0x35 bytes   C++
    AdvancedPlacement090_64d.dll!LWKit::Statics::onMasterEvent<MasterHandler>(void * inst, const st_LWMasterAccess * access)  Line 60   C++
    Layout.exe!000000014008995c()    
    Layout.exe!00000001401c3824()    
    Layout.exe!000000014008a41a()    
    Layout.exe!00000001401380a7()    
    Layout.exe!00000001401baa38()    
    Layout.exe!00000001401b9e68()    
    Layout.exe!00000001401ba26c()    
    Layout.exe!000000014038da67()    
    kernel32.dll!000007fb3f691832()    
    ntdll.dll!000007fb413ad609()
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Fri Sep 06, 2013 4:43 pm

on the assert can you show print the values of the vector. when the assert happens?
ans also the value of the matrix when you call the function.
AdvancedPlacement090_64d.dll!NewtonBodySetMatrix(const NewtonBody * const bodyPtr, const float * const matrixPtr)

that lead to the crash.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Fri Sep 06, 2013 5:43 pm

Ok let us deal with the first problem first, in thsi function

Code: Select all
// updateBodyProperties
bool NewtonScene::updateBodyProperties (const BodyID & bodyID)
{   TRACE("NewtonScene::updateBodyProperties")

   PhysicsBodies::iterator it = bodies_.find(bodyID);
   if ( it != bodies_.end() )
   {
      PhysicsBody::Ptr pBody = it->second;
      if( pBody && pBody->component )
      {
         const NewtonBody * const newtonBody = (NewtonBody*)pBody->component->userData;
         if( !newtonBody ) return false;

         NewtonCollision * const collision = NewtonBodyGetCollision(newtonBody);
         if( !collision ) return false;

         if( pBody->bodyDesc.bodyState & BodyState::ScaleChanged )
         {
            NewtonCollisionSetScale(collision, pBody->bodyDesc.scale[0], pBody->bodyDesc.scale[1], pBody->bodyDesc.scale[2] );
            pBody->bodyDesc.bodyState ^= BodyState::ScaleChanged;
         }

         dVector origin;
         dVector inertia;
         dFloat mass = pBody->bodyDesc.mass;
         NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);   
         dFloat Ixx = mass * inertia[0];
         dFloat Iyy = mass * inertia[1];
         dFloat Izz = mass * inertia[2];

         NewtonBodySetMassMatrix (newtonBody, mass, Ixx, Iyy, Izz);
      }
   }
   return true;
}


In newton therd are two scale functions.
void NewtonCollisionSetScale (const NewtonCollision* const collision, dFloat scaleX, dFloat scaleY, dFloat scaleZ);
void NewtonBodySetCollision (const NewtonBody* const body, const NewtonCollision* const collision);

NewtonCollisionSetScale scale only the colllion shape. but does no notify anyone of what was done.
NewtonBodySetCollision scale the collision shape and after that notify the world that the body owning the shape needs to opdate its AABB,
and that the world also need to update it Node braphse AABB which is different.
you are calling the first.

It has to be like that for real time because scalling a shape happens all the time at run time for effect likes vehicles,
player controllers, triggers, raycats and so on. you do not want these local effects generate global effects over the world.

in you case you need to use teh secund version. your function will be better if it was write like this

Code: Select all
bool NewtonScene::updateBodyProperties (const BodyID & bodyID)
{   TRACE("NewtonScene::updateBodyProperties")

   PhysicsBodies::iterator it = bodies_.find(bodyID);
   if ( it != bodies_.end() )
   {
      PhysicsBody::Ptr pBody = it->second;
      if( pBody && pBody->component )
      {
         const NewtonBody * const newtonBody = (NewtonBody*)pBody->component->userData;

         if( pBody->bodyDesc.bodyState & BodyState::ScaleChanged )
         {
            //NewtonCollisionSetScale(collision, pBody->bodyDesc.scale[0], pBody->bodyDesc.scale[1], pBody->bodyDesc.scale[2] );
            NewtonBodySetCollisionScale (pBody, pBody->bodyDesc.scale[0], pBody->bodyDesc.scale[1], pBody->bodyDesc.scale[2]);
            pBody->bodyDesc.bodyState ^= BodyState::ScaleChanged;
         }

         // I do no thonk you nee to do this, the scale above does that more effeceintly
         // bu I am not sure, needs to be tested.
         dVector origin;
         dVector inertia;
         dFloat mass = pBody->bodyDesc.mass;
         NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);   
         dFloat Ixx = mass * inertia[0];
         dFloat Iyy = mass * inertia[1];
         dFloat Izz = mass * inertia[2];
         NewtonBodySetMassMatrix (newtonBody, mass, Ixx, Iyy, Izz);
      }
   }
   return true;
}

Now the function that is checked in has a bug that I just fixed, you need to update so that that change take effect.
please try that and let us see where we are.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest

cron