Heightfield collision, newton 2

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Heightfield collision, newton 2

Postby Crashy » Tue Mar 20, 2012 10:01 am

The sdk demos are working, it's crashing in my own app. I'm debugging to see why.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Heightfield collision, newton 2

Postby Julio Jerez » Tue Mar 20, 2012 10:17 am

can you send me a demo, so that I can see why?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Heightfield collision, newton 2

Postby Crashy » Tue Mar 20, 2012 10:42 am

It's quite complicated to send a demo, the app is really big and there is some sort of confidentiality.

After some tests I can say that it is related to the OgreNewt::RaycastVehicle. If I make only standard rigid bodies, it works fine. I don't think it is a problem of newton but a problem from OgreNewt. I'll try to see what exactly.

Now when I fire a ray cast, it crashes on the assert on the beginning of this func:

Code: Select all
inline dgFloat32 dgCollisionInstance::RayCast (const dgVector& localP0, const dgVector& localP1, dgContactPoint& contactOut, OnRayPrecastAction preFilter, const dgBody* const body, void* const userData) const
{
   _ASSERTE (m_isUnitScale);
   if (!preFilter || preFilter(body, this, userData)) {
      if (m_isUnitScale) {
         dgFloat32 t = m_childShape->RayCast (localP0, localP1, contactOut, body, userData);
         if (t <= 1.0f) {
            if (!m_childShape->IsType(dgCollision::dgCollisionMesh_RTTI)) {
               contactOut.m_userId = GetUserDataID();
            }
         }
         return t;
      } else {
         _ASSERTE (0);
      }
   }

   return dgFloat32 (1.2f);
}



BTW, Thanks for your help and your great engine.


Edit:

Some more infos: in release mode raycasting does'nt crash anymore and raycasting against terrain is working fine, detected everytime. But collision with rigid body and terrain has the same symptoms than before, sometime it works, sometimes not.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Heightfield collision, newton 2

Postby Julio Jerez » Tue Mar 20, 2012 11:11 am

Crashy wrote:in this function
Code: Select all
inline dgFloat32 dgCollisionInstance::RayCast (const dgVector& localP0, const dgVector& localP1, dgContactPoint& contactOut, OnRayPrecastAction preFilter, const dgBody* const body, void* const userData) const
{
   _ASSERTE (m_isUnitScale);
   if (!preFilter || preFilter(body, this, userData)) {
      if (m_isUnitScale) {
         dgFloat32 t = m_childShape->RayCast (localP0, localP1, contactOut, body, userData);
         if (t <= 1.0f) {
            if (!m_childShape->IsType(dgCollision::dgCollisionMesh_RTTI)) {
               contactOut.m_userId = GetUserDataID();
            }
         }
         return t;
      } else {
         _ASSERTE (0);
      }
   }

   return dgFloat32 (1.2f);
}



it crash in _ASSERTE (m_isUnitScale);
or in _ASSERTE (0); ?

it does no make sence that it crashe in _ASSERTE (0);
since the code will only handle non scale shape at this time.

I move all collsion shape to be instance base, but I still need to complete all the existing funtionality before I start impemnetin the unifirm and non uniform scale.
ar you using vehicles now?
can you not usin then unl\till at leat nex week when I go over all teh existin functinality, as soon as I complete then all the oteh funtion in teh SDK soudl start to work as expected.
bascially I have to go re enabling teh existing Unit test demos, one by one, an as they get re enable teh othe funtion shpul; start to work.

bascailly wat I do is that before I add a new feature I write a uniot test fuintion that test each an every function of that feature.
then I make sure all work.
however the methdo brak down if I make a radical modification, liek moving from referenced collison shape to intance base collision.
when doin that a whol lot of stop cease working and I have to wrap a commnet aorund it.
it is possible that many joints and othe funtionality is still broken. but I am competeing them day by day.

what I do is that I give priority to request featyre, but some time a request feature require a core function, so it may look I am not wroking on it, but I am.
at this time the mot import thing is to compelte all of teh unit test, so that everything is back to normal.

moveng to inatance base collsion was a huge task that I understimated. It since eassy at first, but it touches the entire engine, so I have to commet a lot of stuff temporatilly.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Heightfield collision, newton 2

Postby Julio Jerez » Tue Mar 20, 2012 11:14 am

fro you information, the vehoicles in newton 300 are gerring a huge overhold.
I am bringging back the model of newton 1.53 with many improvement.

and I estimnated that I will be working on it next week. I added the test already.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Heightfield collision, newton 2

Postby Crashy » Tue Mar 20, 2012 11:19 am

Hi,

It crashes in _ASSERTE (m_isUnitScale);

Yes I'm using vehicles, but I can disable them for the moment and wait until they're fixed.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Heightfield collision, newton 2

Postby Julio Jerez » Tue Mar 20, 2012 12:29 pm

I guess that vehicle joint is call some not impemneted funtion. It will be corrected next week.

are you using the vehicle joint? If you are you will be the first to try the new vehicle, which I beleive is going to kick asssssss, believe me...
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Heightfield collision, newton 2

Postby Crashy » Tue Mar 20, 2012 12:38 pm

I use the vehicle joint yes, but I use it to handle a landing gear of an aircraft. About that I'd have a special request, will it be possible to disable/enable a tire on the fly?
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Heightfield collision, newton 2

Postby Crashy » Tue Mar 20, 2012 1:13 pm

I'm trying to find why the collision with the terrain is not working everywhere, do you have an hint on how and where to debug into the newton code?

It's quite complex and I don't know if there are special methods to debug physics.

