Continuous Collision crash after Newton 2.36 to 3.04 upgrade

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Continuous Collision crash after Newton 2.36 to 3.04 upgrade

Postby Yezide » Thu Feb 21, 2013 6:26 am

Hi Julio,

Im writing this from my co-workers account since mine hasnt been activated yet (resigstered 3 weeks ago). It would be great if it could be activated so I dont have to use this account. The name of that account is nebej

I tried updating our game engine to Newton 300 and it almost worked. If I disable continous collision of dynamic bodies then the game runs, but small objects fall through the geometry. When I enbale continous collision the game crashes on the first NewtonUpdate.

Here is the call stack for the crash:
newton.dll!dgWorld::CalculateTimeToImpact(dgContact * const contact, float timestep, int threadIndex, dgVector & p, dgVector & q, dgVector & normal) Line 1303 + 0x3 bytes C++
newton.dll!dgWorldDynamicUpdate::CalculateIslandReactionForces(dgIsland * const island, float timestep, int threadID) Line 174 + 0x32 bytes C++
newton.dll!dgWorldDynamicUpdate::CalculateIslandReactionForcesKernel(void * const context, int threadID) Line 690 C++
newton.dll!dgThreadHive::QueueJob(void (void *, int)* callback, void * const context) Line 204 + 0x9 bytes C++
newton.dll!dgWorldDynamicUpdate::UpdateDynamics(float timestep) Line 222 C++
newton.dll!dgWorld::StepDynamics(float timestep) Line 1282 C++
newton.dll!dgWorld::TickCallback(int threadID) Line 1333 C++
newton.dll!dgMutexThread::Execute(int threadID) Line 64 C++
newton.dll!dgThread::dgThreadSystemCallback(void * threadData) Line 211 C++
newton.dll!ptw32_threadStart(void * vthreadParms) Line 225 + 0x7 bytes C
newton.dll!_callthreadstartex() Line 314 + 0x6 bytes C
newton.dll!_threadstartex(void * ptd) Line 292 + 0x5 bytes C


It crashes on this line and it looks like material is corrupt (dgWorld::CalculateTimeToImpact() Ln. 1303)
Code: Select all
proxy.m_maxContacts = 0;
 proxy.m_timestep = timestep;
 proxy.m_skinThickness = material->m_skinThickness;

It does not crash on the first object in the loop but after a few dozen.


viewtopic.php?f=24&t=6213
This bug might have something to do with it since we are using Collision Trees for our static polygon meshes?
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby Julio Jerez » Thu Feb 21, 2013 3:57 pm

Yezide wrote:Im writing this from my co-workers account since mine hasnt been activated yet (resigstered 3 weeks ago). It would be great if it could be activated so I dont have to use this account. The name of that account is nebej


I activated the account, this seem to be happing quite freqeute wit teh forum software, i think It need to be update it.

about the bug, did that crash happen in debug mode?
are they a sequence of step that I can try to make it happens?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby nebej » Mon Feb 25, 2013 11:05 am

I have only tried with releaseDLL, the other modes do not compile for me.

I tried reproducing the crash outside of our engine and found some more info about what was needed for the crash to happen.

If a dynamic body has ContinuousCollisionMode active and has a NewtonJoint connect to it the game will crash. If it has just a NewtonJoint the object will dissapear.
This is the code I use for creating the body that crashes.

Code: Select all
      gpBoxBody = NewtonCreateDynamicBody(gpNewtonWorld, pShape, cMatrixf::Identity.v);
      NewtonBodySetForceAndTorqueCallback(gpBoxBody, OnUpdateCallback);
      SetBodyMass(gpBoxBody,1);
   
      NewtonBodySetContinuousCollisionMode(gpBoxBody,bContinuesCollision ? 1 : 0);

      mtxTransform = cMatrixf::Identity;
      cVector3f vPos = cVector3f(x,4, y) * 0.5;
      mtxTransform.SetTranslation(vPos);
      NewtonBodySetMatrix(gpBoxBody, &mtxTransform.GetTranspose().m[0][0]);

      if(bJoint)
      {
         cVector3f vJoinPos = 0;
         cVector3f vJoinDir = cVector3f(0, 0, 1);

         NewtonJoint* pNewtonJoint = NewtonConstraintCreateSlider(gpNewtonWorld, vJoinPos.v, vJoinDir.v, gpBoxBody, NULL);
      }


