diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs | 90 |
1 files changed, 47 insertions, 43 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs index 5ad6746..662dd68 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs | |||
@@ -33,62 +33,66 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
33 | { | 33 | { |
34 | // Classes to allow some type checking for the API | 34 | // Classes to allow some type checking for the API |
35 | // These hold pointers to allocated objects in the unmanaged space. | 35 | // These hold pointers to allocated objects in the unmanaged space. |
36 | // These classes are subclassed by the various physical implementations of | ||
37 | // objects. In particular, there is a version for physical instances in | ||
38 | // unmanaged memory ("unman") and one for in managed memory ("XNA"). | ||
36 | 39 | ||
37 | // The physics engine controller class created at initialization | 40 | // Currently, the instances of these classes are a reference to a |
38 | public struct BulletWorld | 41 | // physical representation and this has no releationship to other |
42 | // instances. Someday, refarb the usage of these classes so each instance | ||
43 | // refers to a particular physical instance and this class controls reference | ||
44 | // counts and such. This should be done along with adding BSShapes. | ||
45 | |||
46 | public class BulletWorld | ||
39 | { | 47 | { |
40 | public BulletWorld(uint worldId, BSScene bss, IntPtr xx) | 48 | public BulletWorld(uint worldId, BSScene bss) |
41 | { | 49 | { |
42 | ptr = xx; | ||
43 | worldID = worldId; | 50 | worldID = worldId; |
44 | physicsScene = bss; | 51 | physicsScene = bss; |
45 | } | 52 | } |
46 | public IntPtr ptr; | ||
47 | public uint worldID; | 53 | public uint worldID; |
48 | // The scene is only in here so very low level routines have a handle to print debug/error messages | 54 | // The scene is only in here so very low level routines have a handle to print debug/error messages |
49 | public BSScene physicsScene; | 55 | public BSScene physicsScene; |
50 | } | 56 | } |
51 | 57 | ||
52 | // An allocated Bullet btRigidBody | 58 | // An allocated Bullet btRigidBody |
53 | public struct BulletBody | 59 | public class BulletBody |
54 | { | 60 | { |
55 | public BulletBody(uint id) : this(id, IntPtr.Zero) | 61 | public BulletBody(uint id) |
56 | { | ||
57 | } | ||
58 | public BulletBody(uint id, IntPtr xx) | ||
59 | { | 62 | { |
60 | ID = id; | 63 | ID = id; |
61 | ptr = xx; | ||
62 | collisionType = CollisionType.Static; | 64 | collisionType = CollisionType.Static; |
63 | } | 65 | } |
64 | public IntPtr ptr; | ||
65 | public uint ID; | 66 | public uint ID; |
66 | public CollisionType collisionType; | 67 | public CollisionType collisionType; |
67 | 68 | ||
68 | public void Clear() | 69 | public virtual void Clear() { } |
69 | { | 70 | public virtual bool HasPhysicalBody { get { return false; } } |
70 | ptr = IntPtr.Zero; | ||
71 | } | ||
72 | public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } } | ||
73 | 71 | ||
74 | // Apply the specificed collision mask into the physical world | 72 | // Apply the specificed collision mask into the physical world |
75 | public bool ApplyCollisionMask() | 73 | public virtual bool ApplyCollisionMask(BSScene physicsScene) |
76 | { | 74 | { |
77 | // Should assert the body has been added to the physical world. | 75 | // Should assert the body has been added to the physical world. |
78 | // (The collision masks are stored in the collision proxy cache which only exists for | 76 | // (The collision masks are stored in the collision proxy cache which only exists for |
79 | // a collision body that is in the world.) | 77 | // a collision body that is in the world.) |
80 | return BulletSimAPI.SetCollisionGroupMask2(ptr, | 78 | return physicsScene.PE.SetCollisionGroupMask(this, |
81 | BulletSimData.CollisionTypeMasks[collisionType].group, | 79 | BulletSimData.CollisionTypeMasks[collisionType].group, |
82 | BulletSimData.CollisionTypeMasks[collisionType].mask); | 80 | BulletSimData.CollisionTypeMasks[collisionType].mask); |
83 | } | 81 | } |
84 | 82 | ||
83 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
84 | public virtual string AddrString | ||
85 | { | ||
86 | get { return "unknown"; } | ||
87 | } | ||
88 | |||
85 | public override string ToString() | 89 | public override string ToString() |
86 | { | 90 | { |
87 | StringBuilder buff = new StringBuilder(); | 91 | StringBuilder buff = new StringBuilder(); |
88 | buff.Append("<id="); | 92 | buff.Append("<id="); |
89 | buff.Append(ID.ToString()); | 93 | buff.Append(ID.ToString()); |
90 | buff.Append(",p="); | 94 | buff.Append(",p="); |
91 | buff.Append(ptr.ToString("X")); | 95 | buff.Append(AddrString); |
92 | buff.Append(",c="); | 96 | buff.Append(",c="); |
93 | buff.Append(collisionType); | 97 | buff.Append(collisionType); |
94 | buff.Append(">"); | 98 | buff.Append(">"); |
@@ -96,34 +100,36 @@ public struct BulletBody | |||
96 | } | 100 | } |
97 | } | 101 | } |
98 | 102 | ||
99 | public struct BulletShape | 103 | public class BulletShape |
100 | { | 104 | { |
101 | public BulletShape(IntPtr xx) : this(xx, BSPhysicsShapeType.SHAPE_UNKNOWN) | 105 | public BulletShape() |
102 | { | 106 | { |
103 | } | 107 | type = BSPhysicsShapeType.SHAPE_UNKNOWN; |
104 | public BulletShape(IntPtr xx, BSPhysicsShapeType typ) | ||
105 | { | ||
106 | ptr = xx; | ||
107 | type = typ; | ||
108 | shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE; | 108 | shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE; |
109 | isNativeShape = false; | 109 | isNativeShape = false; |
110 | } | 110 | } |
111 | public IntPtr ptr; | ||
112 | public BSPhysicsShapeType type; | 111 | public BSPhysicsShapeType type; |
113 | public System.UInt64 shapeKey; | 112 | public System.UInt64 shapeKey; |
114 | public bool isNativeShape; | 113 | public bool isNativeShape; |
115 | 114 | ||
116 | public void Clear() | 115 | public virtual void Clear() { } |
116 | public virtual bool HasPhysicalShape { get { return false; } } | ||
117 | // Make another reference to this physical object. | ||
118 | public virtual BulletShape Clone() { return new BulletShape(); } | ||
119 | // Return 'true' if this and other refer to the same physical object | ||
120 | public virtual bool ReferenceSame(BulletShape xx) { return false; } | ||
121 | |||
122 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
123 | public virtual string AddrString | ||
117 | { | 124 | { |
118 | ptr = IntPtr.Zero; | 125 | get { return "unknown"; } |
119 | } | 126 | } |
120 | public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } } | ||
121 | 127 | ||
122 | public override string ToString() | 128 | public override string ToString() |
123 | { | 129 | { |
124 | StringBuilder buff = new StringBuilder(); | 130 | StringBuilder buff = new StringBuilder(); |
125 | buff.Append("<p="); | 131 | buff.Append("<p="); |
126 | buff.Append(ptr.ToString("X")); | 132 | buff.Append(AddrString); |
127 | buff.Append(",s="); | 133 | buff.Append(",s="); |
128 | buff.Append(type.ToString()); | 134 | buff.Append(type.ToString()); |
129 | buff.Append(",k="); | 135 | buff.Append(",k="); |
@@ -136,30 +142,29 @@ public struct BulletShape | |||
136 | } | 142 | } |
137 | 143 | ||
138 | // An allocated Bullet btConstraint | 144 | // An allocated Bullet btConstraint |
139 | public struct BulletConstraint | 145 | public class BulletConstraint |
140 | { | 146 | { |
141 | public BulletConstraint(IntPtr xx) | 147 | public BulletConstraint() |
142 | { | 148 | { |
143 | ptr = xx; | ||
144 | } | 149 | } |
145 | public IntPtr ptr; | 150 | public virtual void Clear() { } |
151 | public virtual bool HasPhysicalConstraint { get { return false; } } | ||
146 | 152 | ||
147 | public void Clear() | 153 | // Used for log messages for a unique display of the memory/object allocated to this instance |
154 | public virtual string AddrString | ||
148 | { | 155 | { |
149 | ptr = IntPtr.Zero; | 156 | get { return "unknown"; } |
150 | } | 157 | } |
151 | public bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } } | ||
152 | } | 158 | } |
153 | 159 | ||
154 | // An allocated HeightMapThing which holds various heightmap info. | 160 | // An allocated HeightMapThing which holds various heightmap info. |
155 | // Made a class rather than a struct so there would be only one | 161 | // Made a class rather than a struct so there would be only one |
156 | // instance of this and C# will pass around pointers rather | 162 | // instance of this and C# will pass around pointers rather |
157 | // than making copies. | 163 | // than making copies. |
158 | public class BulletHeightMapInfo | 164 | public class BulletHMapInfo |
159 | { | 165 | { |
160 | public BulletHeightMapInfo(uint id, float[] hm, IntPtr xx) { | 166 | public BulletHMapInfo(uint id, float[] hm) { |
161 | ID = id; | 167 | ID = id; |
162 | Ptr = xx; | ||
163 | heightMap = hm; | 168 | heightMap = hm; |
164 | terrainRegionBase = OMV.Vector3.Zero; | 169 | terrainRegionBase = OMV.Vector3.Zero; |
165 | minCoords = new OMV.Vector3(100f, 100f, 25f); | 170 | minCoords = new OMV.Vector3(100f, 100f, 25f); |
@@ -168,7 +173,6 @@ public class BulletHeightMapInfo | |||
168 | sizeX = sizeY = 256f; | 173 | sizeX = sizeY = 256f; |
169 | } | 174 | } |
170 | public uint ID; | 175 | public uint ID; |
171 | public IntPtr Ptr; | ||
172 | public float[] heightMap; | 176 | public float[] heightMap; |
173 | public OMV.Vector3 terrainRegionBase; | 177 | public OMV.Vector3 terrainRegionBase; |
174 | public OMV.Vector3 minCoords; | 178 | public OMV.Vector3 minCoords; |