Exemple #1
0
        // Creates a native shape and assignes it to prim.BSShape.
        // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape().
        private bool GetReferenceToNativeShape(BSPhysObject prim,
                                               BSPhysicsShapeType shapeType, FixedShapeKey shapeKey,
                                               ShapeDestructionCallback shapeCallback)
        {
            // release any previous shape
            DereferenceShape(prim.PhysShape, true, shapeCallback);

            BulletShape newShape = BuildPhysicalNativeShape(prim, shapeType, shapeKey);

            // Don't need to do a 'ReferenceShape()' here because native shapes are not shared.
            if (DDetail)
            {
                DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}",
                          prim.LocalID, newShape, prim.Scale);
            }

            // native shapes are scaled by Bullet
            prim.PhysShape = newShape;
            return(true);
        }
Exemple #2
0
        private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, BSPhysicsShapeType shapeType,
                                                     FixedShapeKey shapeKey)
        {
            BulletShape newShape;
            // Need to make sure the passed shape information is for the native type.
            ShapeData nativeShapeData = new ShapeData();

            nativeShapeData.Type    = shapeType;
            nativeShapeData.ID      = prim.LocalID;
            nativeShapeData.Scale   = prim.Scale;
            nativeShapeData.Size    = prim.Scale; // unneeded, I think.
            nativeShapeData.MeshKey = (ulong)shapeKey;
            nativeShapeData.HullKey = (ulong)shapeKey;

            if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
            {
                // The proper scale has been calculated in the prim.
                newShape = new BulletShape(
                    BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale)
                    , shapeType);
                if (DDetail)
                {
                    DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
                }
            }
            else
            {
                // Native shapes are scaled in Bullet so set the scaling to the size
                newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType);
            }
            if (!newShape.HasPhysicalShape)
            {
                PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
                                                LogHeader, prim.LocalID, shapeType);
            }
            newShape.shapeKey      = (System.UInt64)shapeKey;
            newShape.isNativeShape = true;

            return(newShape);
        }
Exemple #3
0
 public BulletShapeXNA(CollisionShape xx, BSPhysicsShapeType typ)
     : base()
 {
     shape = xx;
     shapeType = typ;
 }