I tried uploading the standalone test app that I made but it was to big (700 kb). I could mail it to you if it will help.
nebej
 
Posts: 2
Joined: Thu Jan 31, 2013 6:05 am

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby nebej » Tue Feb 26, 2013 3:14 am

I uploaded the code to my dropbox. It should compile directly.

https://dl.dropbox.com/u/23783800/NewtonTestApp.zip
nebej
 
Posts: 2
Joined: Thu Jan 31, 2013 6:05 am

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby Julio Jerez » Tue Mar 19, 2013 11:25 am

Ok I am trying to resume what IO was doing on eth engine.
For personal reasons I could not do any work last month, but I can resume now.

I just load this and build the project file, I see that is crashes right away, in the first newton update.
I could not see where because this is using a release build.

I will try to make it link to the debug dll to see what the bug is.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby Julio Jerez » Tue Mar 19, 2013 11:31 am

Oh I see, before doing anything, I did this
Code: Select all
      if(bJoint)
      {
         cVector3f vJoinPos = 0;
         cVector3f vJoinDir = cVector3f(0, 0, 1);

//         NewtonJoint* pNewtonJoint = NewtonConstraintCreateSlider(gpNewtonWorld, vJoinPos.v, vJoinDir.v, gpBoxBody, NULL);
      }

and you are right the joint makes the code crash. that should make much easier to figure out the crash.
My guess is that some call back is going out of sync with the LRU system or a callback pointe is casted to a wrong type, I see what could be.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby Julio Jerez » Tue Mar 19, 2013 12:09 pm

Ok I see that there are some issue I have to solve first. you are using compound with CCD, and soem pathway has no being completed. is no big deal I can fix thet quicklly
one of thsi case is here

