예제 #1
0
        // Creates a native shape and assignes it to prim.BSShape
        private bool GetReferenceToNativeShape(BSPrim prim, ShapeData shapeData,
                                               ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey,
                                               ShapeDestructionCallback shapeCallback)
        {
            BulletShape newShape;

            shapeData.Type = shapeType;
            // Bullet native objects are scaled by the Bullet engine so pass the size in
            prim.Scale      = shapeData.Size;
            shapeData.Scale = shapeData.Size;

            // release any previous shape
            DereferenceShape(prim.BSShape, true, shapeCallback);

            // Native shapes are always built independently.
            newShape               = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, shapeData), shapeType);
            newShape.shapeKey      = (ulong)shapeKey;
            newShape.isNativeShape = true;

            // Don't need to do a 'ReferenceShape()' here because native shapes are not tracked.
            // DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1}", shapeData.ID, newShape);

            prim.BSShape = newShape;
            return(true);
        }