Exemple #4
0
 public BulletShapeUnman(IntPtr xx, BSPhysicsShapeType typ)
     : base()
 {
     ptr = xx;
     shapeType = typ;
 }
        public static BulletShape CreatePhysicalNativeShape(BSScene physicsScene, BSPhysObject prim,
            BSPhysicsShapeType shapeType, FixedShapeKey shapeKey)
        {
            BulletShape newShape;

            ShapeData nativeShapeData = new ShapeData();
            nativeShapeData.Type = shapeType;
            nativeShapeData.ID = prim.LocalID;
            nativeShapeData.Scale = prim.Scale;
            nativeShapeData.Size = prim.Scale;
            nativeShapeData.MeshKey = (ulong)shapeKey;
            nativeShapeData.HullKey = (ulong)shapeKey;

            if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
            {
                newShape = physicsScene.PE.BuildCapsuleShape(physicsScene.World, 1f, 1f, prim.Scale);
                physicsScene.DetailLog("{0},BSShapeNative,capsule,scale={1}", prim.LocalID, prim.Scale);
            }
            else
            {
                newShape = physicsScene.PE.BuildNativeShape(physicsScene.World, nativeShapeData);
            }
            if (!newShape.HasPhysicalShape)
            {
                physicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
                    LogHeader, prim.LocalID, shapeType);
            }
            newShape.shapeType = shapeType;
            newShape.isNativeShape = true;
            newShape.shapeKey = (UInt64) shapeKey;
            return newShape;
        }
 public static BSShape GetReference(BSScene physicsScene, BSPhysObject prim,
     BSPhysicsShapeType shapeType, FixedShapeKey shapeKey)
 {
     // Native shapes are not shared and are always built anew.
     return new BSShapeNative(CreatePhysicalNativeShape(physicsScene, prim, shapeType, shapeKey));
 }
        // Creates a native shape and assignes it to prim.BSShape.
        // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape().
        private bool GetReferenceToNativeShape(BSPhysObject prim,
            BSPhysicsShapeType shapeType, FixedShapeKey shapeKey,
            ShapeDestructionCallback shapeCallback)
        {
            // release any previous shape
            DereferenceShape(prim.PhysShape, shapeCallback);

            BulletShape newShape = BuildPhysicalNativeShape(prim, shapeType, shapeKey);

            // Don't need to do a 'ReferenceShape()' here because native shapes are not shared.
            if (DDetail) DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}",
                                prim.LocalID, newShape, prim.Scale);

            // native shapes are scaled by Bullet
            prim.PhysShape = newShape;
            return true;
        }
        private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, BSPhysicsShapeType shapeType,
            FixedShapeKey shapeKey)
        {
            BulletShape newShape;
            // Need to make sure the passed shape information is for the native type.
            ShapeData nativeShapeData = new ShapeData();
            nativeShapeData.Type = shapeType;
            nativeShapeData.ID = prim.LocalID;
            nativeShapeData.Scale = prim.Scale;
            nativeShapeData.Size = prim.Scale;  // unneeded, I think.
            nativeShapeData.MeshKey = (ulong)shapeKey;
            nativeShapeData.HullKey = (ulong)shapeKey;

            if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
            {

            newShape = PhysicsScene.PE.BuildCapsuleShape(PhysicsScene.World, 1f, 1f, prim.Scale);
            if (DDetail) DetailLog("{0},BSShapeCollection.BuildPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
            }
            else
            {
            // Native shapes are scaled in Bullet so set the scaling to the size
            newShape = PhysicsScene.PE.BuildNativeShape(PhysicsScene.World, nativeShapeData);

            }
            if (!newShape.HasPhysicalShape)
            {
            PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
                                    LogHeader, prim.LocalID, shapeType);
            }
            newShape.shapeKey = (System.UInt64)shapeKey;
            newShape.isNativeShape = true;

            return newShape;
        }
Exemple #9
0
        private BSShapeNative(BSScene physicsScene, BSPhysObject prim,
            BSPhysicsShapeType shapeType, FixedShapeKey shapeKey)
        {
            ShapeData nativeShapeData = new ShapeData();
            nativeShapeData.Type = shapeType;
            nativeShapeData.ID = prim.LocalID;
            nativeShapeData.Scale = prim.Scale;
            nativeShapeData.Size = prim.Scale;
            nativeShapeData.MeshKey = (ulong)shapeKey;
            nativeShapeData.HullKey = (ulong)shapeKey;

            /*
            if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
            {
            ptr = PhysicsScene.PE.BuildCapsuleShape(physicsScene.World, 1f, 1f, prim.Scale);
            physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
            }
            else
            {
            ptr = PhysicsScene.PE.BuildNativeShape(physicsScene.World, nativeShapeData);
            }
            if (ptr == IntPtr.Zero)
            {
            physicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
                                    LogHeader, prim.LocalID, shapeType);
            }
            type = shapeType;
            key = (UInt64)shapeKey;
             */
        }
 public BulletShape()
 {
     shapeType     = BSPhysicsShapeType.SHAPE_UNKNOWN;
     shapeKey      = (System.UInt64)FixedShapeKey.KEY_NONE;
     isNativeShape = false;
 }
Exemple #11
0
 public static BSShape GetReference(BSScene physicsScene, BSPhysObject prim,
                                    BSPhysicsShapeType shapeType, FixedShapeKey shapeKey)
 {
     // Native shapes are not shared and are always built anew.
     return(new BSShapeNative(physicsScene, prim, shapeType, shapeKey));
 }
 public BulletShape()
 {
     type = BSPhysicsShapeType.SHAPE_UNKNOWN;
     shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE;
     isNativeShape = false;
 }
 public BulletShape(object xx, BSPhysicsShapeType typ)
 {
     ptr = xx;
     type = typ;
     shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE;
     isNativeShape = false;
 }