BulletSim: uplevel FixedShapeKey out of ShapeData structure (since it is getting simplified out of existance someday) and update all the references to same.

connector_plugin
Robert Adams 2012-11-20 11:30:22 -08:00
parent d6db0d5740
commit 65e55ada87
3 changed files with 22 additions and 20 deletions

View File

@ -409,7 +409,7 @@ public sealed class BSShapeCollection : IDisposable
{
// an avatar capsule is close to a native shape (it is not shared)
ret = GetReferenceToNativeShape(prim, PhysicsShapeType.SHAPE_AVATAR,
ShapeData.FixedShapeKey.KEY_CAPSULE, shapeCallback);
FixedShapeKey.KEY_CAPSULE, shapeCallback);
DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape);
ret = true;
haveShape = true;
@ -464,7 +464,7 @@ public sealed class BSShapeCollection : IDisposable
)
{
ret = GetReferenceToNativeShape(prim, PhysicsShapeType.SHAPE_SPHERE,
ShapeData.FixedShapeKey.KEY_SPHERE, shapeCallback);
FixedShapeKey.KEY_SPHERE, shapeCallback);
DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}",
prim.LocalID, forceRebuild, prim.PhysShape);
}
@ -478,7 +478,7 @@ public sealed class BSShapeCollection : IDisposable
)
{
ret = GetReferenceToNativeShape( prim, PhysicsShapeType.SHAPE_BOX,
ShapeData.FixedShapeKey.KEY_BOX, shapeCallback);
FixedShapeKey.KEY_BOX, shapeCallback);
DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}",
prim.LocalID, forceRebuild, prim.PhysShape);
}
@ -519,7 +519,7 @@ public sealed class BSShapeCollection : IDisposable
// 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,
PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey,
PhysicsShapeType shapeType, FixedShapeKey shapeKey,
ShapeDestructionCallback shapeCallback)
{
// release any previous shape
@ -539,7 +539,7 @@ public sealed class BSShapeCollection : IDisposable
}
private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, PhysicsShapeType shapeType,
ShapeData.FixedShapeKey shapeKey)
FixedShapeKey shapeKey)
{
BulletShape newShape;
// Need to make sure the passed shape information is for the native type.
@ -894,7 +894,7 @@ public sealed class BSShapeCollection : IDisposable
// While we figure out the real problem, stick a simple native shape on the object.
BulletShape fillinShape =
BuildPhysicalNativeShape(prim, PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX);
BuildPhysicalNativeShape(prim, PhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX);
return fillinShape;
}

View File

@ -58,7 +58,7 @@ public abstract class BSShape
{
// an avatar capsule is close to a native shape (it is not shared)
ret = BSShapeNative.GetReference(physicsScene, prim, PhysicsShapeType.SHAPE_AVATAR,
ShapeData.FixedShapeKey.KEY_CAPSULE);
FixedShapeKey.KEY_CAPSULE);
physicsScene.DetailLog("{0},BSShape.GetShapeReference,avatarCapsule,shape={1}", prim.LocalID, ret);
}
@ -123,14 +123,14 @@ public class BSShapeNative : BSShape
{
}
public static BSShape GetReference(BSScene physicsScene, BSPhysObject prim,
PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey)
PhysicsShapeType shapeType, FixedShapeKey shapeKey)
{
// Native shapes are not shared and are always built anew.
return new BSShapeNative(physicsScene, prim, shapeType, shapeKey);
}
private BSShapeNative(BSScene physicsScene, BSPhysObject prim,
PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey)
PhysicsShapeType shapeType, FixedShapeKey shapeKey)
{
ShapeData nativeShapeData = new ShapeData();
nativeShapeData.Type = shapeType;

View File

@ -89,7 +89,7 @@ public struct BulletShape
{
ptr = xx;
type=PhysicsShapeType.SHAPE_UNKNOWN;
shapeKey = 0;
shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE;
isNativeShape = false;
}
public BulletShape(IntPtr xx, PhysicsShapeType typ)
@ -194,6 +194,18 @@ public enum PhysicsShapeType
SHAPE_COMPOUND = 22,
SHAPE_HEIGHTMAP = 23,
};
// The native shapes have predefined shape hash keys
public enum FixedShapeKey : ulong
{
KEY_NONE = 0,
KEY_BOX = 1,
KEY_SPHERE = 2,
KEY_CONE = 3,
KEY_CYLINDER = 4,
KEY_CAPSULE = 5,
}
[StructLayout(LayoutKind.Sequential)]
public struct ShapeData
{
@ -217,16 +229,6 @@ public struct ShapeData
// note that bools are passed as floats since bool size changes by language and architecture
public const float numericTrue = 1f;
public const float numericFalse = 0f;
// The native shapes have predefined shape hash keys
public enum FixedShapeKey : ulong
{
KEY_BOX = 1,
KEY_SPHERE = 2,
KEY_CONE = 3,
KEY_CYLINDER = 4,
KEY_CAPSULE = 5,
}
}
[StructLayout(LayoutKind.Sequential)]
public struct SweepHit