public override float Simulate(float timeStep) { lock (m_taintedActors) { foreach (PhysicsActor act in m_taintedActors) { if (act is BulletDotNETCharacter) { ((BulletDotNETCharacter)act).ProcessTaints(timeStep); } if (act is BulletDotNETPrim) { ((BulletDotNETPrim)act).ProcessTaints(timeStep); } } m_taintedActors.Clear(); } lock (m_characters) { foreach (BulletDotNETCharacter chr in m_characters) { chr.Move(timeStep); } } lock (m_prims) { foreach (BulletDotNETPrim prim in m_prims) { if (prim != null) { prim.Move(timeStep); } } } float steps = m_world.stepSimulation(timeStep, 10, WorldTimeComp); foreach (BulletDotNETCharacter chr in m_characters) { chr.UpdatePositionAndVelocity(); } foreach (BulletDotNETPrim prm in m_activePrims) { /* * if (prm != null) * if (prm.Body != null) */ prm.UpdatePositionAndVelocity(); } if (m_CollisionInterface != null) { List <BulletDotNETPrim> primsWithCollisions = new List <BulletDotNETPrim>(); List <BulletDotNETCharacter> charactersWithCollisions = new List <BulletDotNETCharacter>(); // get the collisions that happened this tick List <BulletDotNET.ContactAddedCallbackHandler.ContactInfo> collisions = m_CollisionInterface.GetContactList(); // passed back the localID of the prim so we can associate the prim foreach (BulletDotNET.ContactAddedCallbackHandler.ContactInfo ci in collisions) { // ContactPoint = { contactPoint, contactNormal, penetrationDepth } ContactPoint contact = new ContactPoint(new Vector3(ci.pX, ci.pY, ci.pZ), new Vector3(ci.nX, ci.nY, ci.nZ), ci.depth); ProcessContact(ci.contact, ci.contactWith, contact, ref primsWithCollisions, ref charactersWithCollisions); ProcessContact(ci.contactWith, ci.contact, contact, ref primsWithCollisions, ref charactersWithCollisions); } m_CollisionInterface.Clear(); // for those prims and characters that had collisions cause collision events foreach (BulletDotNETPrim bdnp in primsWithCollisions) { bdnp.SendCollisions(); } foreach (BulletDotNETCharacter bdnc in charactersWithCollisions) { bdnc.SendCollisions(); } } return(steps); }
public override float Simulate(float timeStep) { lock (m_taintedActors) { foreach (PhysicsActor act in m_taintedActors) { if (act is BulletDotNETCharacter) { ((BulletDotNETCharacter)act).ProcessTaints(timeStep); } if (act is BulletDotNETPrim) { ((BulletDotNETPrim)act).ProcessTaints(timeStep); } } m_taintedActors.Clear(); } lock (m_characters) { foreach (BulletDotNETCharacter chr in m_characters) { chr.Move(timeStep); } } lock (m_prims) { foreach (BulletDotNETPrim prim in m_prims) { if (prim != null) { prim.Move(timeStep); } } } float steps = m_world.stepSimulation(timeStep * 1000, 10, WorldTimeComp); foreach (BulletDotNETCharacter chr in m_characters) { chr.UpdatePositionAndVelocity(); } foreach (BulletDotNETPrim prm in m_activePrims) { /* * if (prm != null) * if (prm.Body != null) */ prm.UpdatePositionAndVelocity(); } if (m_CollisionInterface != null) { List <int> collisions = m_CollisionInterface.GetContactList(); lock (collisions) { foreach (int pvalue in collisions) { System.Console.Write(string.Format("{0} ", pvalue)); } } m_CollisionInterface.Clear(); } return(steps); }