//---------------------------------------------------------------------------------------------- public override void ClientResetScene() { //#ifdef SHOW_NUM_DEEP_PENETRATIONS gNumDeepPenetrationChecks = 0; gNumGjkChecks = 0; //#endif //SHOW_NUM_DEEP_PENETRATIONS gNumClampedCcdMotions = 0; int numObjects = 0; foreach (DiscreteDynamicsWorld world in m_worlds) { // Prefer a better place for this... world.SetDebugDrawer(m_debugDraw); numObjects = world.GetNumCollisionObjects(); IList <CollisionObject> copyArray = world.GetCollisionObjectArray(); for (int i = 0; i < numObjects; i++) { CollisionObject colObj = copyArray[i]; RigidBody body = RigidBody.Upcast(colObj); if (body != null) { if (body.GetMotionState() != null) { DefaultMotionState myMotionState = (DefaultMotionState)body.GetMotionState(); myMotionState.m_graphicsWorldTrans = myMotionState.m_startWorldTrans; body.SetCenterOfMassTransform(ref myMotionState.m_graphicsWorldTrans); colObj.SetInterpolationWorldTransform(ref myMotionState.m_startWorldTrans); if (colObj.GetActivationState() != ActivationState.DISABLE_DEACTIVATION) { colObj.ForceActivationState(ActivationState.ACTIVE_TAG); colObj.Activate(); colObj.SetDeactivationTime(0); } //colObj.setActivationState(WANTS_DEACTIVATION); } //removed cached contact points (this is not necessary if all objects have been removed from the dynamics world) world.GetBroadphase().GetOverlappingPairCache().CleanProxyFromPairs(colObj.GetBroadphaseHandle(), world.GetDispatcher()); if (!body.IsStaticObject()) { IndexedVector3 zero = IndexedVector3.Zero; body.SetLinearVelocity(ref zero); body.SetAngularVelocity(ref zero); } } } ///reset some internal cached data in the broadphase world.GetBroadphase().ResetPool(world.GetDispatcher()); world.GetConstraintSolver().Reset(); } }
//---------------------------------------------------------------------------------------------- public virtual void RenderScenePassMultiWorld(int pass, GameTime gameTime, DiscreteDynamicsWorld world) { IndexedMatrix m = IndexedMatrix.Identity; IndexedBasisMatrix rot = IndexedBasisMatrix.Identity; int numObjects = world.GetNumCollisionObjects(); IndexedVector3 wireColor = new IndexedVector3(1, 0, 0); for (int i = 0; i < numObjects; i++) { CollisionObject colObj = world.GetCollisionObjectArray()[i]; RigidBody body = RigidBody.Upcast(colObj); if (body != null && body.GetMotionState() != null) { DefaultMotionState myMotionState = (DefaultMotionState)body.GetMotionState(); //myMotionState.m_graphicsWorldTrans.getOpenGLMatrix(m); m = myMotionState.m_graphicsWorldTrans; rot = myMotionState.m_graphicsWorldTrans._basis; } else { //colObj.getWorldTransform().getOpenGLMatrix(m); m = colObj.GetWorldTransform(); rot = colObj.GetWorldTransform()._basis; } wireColor = new IndexedVector3(1.0f, 1.0f, 0.5f); //wants deactivation if ((i & 1) != 0) { wireColor = new IndexedVector3(0f, 0f, 1f); } ///color differently for active, sleeping, wantsdeactivation states if (colObj.GetActivationState() == ActivationState.ACTIVE_TAG) //active { if ((i & 1) != 0) { wireColor += new IndexedVector3(1f, 0f, 0f); } else { wireColor += new IndexedVector3(.5f, 0f, 0f); } } if (colObj.GetActivationState() == ActivationState.ISLAND_SLEEPING) //ISLAND_SLEEPING { if ((i & 1) != 0) { wireColor += new IndexedVector3(0f, 1f, 0f); } else { wireColor += new IndexedVector3(0f, 05f, 0f); } } IndexedVector3 min, max; world.GetBroadphase().GetBroadphaseAabb(out min, out max); min -= MathUtil.MAX_VECTOR; max += MathUtil.MAX_VECTOR; // printf("aabbMin=(%f,%f,%f)\n",aabbMin.getX(),aabbMin.getY(),aabbMin.getZ()); // printf("aabbMax=(%f,%f,%f)\n",aabbMax.getX(),aabbMax.getY(),aabbMax.getZ()); // m_dynamicsWorld.getDebugDrawer().drawAabb(aabbMin,aabbMax,btVector3(1,1,1)); switch (pass) { case 0: { m_shapeDrawer.DrawXNA(ref m, colObj.GetCollisionShape(), ref wireColor, m_debugDraw.GetDebugMode(), ref min, ref max, ref m_lookAt, ref m_perspective); break; } case 1: { IndexedVector3 shadow = rot * m_lightDirection; m_shapeDrawer.DrawShadow(ref m, ref shadow, colObj.GetCollisionShape(), ref min, ref max); break; } case 2: { IndexedVector3 adjustedWireColor = wireColor * 0.3f; m_shapeDrawer.DrawXNA(ref m, colObj.GetCollisionShape(), ref adjustedWireColor, 0, ref min, ref max, ref m_lookAt, ref m_perspective); break; } } } }
public override void DumpDebugInfo(StringBuilder stringBuilder) { base.DumpDebugInfo(stringBuilder); stringBuilder.AppendFormat("BulletXNAObject type[{0}] actiState[{1}] mask[{2}] flags[{3}]", RigidBody != null?"RB":"G", CollisionObject.GetActivationState(), CollisionMask, CollisionGroups); GameComponentHelper.PrintVector3(stringBuilder, "LinVel", LinearVelocity); if (CollisionObject.GetBroadphaseHandle() != null) { GameComponentHelper.PrintVector3(stringBuilder, "aaBMin", CollisionObject.GetBroadphaseHandle().m_aabbMin); GameComponentHelper.PrintVector3(stringBuilder, "aaBMax", CollisionObject.GetBroadphaseHandle().m_aabbMax); } }