internal void Update() { if (m_objectPtr != IntPtr.Zero) { Transform transform = Transform; if (transform != null) { lock (transform) { byte staticState = transform.StaticState; if ((staticState & 0b1 << 2) == 0) { IntPtr ptr = BtCollisionObject.CollisionObject_getTransformMatrix(m_objectPtr); Matrix4 matrix = Marshal.PtrToStructure <Matrix4>(ptr); transform.Translation = matrix.ExtractTranslation(); transform.Quaternion = matrix.ExtractRotation(); BtCollisionObject.CollisionObject_freeTransformMatrix(ptr); } else { Vector3 translation = transform.Translation; Quaternion rotation = transform.Quaternion; BtCollisionObject.CollisionObject_setWorldTranslation(m_objectPtr, translation.X, translation.Y, translation.Z); BtCollisionObject.CollisionObject_setWorldRotation(m_objectPtr, rotation.X, rotation.Y, rotation.Z, rotation.W); } transform.StaticState = (byte)((staticState | (0b1 << 2)) ^ (0b1 << 2)); } }
protected void GetState() { m_static = BtCollisionObject.CollisionObject_isStaticObject(m_objectPtr); m_kinematic = BtCollisionObject.CollisionObject_isKinematicObject(m_objectPtr); }