public d.Contact GetContactPoint (ActorTypes actorType) { d.Contact contact = new d.Contact (); //Defaults contact.surface.mode |= d.ContactFlags.SoftERP; contact.surface.soft_cfm = 0.010f; contact.surface.soft_erp = 0.010f; float restSquared = _parent_entity.Restitution * _parent_entity.Restitution; contact.surface.bounce = _parent_entity.Restitution * (Velocity.Z * -(restSquared));//Its about 1:1 surprisingly, even though this constant was for havok if (contact.surface.bounce > 1.5f) contact.surface.bounce = 0.75f; //Limit the bouncing please... contact.surface.bounce_vel = 0.05f * _parent_entity.Restitution * (-Velocity.Z * restSquared); //give it a good amount of bounce and have it depend on how much velocity is there too contact.surface.mode |= d.ContactFlags.Bounce; //Add bounce contact.surface.mu = 800; if(actorType == ActorTypes.Prim) contact.surface.mu *= _parent_entity.Friction; if (m_vehicle.Type != Vehicle.TYPE_NONE) contact.surface.mu *= 0.05f; contact.surface.mu2 = contact.surface.mu; return contact; }
private void AddODECollision(d.ContactGeom curContact, PhysicsActor p1, PhysicsActor p2, IntPtr b1, IntPtr b2, ContactPoint maxDepthContact, ref int NotSkipedCount) { IntPtr joint = IntPtr.Zero; bool p2col = true; // We only need to test p2 for 'jump crouch purposes' if (p2 is WhiteCoreODECharacter && p1.PhysicsActorType == (int) ActorTypes.Prim) { // Testing if the collision is at the feet of the avatar if ((p2.Position.Z - maxDepthContact.Position.Z) < (p2.Size.Z*0.5f)) p2col = false; } p2.IsTruelyColliding = true; p2.IsColliding = p2col; // Logic for collision handling // Note, that if *all* contacts are skipped (VolumeDetect) // The prim still detects (and forwards) collision events but // appears to be phantom for the world // No collision on volume detect prims if ((p1 is WhiteCoreODEPrim && p1.VolumeDetect) || (p2 is WhiteCoreODEPrim && p2.VolumeDetect)) return; if (curContact.depth < 0f) return; //Has to be penetrating if (m_filterCollisions && checkDupe(curContact, p2.PhysicsActorType)) return; if (m_filterCollisions) _perloopContact.Add(curContact); NotSkipedCount++; // If we're colliding against terrain if (p1.PhysicsActorType == (int) ActorTypes.Ground) { if (p2.PhysicsActorType == (int) ActorTypes.Prim) { ((WhiteCoreODEPrim) p2).GetContactParam(p2, ref newGlobalcontact); joint = CreateContacJoint(curContact); } else { newGlobalcontact = new d.Contact(); newGlobalcontact.surface.mode |= d.ContactFlags.SoftERP; newGlobalcontact.surface.mu = 75; newGlobalcontact.surface.bounce = 0.1f; newGlobalcontact.surface.soft_erp = 0.05025f; //GetContactParam(0.0f, AvatarContactBounce, ref newGlobalcontact); joint = CreateContacJoint(curContact); } //Can't collide against anything else, agents do their own ground checks } else if ((p1.PhysicsActorType == (int) ActorTypes.Agent) && (p2.PhysicsActorType == (int) ActorTypes.Agent)) { GetContactParam(0.0f, AvatarContactBounce, ref newGlobalcontact); joint = CreateContacJoint(curContact); } else if (p1.PhysicsActorType == (int) ActorTypes.Prim) { //Add restitution and friction changes ((WhiteCoreODEPrim) p1).GetContactParam(p2, ref newGlobalcontact); joint = CreateContacJoint(curContact); } if (ContinueCollisionProcessing && joint != IntPtr.Zero) { d.JointAttach(joint, b1, b2); m_global_contactcount++; joint = IntPtr.Zero; } }