Terrain Holes

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Terrain Holes

Postby Leadwerks » Fri Jul 03, 2009 2:15 pm

Is it possible to modify terrain tile collision by modifying the m_attribute array of the newtonheightfieldcollision object? Is the m_attribute an array of bytes? What value should I use to disable collision on a single terrain tile?
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Terrain Holes

Postby JernejL » Fri Jul 03, 2009 2:44 pm

I guess, you could check if the contacts are in specific region of heightfield and remove the contacts in that case.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Terrain Holes

Postby Leadwerks » Fri Jul 03, 2009 3:00 pm

I remember Julio saying there was some way to disable specific terrain tiles. I thought that was what the attribute field was for.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Terrain Holes

Postby Julio Jerez » Fri Jul 03, 2009 5:21 pm

The attribute face ID is the same as the Face Id of the faces in a collision tree,
You get them in a material callback like this

Code: Select all
// say the the id for invesible face is
#define HOLE_INTERRAIN 10

void GenericContactProcess (const NewtonJoint* contactJoint, dFloat timestep, int threadIndex)
{
   int isHightField;
   NewtonBody* body;
   NewtonCollision* collision;
   NewtonCollisionInfoRecord info;

   isHightField = 1;
   body = NewtonJointGetBody0 (contactJoint);
   collision = NewtonBodyGetCollision(body);
   NewtonCollisionGetInfo(collision, &info);
   if (info.m_collisionType != SERIALIZE_ID_HEIGHTFIELD) {
      body = NewtonJointGetBody1 (contactJoint);
      collision = NewtonBodyGetCollision(body);
      NewtonCollisionGetInfo(collision, &info);
      isHightField  = (info.m_collisionType == SERIALIZE_ID_HEIGHTFIELD);
   }

   if (isHightField) {
      void* nextContact;
      for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = nextContact) {
         int faceID;
         NewtonMaterial* material;

         nextContact = NewtonContactJointGetNextContact (contactJoint, contact);

         material = NewtonContactGetMaterial (contact);
         faceID = NewtonMaterialGetContactFaceAttribute (material);
         if (faceID == HOLE_INTERRAIN) {
            NewtonContactJointRemoveContact (contactJoint, contact);
         }
      }
   }
}


I hope thsi is eassy.
you can also do teh same for collison tree and make face invsisible if you want :D
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Terrain Holes

Postby Leadwerks » Sat Jul 04, 2009 12:22 pm

Works great!
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest