Ejemplo n.º 1
0
 public static unsafe PhysicsShapeHandle CreateScaledSphereShape(float radius, Vector3 scaling, CollisionShapeOptionsDesc shapeOptions)
 {
     return(LosgapSystem.InvokeOnMaster(() => {
         AlignedAllocation <CollisionShapeOptionsDesc> shapeOptionsAligned = new AlignedAllocation <CollisionShapeOptionsDesc>(16L, (uint)sizeof(CollisionShapeOptionsDesc));
         *((CollisionShapeOptionsDesc *)shapeOptionsAligned.AlignedPointer) = shapeOptions;
         AlignedAllocation <Vector4> vec4Aligned = new AlignedAllocation <Vector4>(16L, (uint)sizeof(Vector4));
         *((Vector4 *)vec4Aligned.AlignedPointer) = scaling;
         PhysicsShapeHandle result;
         InteropUtils.CallNative(
             NativeMethods.PhysicsManager_CreateScaledSphereShape,
             radius,
             vec4Aligned.AlignedPointer,
             shapeOptionsAligned.AlignedPointer,
             (IntPtr)(&result)
             ).ThrowOnFailure();
         shapeOptionsAligned.Dispose();
         vec4Aligned.Dispose();
         return result;
     }));
 }
Ejemplo n.º 2
0
 public static unsafe PhysicsShapeHandle CreateConcaveHullShape(IEnumerable <Vector3> vertices, IEnumerable <int> indices, CollisionShapeOptionsDesc shapeOptions, string acdFilePath)
 {
     return(LosgapSystem.InvokeOnMaster(() => {
         AlignedAllocation <CollisionShapeOptionsDesc> shapeOptionsAligned = new AlignedAllocation <CollisionShapeOptionsDesc>(16L, (uint)sizeof(CollisionShapeOptionsDesc));
         *((CollisionShapeOptionsDesc *)shapeOptionsAligned.AlignedPointer) = shapeOptions;
         Vector3 *verticesLocal = stackalloc Vector3[vertices.Count()];
         int *indicesLocal = stackalloc int[indices.Count()];
         int numVertices = 0;
         int numIndices = 0;
         foreach (Vector3 vertex in vertices)
         {
             verticesLocal[numVertices++] = vertex;
         }
         foreach (int index in indices)
         {
             indicesLocal[numIndices++] = index;
         }
         PhysicsShapeHandle result;
         InteropUtils.CallNative(
             NativeMethods.PhysicsManager_CreateConcaveHullShape,
             (IntPtr)verticesLocal,
             numVertices,
             (IntPtr)indicesLocal,
             numIndices,
             shapeOptionsAligned.AlignedPointer,
             acdFilePath,
             (IntPtr)(&result)
             ).ThrowOnFailure();
         shapeOptionsAligned.Dispose();
         return result;
     }));
 }
Ejemplo n.º 3
0
 public static unsafe PhysicsShapeHandle CreateBoxShape(float width, float height, float depth, CollisionShapeOptionsDesc shapeOptions)
 {
     return(LosgapSystem.InvokeOnMaster(() => {
         AlignedAllocation <CollisionShapeOptionsDesc> shapeOptionsAligned = new AlignedAllocation <CollisionShapeOptionsDesc>(16L, (uint)sizeof(CollisionShapeOptionsDesc));
         *((CollisionShapeOptionsDesc *)shapeOptionsAligned.AlignedPointer) = shapeOptions;
         AlignedAllocation <Vector4> boxExtents = new AlignedAllocation <Vector4>(16L, (uint)sizeof(Vector4));
         *((Vector4 *)boxExtents.AlignedPointer) = new Vector4(width * 0.5f, height * 0.5f, depth * 0.5f, 0f);
         PhysicsShapeHandle result;
         InteropUtils.CallNative(
             NativeMethods.PhysicsManager_CreateBoxShape,
             boxExtents.AlignedPointer,
             shapeOptionsAligned.AlignedPointer,
             (IntPtr)(&result)
             ).ThrowOnFailure();
         shapeOptionsAligned.Dispose();
         boxExtents.Dispose();
         return result;
     }));
 }
Ejemplo n.º 4
0
 public static unsafe PhysicsShapeHandle CreateCompoundCurveShape(IEnumerable <Vector3> vertices, CollisionShapeOptionsDesc shapeOptions)
 {
     return(LosgapSystem.InvokeOnMaster(() => {
         AlignedAllocation <CollisionShapeOptionsDesc> shapeOptionsAligned = new AlignedAllocation <CollisionShapeOptionsDesc>(16L, (uint)sizeof(CollisionShapeOptionsDesc));
         *((CollisionShapeOptionsDesc *)shapeOptionsAligned.AlignedPointer) = shapeOptions;
         Vector3 *verticesLocal = stackalloc Vector3[vertices.Count()];
         int numVertices = 0;
         foreach (Vector3 vertex in vertices)
         {
             verticesLocal[numVertices++] = vertex;
         }
         PhysicsShapeHandle result;
         InteropUtils.CallNative(
             NativeMethods.PhysicsManager_CreateCompoundCurveShape,
             (IntPtr)verticesLocal,
             (uint)numVertices / 8U,
             shapeOptionsAligned.AlignedPointer,
             (IntPtr)(&result)
             ).ThrowOnFailure();
         shapeOptionsAligned.Dispose();
         return result;
     }));
 }