internal unsafe static PhysicsBodyHandle CreateRigidBody(PhysicsShapeHandle shapeHandle, float mass, bool alwaysActive, bool forceIntransigence, bool collideOnlyAgainstWorld, bool collideAgainstDynamicsOnly, IntPtr translationPtr, IntPtr rotationPtr, IntPtr shapeOffsetPtr)
 {
     Assure.GreaterThanOrEqualTo(mass, 0f);
     if (collideOnlyAgainstWorld && collideAgainstDynamicsOnly)
     {
         throw new ArgumentException("Can't collide against world and only dynamics simultaneously.");
     }
     return(LosgapSystem.InvokeOnMaster(() => {
         PhysicsBodyHandle result;
         InteropUtils.CallNative(
             NativeMethods.PhysicsManager_CreateRigidBody,
             translationPtr,
             rotationPtr,
             shapeOffsetPtr,
             shapeHandle,
             mass,
             (InteropBool)alwaysActive,
             (InteropBool)forceIntransigence,
             (InteropBool)collideOnlyAgainstWorld,
             (InteropBool)collideAgainstDynamicsOnly,
             (IntPtr)(&result)
             ).ThrowOnFailure();
         return result;
     }));
 }
 internal static void DestroyShape(PhysicsShapeHandle shape)
 {
     LosgapSystem.InvokeOnMasterAsync(() => InteropUtils.CallNative(
                                          NativeMethods.PhysicsManager_DestroyShape,
                                          shape
                                          ).ThrowOnFailure());
 }
 public static extern InteropBool PhysicsManager_CreateRigidBody(
     IntPtr failReason,
     IntPtr translationPtr,          // Vector4*
     IntPtr rotationPtr,             // Vector4*
     IntPtr physicsShapeOffsetPtr,   // Vector4*
     PhysicsShapeHandle collisionShapeHandle,
     float bodyMass,
     InteropBool alwaysActive,
     InteropBool forceIntransigence,
     InteropBool collideAgainstWorldOnly,
     InteropBool collideAgainstDynamicsOnly,
     IntPtr outBodyHandle             // PhysicsBodyHandle*
     );
 public void SetPhysicsShape(
     PhysicsShapeHandle shapeHandle,
     Vector3 physicsShapeOffset,
     float mass,
     bool forceIntransigence             = false,
     bool disablePerformanceDeactivation = false,
     bool collideOnlyWithWorld           = false,
     bool collideWithOnlyDynamics        = false,
     float restitution     = PhysicsManager.DEFAULT_RESTITUTION,
     float linearDamping   = PhysicsManager.DEFAULT_LINEAR_DAMPING,
     float angularDamping  = PhysicsManager.DEFAULT_ANGULAR_DAMPING,
     float friction        = PhysicsManager.DEFAULT_FRICTION,
     float rollingFriction = PhysicsManager.DEFAULT_ROLLING_FRICTION)
 {
     LosgapSystem.InvokeOnMaster(() => {                     // Anti-deadlock measures x.x
         lock (InstanceMutationLock) {
             if (physicsBody != PhysicsBodyHandle.NULL)
             {
                 physicsBody.Dispose();
             }
             if (this.physicsShapeOffset == null)
             {
                 this.physicsShapeOffset = new AlignedAllocation <Vector4>(TRANSFORM_ALIGNMENT, (uint)sizeof(Vector4));
             }
             this.physicsShapeOffset.Value.Write(physicsShapeOffset);
             physicsBody = PhysicsManager.CreateRigidBody(
                 shapeHandle,
                 mass,
                 disablePerformanceDeactivation,
                 forceIntransigence,
                 collideOnlyWithWorld,
                 collideWithOnlyDynamics,
                 transform.AlignedPointer + 32,
                 transform.AlignedPointer + 16,
                 this.physicsShapeOffset.Value.AlignedPointer
                 );
         }
     });
     SetPhysicsProperties(restitution, linearDamping, angularDamping, friction, rollingFriction);
 }
 public static extern InteropBool PhysicsManager_DestroyShape(
     IntPtr failReason,
     PhysicsShapeHandle shape
     );