diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs index 5ad6746..681d21e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
35 | // These hold pointers to allocated objects in the unmanaged space. | 35 | // These hold pointers to allocated objects in the unmanaged space. |
36 | 36 | ||
37 | // The physics engine controller class created at initialization | 37 | // The physics engine controller class created at initialization |
38 | public struct BulletWorld | 38 | public class BulletWorld |
39 | { | 39 | { |
40 | public BulletWorld(uint worldId, BSScene bss, IntPtr xx) | 40 | public BulletWorld(uint worldId, BSScene bss, IntPtr xx) |
41 | { | 41 | { |
@@ -50,7 +50,7 @@ public struct BulletWorld | |||
50 | } | 50 | } |
51 | 51 | ||
52 | // An allocated Bullet btRigidBody | 52 | // An allocated Bullet btRigidBody |
53 | public struct BulletBody | 53 | public class BulletBody |
54 | { | 54 | { |
55 | public BulletBody(uint id) : this(id, IntPtr.Zero) | 55 | public BulletBody(uint id) : this(id, IntPtr.Zero) |
56 | { | 56 | { |
@@ -72,23 +72,32 @@ public struct BulletBody | |||
72 | public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } } | 72 | public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } } |
73 | 73 | ||
74 | // Apply the specificed collision mask into the physical world | 74 | // Apply the specificed collision mask into the physical world |
75 | public bool ApplyCollisionMask() | 75 | public bool ApplyCollisionMask(BSScene physicsScene) |
76 | { | 76 | { |
77 | // Should assert the body has been added to the physical world. | 77 | // 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 | 78 | // (The collision masks are stored in the collision proxy cache which only exists for |
79 | // a collision body that is in the world.) | 79 | // a collision body that is in the world.) |
80 | return BulletSimAPI.SetCollisionGroupMask2(ptr, | 80 | return physicsScene.PE.SetCollisionGroupMask(this, |
81 | BulletSimData.CollisionTypeMasks[collisionType].group, | 81 | BulletSimData.CollisionTypeMasks[collisionType].group, |
82 | BulletSimData.CollisionTypeMasks[collisionType].mask); | 82 | BulletSimData.CollisionTypeMasks[collisionType].mask); |
83 | } | 83 | } |
84 | 84 | ||
85 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
86 | public string AddrString | ||
87 | { | ||
88 | get | ||
89 | { | ||
90 | return ptr.ToString("X"); | ||
91 | } | ||
92 | } | ||
93 | |||
85 | public override string ToString() | 94 | public override string ToString() |
86 | { | 95 | { |
87 | StringBuilder buff = new StringBuilder(); | 96 | StringBuilder buff = new StringBuilder(); |
88 | buff.Append("<id="); | 97 | buff.Append("<id="); |
89 | buff.Append(ID.ToString()); | 98 | buff.Append(ID.ToString()); |
90 | buff.Append(",p="); | 99 | buff.Append(",p="); |
91 | buff.Append(ptr.ToString("X")); | 100 | buff.Append(AddrString); |
92 | buff.Append(",c="); | 101 | buff.Append(",c="); |
93 | buff.Append(collisionType); | 102 | buff.Append(collisionType); |
94 | buff.Append(">"); | 103 | buff.Append(">"); |
@@ -96,9 +105,14 @@ public struct BulletBody | |||
96 | } | 105 | } |
97 | } | 106 | } |
98 | 107 | ||
99 | public struct BulletShape | 108 | public class BulletShape |
100 | { | 109 | { |
101 | public BulletShape(IntPtr xx) : this(xx, BSPhysicsShapeType.SHAPE_UNKNOWN) | 110 | public BulletShape() |
111 | : this(IntPtr.Zero, BSPhysicsShapeType.SHAPE_UNKNOWN) | ||
112 | { | ||
113 | } | ||
114 | public BulletShape(IntPtr xx) | ||
115 | : this(xx, BSPhysicsShapeType.SHAPE_UNKNOWN) | ||
102 | { | 116 | { |
103 | } | 117 | } |
104 | public BulletShape(IntPtr xx, BSPhysicsShapeType typ) | 118 | public BulletShape(IntPtr xx, BSPhysicsShapeType typ) |
@@ -119,11 +133,20 @@ public struct BulletShape | |||
119 | } | 133 | } |
120 | public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } } | 134 | public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } } |
121 | 135 | ||
136 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
137 | public string AddrString | ||
138 | { | ||
139 | get | ||
140 | { | ||
141 | return ptr.ToString("X"); | ||
142 | } | ||
143 | } | ||
144 | |||
122 | public override string ToString() | 145 | public override string ToString() |
123 | { | 146 | { |
124 | StringBuilder buff = new StringBuilder(); | 147 | StringBuilder buff = new StringBuilder(); |
125 | buff.Append("<p="); | 148 | buff.Append("<p="); |
126 | buff.Append(ptr.ToString("X")); | 149 | buff.Append(AddrString); |
127 | buff.Append(",s="); | 150 | buff.Append(",s="); |
128 | buff.Append(type.ToString()); | 151 | buff.Append(type.ToString()); |
129 | buff.Append(",k="); | 152 | buff.Append(",k="); |
@@ -136,7 +159,7 @@ public struct BulletShape | |||
136 | } | 159 | } |
137 | 160 | ||
138 | // An allocated Bullet btConstraint | 161 | // An allocated Bullet btConstraint |
139 | public struct BulletConstraint | 162 | public class BulletConstraint |
140 | { | 163 | { |
141 | public BulletConstraint(IntPtr xx) | 164 | public BulletConstraint(IntPtr xx) |
142 | { | 165 | { |
@@ -149,17 +172,25 @@ public struct BulletConstraint | |||
149 | ptr = IntPtr.Zero; | 172 | ptr = IntPtr.Zero; |
150 | } | 173 | } |
151 | public bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } } | 174 | public bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } } |
175 | |||
176 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
177 | public string AddrString | ||
178 | { | ||
179 | get | ||
180 | { | ||
181 | return ptr.ToString("X"); | ||
182 | } | ||
183 | } | ||
152 | } | 184 | } |
153 | 185 | ||
154 | // An allocated HeightMapThing which holds various heightmap info. | 186 | // An allocated HeightMapThing which holds various heightmap info. |
155 | // Made a class rather than a struct so there would be only one | 187 | // Made a class rather than a struct so there would be only one |
156 | // instance of this and C# will pass around pointers rather | 188 | // instance of this and C# will pass around pointers rather |
157 | // than making copies. | 189 | // than making copies. |
158 | public class BulletHeightMapInfo | 190 | public class BulletHMapInfo |
159 | { | 191 | { |
160 | public BulletHeightMapInfo(uint id, float[] hm, IntPtr xx) { | 192 | public BulletHMapInfo(uint id, float[] hm) { |
161 | ID = id; | 193 | ID = id; |
162 | Ptr = xx; | ||
163 | heightMap = hm; | 194 | heightMap = hm; |
164 | terrainRegionBase = OMV.Vector3.Zero; | 195 | terrainRegionBase = OMV.Vector3.Zero; |
165 | minCoords = new OMV.Vector3(100f, 100f, 25f); | 196 | minCoords = new OMV.Vector3(100f, 100f, 25f); |
@@ -168,7 +199,6 @@ public class BulletHeightMapInfo | |||
168 | sizeX = sizeY = 256f; | 199 | sizeX = sizeY = 256f; |
169 | } | 200 | } |
170 | public uint ID; | 201 | public uint ID; |
171 | public IntPtr Ptr; | ||
172 | public float[] heightMap; | 202 | public float[] heightMap; |
173 | public OMV.Vector3 terrainRegionBase; | 203 | public OMV.Vector3 terrainRegionBase; |
174 | public OMV.Vector3 minCoords; | 204 | public OMV.Vector3 minCoords; |