Code: Select all
dgInt32 dgCollisionConvex::CalculateConvexCastContacts(dgCollisionParamProxy& proxy) const
{
   dgBody* const floatingBody = proxy.m_floatingBody;
   dgBody* const referenceBody = proxy.m_referenceBody;

   dgVector floatingVeloc (floatingBody->m_veloc);
   dgVector referenceVeloc (referenceBody->m_veloc);

   dgCollisionInstance* const collConicConvexInstance = proxy.m_referenceCollision;
   const dgVector& scale = collConicConvexInstance->m_scale;
   const dgVector& invScale = collConicConvexInstance->m_invScale;
   const dgMatrix& matrix = collConicConvexInstance->GetGlobalMatrix();
   dgInt32 isNonUniformScale = !collConicConvexInstance->m_scaleIsUniform;

   //dgVector veloc (scale.CompProduct4 (matrix.UnrotateVector(floatingVeloc - referenceVeloc)));
   dgVector veloc (matrix.UnrotateVector(floatingVeloc - referenceVeloc));
   if ((veloc % veloc) == dgFloat32 (0.0f)) {
// this should never happens, I need to find out why the code come here if teh reletive veloc is zero.
// in realseo mode thsi will generate divide by zeros, whic will lead to a crash
      _ASSERTE (0);
   }
   _ASSERTE ((veloc % veloc) > dgFloat32 (0.0f));

...


The bug is no on the function is on whe path code tha led to a call to tha function. Basically ot the relative velocity is too smal or zero, the code with use descrete collision, I am suprice thsi happens
I can see that that path way come from the the CCD calculate time of impact, with tow compound shapes.
    > newton_d.dll!dgCollisionConvex::CalculateConvexCastContacts(dgCollisionParamProxy & proxy={...}) Line 3344 C++
    newton_d.dll!dgWorld::CalculateConvexToConvexContacts(dgCollisionParamProxy & proxy={...}) Line 1776 + 0xf bytes C++
    newton_d.dll!dgCollisionCompound::CalculateContactsToCompound(dgCollidingPairCollector::dgPair * const pair=0x07efd028, dgCollisionParamProxy & proxy={...}, int useSimd=0) Line 1822 + 0x12 bytes C++
    newton_d.dll!dgCollisionCompound::CalculateContacts(dgCollidingPairCollector::dgPair * const pair=0x07efd028, dgCollisionParamProxy & proxy={...}, int useSimd=0) Line 1372 + 0x14 bytes C++
    newton_d.dll!dgWorld::CompoundContacts(dgCollidingPairCollector::dgPair * const pair=0x07efd028, dgCollisionParamProxy & proxy={...}) Line 980 C++
    newton_d.dll!dgWorld::CalculateTimeToImpact(dgContact * const contact=0x08166840, float timestep=0.0023079785, int threadIndex=0, dgVector & p={...}, dgVector & q={...}, dgVector & normal={...}) Line 1310 + 0x13 bytes C++
    newton_d.dll!dgWorldDynamicUpdate::CalculateIslandReactionForces(dgIsland * const island=0x07d34960, float timestep=0.016666668, int threadID=0) Line 174 + 0x32 bytes C++
    newton_d.dll!dgWorldDynamicUpdate::CalculateIslandReactionForcesKernel(void * const context=0x07effb58, void * const worldContext=0x00238300, int threadID=0) Line 691 C++
    newton_d.dll!dgThreadHive::QueueJob(void (void *, void *, int)* callback=0x1001f510, void * const context0=0x07effb58, void * const context1=0x00238300) Line 204 + 0xd bytes C++

the good part is that it is consistent and reproducible, It may be that tha case never happen to me before. any way I am cleaning this up.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby carli2 » Wed Mar 20, 2013 5:13 am

Julio Jerez wrote:Ok I am trying to resume what IO was doing on eth engine.
For personal reasons I could not do any work last month, but I can resume now.


I already thought newton was given up because of no commits and still lots of non-working features (inverse force calculation, buoyancy, convex decomposition)
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby Sweenie » Wed Mar 20, 2013 6:00 am

Well, we can't expect Julio to work on Newton 24/7. After all he got his day time work, personal life etc.
Considering Newton is a project he works on at his spare time I'm incredibly impressed how much work he put into it and how much time he spends on helping people solving different physics problems.
Don't want to point my finger at anyone but I dislike threads like "Fix this" or "Fix that"and "Are you done yet?".
There is a big difference between humble requests/suggestions and demands.

I think sometimes Julio doesn't get enough credit for his awesome work.
So Julio, please know that your work is greatly appreciated.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby belfegor » Wed Mar 20, 2013 2:46 pm

So Julio, please know that your work is greatly appreciated.

+1.
User avatar
belfegor
 
Posts: 53
Joined: Mon Sep 18, 2006 4:42 pm
Location: Serbia

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby Julio Jerez » Wed Apr 03, 2013 11:46 am

Ok I believe I fixed that now, there was also a problem with the build in sliding joint, the attachment points were too close compered to the size of the object
I fix it, but I suggest you use the custom joint library, is provide more flexibility.

Please sync to SVN and try again, you can use the compiled dlls, or you can build them.
sorry it took me so long to get to this.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby JoeJ » Sat Apr 06, 2013 5:43 am

I did some tests with CCD. Again i tried to smash bodies (box or capsule) into the static ground.
If i use force based interaction model it works fine now and it seems not possible anymore to force them into the ground box.
But if i use joint based interaction (you remember: kinematic joint acting at body COM), i get an assert because of corrupt numbers. See screenshot.
Attachments
ccd_assert.JPG
ccd_assert.JPG (202.81 KiB) Viewed 9379 times
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby Julio Jerez » Sat Apr 06, 2013 11:07 am

Joe can you send me the test that generate those errors?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby JoeJ » Sat Apr 06, 2013 12:57 pm

I made this code to add it as a new demo to sandbox - much less work for both of us :)
Can you keep that in the sandbox, so it's always easy to modify it when a user wants to replicate a bug in it?

Contains also the penetration bug templates, where the boxes start jittering.
It's not as bad as with complex ragdoll, but the same issue.





Code: Select all
/* Copyright (c) <2009> <Newton Game Dynamics>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely
*/

#include <toolbox_stdafx.h>
#include "SkyBox.h"
#include "../DemoEntityManager.h"
#include "../DemoCamera.h"
#include "DemoMesh.h"
#include "PhysicsUtils.h"

#include "CustomKinematicController.h"


static NewtonBody* BuildBox (DemoEntityManager* const scene, dFloat mass, const dVector& origin, const dVector& size)
{
   dMatrix matrix (GetIdentityMatrix());

   // create the shape and visual mesh as a common data to be re used
   NewtonWorld* const world = scene->GetNewton();
   NewtonCollision* const collision = CreateConvexCollision (world, GetIdentityMatrix(), size, _BOX_PRIMITIVE, 0);


   DemoMesh* const geometry = mass
      ? new DemoMesh("DynBox", collision, "smilli.tga", "smilli.tga", "smilli.tga")
      : new DemoMesh("StaticBox", collision, "wood_0.tga", "wood_0.tga", "wood_1.tga");
   
   matrix.m_posit = origin;
   
   NewtonBody *body = CreateSimpleSolid (scene, geometry, mass, matrix, collision, 0);

   // do not forget to release the assets   
   geometry->Release();
   NewtonDestroyCollision (collision);

   return body;
}




