static void printGeom (PrintingContext &c, dxGeom *g) { unsigned long category = dGeomGetCategoryBits (g); if (category != (unsigned long)(~0)) { c.printIndent(); fprintf (c.file,"category_bits = %lu\n",category); } unsigned long collide = dGeomGetCollideBits (g); if (collide != (unsigned long)(~0)) { c.printIndent(); fprintf (c.file,"collide_bits = %lu\n",collide); } if (!dGeomIsEnabled (g)) { c.print ("disabled",1); } switch (g->type) { case dSphereClass: printSphere (c,g); break; case dBoxClass: printBox (c,g); break; case dCapsuleClass: printCapsule (c,g); break; case dCylinderClass: printCylinder (c,g); break; case dPlaneClass: printPlane (c,g); break; case dRayClass: printRay (c,g); break; case dConvexClass: printConvex (c,g); break; case dTriMeshClass: printTriMesh (c,g); break; case dHeightfieldClass: printHeightfieldClass (c,g); break; } }
bool EOSOdeCollisionObject::isActive() { if(this->collisionGeometry != 0) { return dGeomIsEnabled(this->collisionGeometry); } return false; }
bool Construction::IsGeomActive() { for(int i=0; i<nObjects; i++) { if(ObjectList[i].HasGeom ) { if(dGeomIsEnabled( ObjectList[i].Geom ) ) return true; } } return false; }
static void nearCallback (void *data, dGeomID o1, dGeomID o2) { //make sure both of the geom's are enabled (otherwise this is //a waste of our time if( !dGeomIsEnabled( o1 ) || !dGeomIsEnabled (o2 )) { return; } //collide spaces if neccesary if (dGeomIsSpace (o1) || dGeomIsSpace (o2)) { // collide the space(s?) dSpaceCollide2 (o1,o2,data,&nearCallback); // collide all geoms/spaces within the spaces //if (dGeomIsSpace (o1)) dSpaceCollide ((dSpaceID)o1,data,&nearCallback); //if (dGeomIsSpace (o2)) dSpaceCollide ((dSpaceID)o2,data,&nearCallback); } //otherwise no spaces, just collide geoms else { //make sure one of the geoms has a body dBodyID body1 = dGeomGetBody( o1 ); dBodyID body2 = dGeomGetBody( o2 ); //if( body1 == 0 && body2 == 0) //return; //make sure that the bodies are enabled //declarations DynamicsObject* dynobj=NULL, *dynobj2=NULL; int n; DynamicsSolver* solver = (DynamicsSolver*)data; //Get 64 contacts const int N = 64; dContact contact[N]; n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact)); //Sort all the contacts dContact* sortedContacts[N]; for( int i=0; i<n; i++ ) sortedContacts[i] = &contact[i]; qsort( sortedContacts, n,sizeof( dContact*), compareContacts ); //determine how many contacts to actually care about //if( n > 8 ) // n = 8; if (n > 0) { //figure out surface desc stuff DynamicsSurfaceDesc* sd1, *sd2; DynamicsSurfaceDesc finaldesc; sd1 = (DynamicsSurfaceDesc*)dGeomGetData(contact[0].geom.g1); sd2 = (DynamicsSurfaceDesc*)dGeomGetData(contact[0].geom.g2); finaldesc.Combine( sd1, sd2); //Get the bodies involved in the collision dBodyID b1, b2; b1 = dGeomGetBody(contact[0].geom.g1); b2 = dGeomGetBody(contact[0].geom.g2); //Inform objects of the collision that occured. if(b1) dynobj = (DynamicsObject*)dBodyGetData(b1); if(b2) dynobj2 = (DynamicsObject*)dBodyGetData(b2); if( dynobj ) dynobj->OnCollide ( dynobj2 ); if( dynobj2) dynobj2->OnCollide( dynobj); //Generate contact joints for (int i=0; i<n; i++) { contact[i].surface.mode = dContactSoftERP | dContactSoftCFM | dContactApprox1;// | dContactBounce; //contact[i].surface.mu = 0.5f; contact[i].surface.mu = finaldesc.mu; if(contact[i].geom.normal[1] < .8f ) { contact[i].surface.mu = 0.1f; } contact[i].surface.slip1 = finaldesc.ContactSlip1 ; contact[i].surface.slip2 = finaldesc.ContactSlip2 ; contact[i].surface.soft_erp = finaldesc.SoftERP ; contact[i].surface.soft_cfm = finaldesc.SoftCFM; contact[i].surface.bounce = finaldesc.Bounce; contact[i].surface.bounce_vel = finaldesc.BounceVelocity ; dJointID c = dJointCreateContact (solver->WorldID,solver->ContactGroup,&contact[i]); //Insert friction anisotropy code here fixFrictionVector( b1, b2, contact[i] ); dJointAttach (c, dGeomGetBody(contact[i].geom.g1), dGeomGetBody(contact[i].geom.g2)); } } } }
bool CollidableObject::GetCanCollide() { return dGeomIsEnabled(mGeom) != 0; }