Thanks.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Heightfield collision, newton 2

Postby Julio Jerez » Tue Mar 20, 2012 1:29 pm

Crashy wrote:I use the vehicle joint yes, but I use it to handle a landing gear of an aircraft. About that I'd have a special request, will it be possible to disable/enable a tire on the fly?

yes that can be done.

the terrain collision should be working every where. can you make a video of were it fail?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Heightfield collision, newton 2

Postby Crashy » Tue Mar 20, 2012 3:54 pm

I sent you a pm with a link to a video.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Heightfield collision, newton 2

Postby Julio Jerez » Tue Mar 20, 2012 5:07 pm

are you sure that there is a collison mesh under the airplan in the place that teh collison misses?
static collision have a special debug display funtion that get call when a object is close to the collind faces.
this is so that is reduce all o fteh overhead rendring large meshes.

in the SDK demo, you can run the highfield demo and click show collison mesh , it will show you the facr on teh terrain that each pice is colliding with.

but fo rthat yo uwill have to change funtins
void NewtonStaticCollisionSetDebugCallback(const NewtonCollision* const staticCollision, NewtonTreeCollisionCallback userCallback)
in Netwon.ccp to this function

Code: Select all
void NewtonStaticCollisionSetDebugCallback(const NewtonCollision* const staticCollision, NewtonTreeCollisionCallback userCallback)
{
   TRACE_FUNCTION(__FUNCTION__);
   dgCollisionInstance* const collision = (dgCollisionInstance*) staticCollision;
   if (collision->IsType (dgCollision::dgCollisionMesh_RTTI)) {
      dgCollisionMesh* const mesh = (dgCollisionMesh*) collision->GetChildShape();
      mesh->SetCollisionCallback ((dgCollisionMeshCollisionCallback) userCallback);
   } else if (collision->IsType (dgCollision::dgCollisionScene_RTTI)) {
      dgCollisionScene* const scene = (dgCollisionScene*) collision->GetChildShape();
      scene->SetCollisionCallback ((dgCollisionMeshCollisionCallback) userCallback);
   }

}


you have to implemnet you call back to save the face that are reported by teh call back, so that you cna reneder the later.
tha way you cna see if there are terrain face whn teh plane is hittoing teh ground.

in the SDK demo the callback looks like this

Code: Select all
void ShowMeshCollidingFaces (const NewtonBody* staticCollisionBody, const NewtonBody* body, int faceID, int vertexCount, const dFloat* vertex, int vertexstrideInBytes)
{
#ifdef USE_STATIC_MESHES_DEBUG_COLLISION
   if (debugMode) {
      if ((debugDisplayCount + vertexCount * 2) < sizeof (debugDisplayCallback) / sizeof(debugDisplayCallback[0])) {
         // we are coping data to and array of memory, another call back may be doing the same thing
         // here fore we need to avoid race conditions
         NewtonWorldCriticalSectionLock (NewtonBodyGetWorld (staticCollisionBody), 0);

         int stride = vertexstrideInBytes / sizeof (dFloat);
         dVector l0 (vertex[(vertexCount-1) * stride + 0], vertex[(vertexCount-1) * stride + 1], vertex[(vertexCount-1) * stride + 2], 0.0f);
         for (int j = 0; j < vertexCount; j ++) {
            dVector l1 (vertex[j * stride + 0], vertex[j * stride + 1] , vertex[j * stride + 2], 0.0f);
            debugDisplayCallback[debugDisplayCount + 0] = l0;
            debugDisplayCallback[debugDisplayCount + 1] = l1;
            debugDisplayCount  += 2;
            l0 = l1;
         }
   

         // unlock the critical section
         NewtonWorldCriticalSectionUnlock (NewtonBodyGetWorld (staticCollisionBody));
      }

   }
#endif
}


basically it save teh face as lines in an array an dthe it simp[le dra an array lines.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Heightfield collision, newton 2

Postby Crashy » Tue Mar 20, 2012 5:33 pm

I'm sure there is a collision mesh because when I display debug mesh there is no hole in the terrain collision mesh (I see every quads and diagonals), and the raycast works fine on zones where the collision with the plane is not working.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Heightfield collision, newton 2

Postby Julio Jerez » Tue Mar 20, 2012 6:15 pm

the collision can be there, but this function call back will show only the faces that ar onder the colliding shape.
try adding that so that you can see if the face are there, there may be a bug.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Heightfield collision, newton 2

Postby Crashy » Tue Mar 20, 2012 7:51 pm

Okay I implemented a callback, called the NewtonStaticCollisionSetDebugCallback, but it never calls the callback,. After some debug I've seen that, in this part of code:

Code: Select all
if (GetDebugCollisionCallback())
 {
         dgTriplex triplex[3];
         const dgMatrix& matrix = data->m_polySoupBody->GetCollisionMatrix();
         for (dgInt32 i = 0; i < faceCount; i ++) {
            for (dgInt32 j = 0; j < 3; j ++) {
               dgVector p (matrix.TransformVector(vertex[indices[i * 3 + j]]));
               triplex[j].m_x = p.m_x;
               triplex[j].m_y = p.m_y;
               triplex[j].m_z = p.m_z;
            }
            GetDebugCollisionCallback() (data->m_polySoupBody, data->m_objBody, attributes[i], 3, &triplex[0].m_x, sizeof (dgTriplex));
         }
      }


GetDebugCollisionCallback() always returns NULL pointer.

I've got the same result for the Newton SDK Demos, the callback is never called even if NewtonStaticCollisionSetDebugCallback is called.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 5 guests