void BasicBoxStacks (DemoEntityManager* const scene)
{
   BuildBox (scene, 0.0f, dVector(0,-5,0), dVector (100, 10, 100)); // ground
   
#if 0

   // provoke CCD assert
   
   NewtonBody* body = BuildBox (scene, 10.0f, dVector(0,3,1), dVector (4,4,4));
   NewtonBodySetContinuousCollisionMode (body, 1);
   CustomKinematicController *kj = new CustomKinematicController(body, dVector (0,3,0));
   kj->SetMaxLinearFriction (1000);
   kj->SetTargetPosit (dVector (0,0,0));

#elif 0

   // provoke 'penetration bug'
   
   NewtonBody* body = BuildBox (scene, 1.0f, dVector(0,3,1), dVector (4,4,4));
   CustomKinematicController *kj = new CustomKinematicController(body, dVector (0,3,0));
   dQuaternion q (dVector(1,0,0), 0.7f);
   kj->SetPickMode (1);
   kj->SetTargetPosit (dVector (0,0,0));
   kj->SetTargetRotation (q);
   kj->SetMaxLinearFriction (500);
   kj->SetMaxAngularFriction (500);

#else

   // provoke 'penetration bug' linear only
   
   NewtonBody* body = BuildBox (scene, 1.0f, dVector(0,3,1), dVector (4,4,4));
   CustomKinematicController *kj = new CustomKinematicController(body, dVector (0,3,0));
   kj->SetTargetPosit (dVector (0,-10,0));
   kj->SetMaxLinearFriction (500);

#endif


   // place camera into position
   dQuaternion rot;
   dVector origin (-20.0f, 2.0f, 0.0f, 0.0f);
   scene->SetCameraMatrix(rot, origin);


//   ExportScene (scene->GetNewton(), "../../../media/test1.ngd");
}

User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Continuous Collision crash after Newton 2.36 to 3.04 upg

Postby Julio Jerez » Sat Apr 06, 2013 1:18 pm

Ok I pasted that in the demo, I see a big box on a flat surface. what should I do to make the bug happens

I do not see what the problems is.
I see some #if /#end should I enable any of those
this confuse me
Code: Select all
#if 0

   // provoke CCD assert

   NewtonBody* body = BuildBox (scene, 10.0f, dVector(0,3,1), dVector (4,4,4));
   NewtonBodySetContinuousCollisionMode (body, 1);
   CustomKinematicController *kj = new CustomKinematicController(body, dVector (0,3,0));
   kj->SetMaxLinearFriction (1000);
   kj->SetTargetPosit (dVector (0,0,0));

#elif 0

   // provoke 'penetration bug'

   NewtonBody* body = BuildBox (scene, 1.0f, dVector(0,3,1), dVector (4,4,4));
   CustomKinematicController *kj = new CustomKinematicController(body, dVector (0,3,0));
   dQuaternion q (dVector(1,0,0), 0.7f);
   kj->SetPickMode (1);
   kj->SetTargetPosit (dVector (0,0,0));
   kj->SetTargetRotation (q);
   kj->SetMaxLinearFriction (500);
   kj->SetMaxAngularFriction (500);

#else

   // provoke 'penetration bug' linear only

   NewtonBody* body = BuildBox (scene, 1.0f, dVector(0,3,1), dVector (4,4,4));
   CustomKinematicController *kj = new CustomKinematicController(body, dVector (0,3,0));
   kj->SetTargetPosit (dVector (0,-10,0));
   kj->SetMaxLinearFriction (500);

#endif



it is executing this part

Code: Select all
   // provoke 'penetration bug' linear only

   NewtonBody* body = BuildBox (scene, 1.0f, dVector(0,3,1), dVector (4,4,4));
   CustomKinematicController *kj = new CustomKinematicController(body, dVector (0,3,0));
   kj->SetTargetPosit (dVector (0,-10,0));
   kj->SetMaxLinearFriction (500);


does that reproduce the bug?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 7 guests