private void UpdatePhysicsElement() { if (!Solid) { deletePhysicsElement(); return; } if (Static) { if (dynamicPhysicsElement != null) { deletePhysicsElement(); } else if (staticPhysicsElement != null && staticPhysicsElement.Mesh != Mesh) { deletePhysicsElement(); } } else { if (staticPhysicsElement != null) { deletePhysicsElement(); } else if (dynamicPhysicsElement != null && dynamicPhysicsElement.Mesh != Mesh) { deletePhysicsElement(); } } if (Mesh == null) { return; } if (Static) { if (staticPhysicsElement == null) { staticPhysicsElement = factory.CreateStaticElement(Mesh, Entity.WorldMatrix.xna()); } staticPhysicsElement.ActorUserData = this; } else { if (dynamicPhysicsElement == null) { dynamicPhysicsElement = factory.CreateDynamicElement(Mesh, Entity.WorldMatrix.xna()); } dynamicPhysicsElement.ActorUserData = this; } }
private void deletePhysicsElement() { if (staticPhysicsElement != null) { factory.DeleteStaticElement(staticPhysicsElement); staticPhysicsElement = null; } if (dynamicPhysicsElement != null) { factory.DeleteDynamicElement(dynamicPhysicsElement); dynamicPhysicsElement = null; } }