aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs)1257
1 files changed, 763 insertions, 494 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
index b361498..3975776 100644..100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
@@ -26,664 +26,954 @@
26 */ 26 */
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection;
29using System.Runtime.InteropServices; 30using System.Runtime.InteropServices;
30using System.Security; 31using System.Security;
31using System.Text; 32using System.Text;
33
32using OpenMetaverse; 34using OpenMetaverse;
33 35
34namespace OpenSim.Region.Physics.BulletSPlugin { 36namespace OpenSim.Region.Physics.BulletSPlugin
37{
38public sealed class BSAPIUnman : BSAPITemplate
39{
40
41// We pin the memory passed between the managed and unmanaged code.
42GCHandle m_paramsHandle;
43private GCHandle m_collisionArrayPinnedHandle;
44private GCHandle m_updateArrayPinnedHandle;
45
46// Handle to the callback used by the unmanaged code to call into the managed code.
47// Used for debug logging.
48// Need to store the handle in a persistant variable so it won't be freed.
49private BSAPICPP.DebugLogCallback m_DebugLogCallbackHandle;
50
51private BSScene PhysicsScene { get; set; }
52
53public override string BulletEngineName { get { return "BulletUnmanaged"; } }
54public override string BulletEngineVersion { get; protected set; }
35 55
36 // Constraint type values as defined by Bullet 56public BSAPIUnman(string paramName, BSScene physScene)
37public enum ConstraintType : int
38{ 57{
39 POINT2POINT_CONSTRAINT_TYPE = 3, 58 PhysicsScene = physScene;
40 HINGE_CONSTRAINT_TYPE, 59 // Do something fancy with the paramName to get the right DLL implementation
41 CONETWIST_CONSTRAINT_TYPE, 60 // like "Bullet-2.80-OpenCL-Intel" loading the version for Intel based OpenCL implementation, etc.
42 D6_CONSTRAINT_TYPE,
43 SLIDER_CONSTRAINT_TYPE,
44 CONTACT_CONSTRAINT_TYPE,
45 D6_SPRING_CONSTRAINT_TYPE,
46 MAX_CONSTRAINT_TYPE
47} 61}
48 62
49// ===============================================================================
50[StructLayout(LayoutKind.Sequential)]
51public struct ConvexHull
52{
53 Vector3 Offset;
54 int VertexCount;
55 Vector3[] Vertices;
56}
57public enum BSPhysicsShapeType
58{
59 SHAPE_UNKNOWN = 0,
60 SHAPE_CAPSULE = 1,
61 SHAPE_BOX = 2,
62 SHAPE_CONE = 3,
63 SHAPE_CYLINDER = 4,
64 SHAPE_SPHERE = 5,
65 SHAPE_MESH = 6,
66 SHAPE_HULL = 7,
67 // following defined by BulletSim
68 SHAPE_GROUNDPLANE = 20,
69 SHAPE_TERRAIN = 21,
70 SHAPE_COMPOUND = 22,
71 SHAPE_HEIGHTMAP = 23,
72 SHAPE_AVATAR = 24,
73};
74
75// The native shapes have predefined shape hash keys
76public enum FixedShapeKey : ulong
77{
78 KEY_NONE = 0,
79 KEY_BOX = 1,
80 KEY_SPHERE = 2,
81 KEY_CONE = 3,
82 KEY_CYLINDER = 4,
83 KEY_CAPSULE = 5,
84 KEY_AVATAR = 6,
85}
86
87[StructLayout(LayoutKind.Sequential)]
88public struct ShapeData
89{
90 public uint ID;
91 public BSPhysicsShapeType Type;
92 public Vector3 Position;
93 public Quaternion Rotation;
94 public Vector3 Velocity;
95 public Vector3 Scale;
96 public float Mass;
97 public float Buoyancy;
98 public System.UInt64 HullKey;
99 public System.UInt64 MeshKey;
100 public float Friction;
101 public float Restitution;
102 public float Collidable; // true of things bump into this
103 public float Static; // true if a static object. Otherwise gravity, etc.
104 public float Solid; // true if object cannot be passed through
105 public Vector3 Size;
106
107 // note that bools are passed as floats since bool size changes by language and architecture
108 public const float numericTrue = 1f;
109 public const float numericFalse = 0f;
110}
111[StructLayout(LayoutKind.Sequential)]
112public struct SweepHit
113{
114 public uint ID;
115 public float Fraction;
116 public Vector3 Normal;
117 public Vector3 Point;
118}
119[StructLayout(LayoutKind.Sequential)]
120public struct RaycastHit
121{
122 public uint ID;
123 public float Fraction;
124 public Vector3 Normal;
125}
126[StructLayout(LayoutKind.Sequential)]
127public struct CollisionDesc
128{
129 public uint aID;
130 public uint bID;
131 public Vector3 point;
132 public Vector3 normal;
133}
134[StructLayout(LayoutKind.Sequential)]
135public struct EntityProperties
136{
137 public uint ID;
138 public Vector3 Position;
139 public Quaternion Rotation;
140 public Vector3 Velocity;
141 public Vector3 Acceleration;
142 public Vector3 RotationalVelocity;
143}
144
145// Format of this structure must match the definition in the C++ code
146// NOTE: adding the X causes compile breaks if used. These are unused symbols
147// that can be removed from both here and the unmanaged definition of this structure.
148[StructLayout(LayoutKind.Sequential)]
149public struct ConfigurationParameters
150{
151 public float defaultFriction;
152 public float defaultDensity;
153 public float defaultRestitution;
154 public float collisionMargin;
155 public float gravity;
156
157 public float XlinearDamping;
158 public float XangularDamping;
159 public float XdeactivationTime;
160 public float XlinearSleepingThreshold;
161 public float XangularSleepingThreshold;
162 public float XccdMotionThreshold;
163 public float XccdSweptSphereRadius;
164 public float XcontactProcessingThreshold;
165
166 public float XterrainImplementation;
167 public float XterrainFriction;
168 public float XterrainHitFraction;
169 public float XterrainRestitution;
170 public float XterrainCollisionMargin;
171
172 public float XavatarFriction;
173 public float XavatarStandingFriction;
174 public float XavatarDensity;
175 public float XavatarRestitution;
176 public float XavatarCapsuleWidth;
177 public float XavatarCapsuleDepth;
178 public float XavatarCapsuleHeight;
179 public float XavatarContactProcessingThreshold;
180
181 public float XvehicleAngularDamping;
182
183 public float maxPersistantManifoldPoolSize;
184 public float maxCollisionAlgorithmPoolSize;
185 public float shouldDisableContactPoolDynamicAllocation;
186 public float shouldForceUpdateAllAabbs;
187 public float shouldRandomizeSolverOrder;
188 public float shouldSplitSimulationIslands;
189 public float shouldEnableFrictionCaching;
190 public float numberOfSolverIterations;
191
192 public float XlinksetImplementation;
193 public float XlinkConstraintUseFrameOffset;
194 public float XlinkConstraintEnableTransMotor;
195 public float XlinkConstraintTransMotorMaxVel;
196 public float XlinkConstraintTransMotorMaxForce;
197 public float XlinkConstraintERP;
198 public float XlinkConstraintCFM;
199 public float XlinkConstraintSolverIterations;
200
201 public float physicsLoggingFrames;
202
203 public const float numericTrue = 1f;
204 public const float numericFalse = 0f;
205}
206
207
208// The states a bullet collision object can have
209public enum ActivationState : uint
210{
211 ACTIVE_TAG = 1,
212 ISLAND_SLEEPING,
213 WANTS_DEACTIVATION,
214 DISABLE_DEACTIVATION,
215 DISABLE_SIMULATION,
216}
217
218public enum CollisionObjectTypes : int
219{
220 CO_COLLISION_OBJECT = 1 << 0,
221 CO_RIGID_BODY = 1 << 1,
222 CO_GHOST_OBJECT = 1 << 2,
223 CO_SOFT_BODY = 1 << 3,
224 CO_HF_FLUID = 1 << 4,
225 CO_USER_TYPE = 1 << 5,
226}
227
228// Values used by Bullet and BulletSim to control object properties.
229// Bullet's "CollisionFlags" has more to do with operations on the
230// object (if collisions happen, if gravity effects it, ...).
231public enum CollisionFlags : uint
232{
233 CF_STATIC_OBJECT = 1 << 0,
234 CF_KINEMATIC_OBJECT = 1 << 1,
235 CF_NO_CONTACT_RESPONSE = 1 << 2,
236 CF_CUSTOM_MATERIAL_CALLBACK = 1 << 3,
237 CF_CHARACTER_OBJECT = 1 << 4,
238 CF_DISABLE_VISUALIZE_OBJECT = 1 << 5,
239 CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6,
240 // Following used by BulletSim to control collisions and updates
241 BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10,
242 BS_FLOATS_ON_WATER = 1 << 11,
243 BS_VEHICLE_COLLISIONS = 1 << 12,
244 BS_NONE = 0,
245 BS_ALL = 0xFFFFFFFF
246};
247
248// Values f collisions groups and masks
249public enum CollisionFilterGroups : uint
250{
251 // Don't use the bit definitions!! Define the use in a
252 // filter/mask definition below. This way collision interactions
253 // are more easily found and debugged.
254 BNoneGroup = 0,
255 BDefaultGroup = 1 << 0, // 0001
256 BStaticGroup = 1 << 1, // 0002
257 BKinematicGroup = 1 << 2, // 0004
258 BDebrisGroup = 1 << 3, // 0008
259 BSensorTrigger = 1 << 4, // 0010
260 BCharacterGroup = 1 << 5, // 0020
261 BAllGroup = 0x000FFFFF,
262 // Filter groups defined by BulletSim
263 BGroundPlaneGroup = 1 << 10, // 0400
264 BTerrainGroup = 1 << 11, // 0800
265 BRaycastGroup = 1 << 12, // 1000
266 BSolidGroup = 1 << 13, // 2000
267 // BLinksetGroup = xx // a linkset proper is either static or dynamic
268 BLinksetChildGroup = 1 << 14, // 4000
269};
270
271// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0
272// ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2.
273public enum ConstraintParams : int
274{
275 BT_CONSTRAINT_ERP = 1, // this one is not used in Bullet as of 20120730
276 BT_CONSTRAINT_STOP_ERP,
277 BT_CONSTRAINT_CFM,
278 BT_CONSTRAINT_STOP_CFM,
279};
280public enum ConstraintParamAxis : int
281{
282 AXIS_LINEAR_X = 0,
283 AXIS_LINEAR_Y,
284 AXIS_LINEAR_Z,
285 AXIS_ANGULAR_X,
286 AXIS_ANGULAR_Y,
287 AXIS_ANGULAR_Z,
288 AXIS_LINEAR_ALL = 20, // these last three added by BulletSim so we don't have to do zillions of calls
289 AXIS_ANGULAR_ALL,
290 AXIS_ALL
291};
292
293public abstract class BulletSimAPITemplate
294{
295// Initialization and simulation 63// Initialization and simulation
296public abstract BulletWorld Initialize2(Vector3 maxPosition, IntPtr parms, 64public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms,
297 int maxCollisions, IntPtr collisionArray, 65 int maxCollisions, ref CollisionDesc[] collisionArray,
298 int maxUpdates, IntPtr updateArray 66 int maxUpdates, ref EntityProperties[] updateArray
299 ); 67 )
68{
69 // Pin down the memory that will be used to pass object collisions and updates back from unmanaged code
70 m_paramsHandle = GCHandle.Alloc(parms, GCHandleType.Pinned);
71 m_collisionArrayPinnedHandle = GCHandle.Alloc(collisionArray, GCHandleType.Pinned);
72 m_updateArrayPinnedHandle = GCHandle.Alloc(updateArray, GCHandleType.Pinned);
73
74 // If Debug logging level, enable logging from the unmanaged code
75 m_DebugLogCallbackHandle = null;
76 if (BSScene.m_log.IsDebugEnabled || PhysicsScene.PhysicsLogging.Enabled)
77 {
78 BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader);
79 if (PhysicsScene.PhysicsLogging.Enabled)
80 // The handle is saved in a variable to make sure it doesn't get freed after this call
81 m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLoggerPhysLog);
82 else
83 m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLogger);
84 }
85
86 // Get the version of the DLL
87 // TODO: this doesn't work yet. Something wrong with marshaling the returned string.
88 // BulletEngineVersion = BulletSimAPI.GetVersion2();
89 BulletEngineVersion = "";
90
91 // Call the unmanaged code with the buffers and other information
92 return new BulletWorld(0, PhysicsScene, BSAPICPP.Initialize2(maxPosition, m_paramsHandle.AddrOfPinnedObject(),
93 maxCollisions, m_collisionArrayPinnedHandle.AddrOfPinnedObject(),
94 maxUpdates, m_updateArrayPinnedHandle.AddrOfPinnedObject(),
95 m_DebugLogCallbackHandle));
300 96
301public abstract bool UpdateParameter2(BulletWorld world, uint localID, String parm, float value); 97}
302 98
303public abstract void SetHeightMap2(BulletWorld world, float[] heightmap); 99// Called directly from unmanaged code so don't do much
100private void BulletLogger(string msg)
101{
102 BSScene.m_log.Debug("[BULLETS UNMANAGED]:" + msg);
103}
304 104
305public abstract void Shutdown2(BulletWorld sim); 105// Called directly from unmanaged code so don't do much
106private void BulletLoggerPhysLog(string msg)
107{
108 PhysicsScene.DetailLog("[BULLETS UNMANAGED]:" + msg);
109}
306 110
307public abstract int PhysicsStep2(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, 111public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
308 out int updatedEntityCount, 112 out int updatedEntityCount, out int collidersCount)
309 out IntPtr updatedEntitiesPtr, 113{
310 out int collidersCount, 114 return BSAPICPP.PhysicsStep2(world.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount);
311 out IntPtr collidersPtr); 115}
312 116
313public abstract bool PushUpdate2(BulletBody obj); 117public override void Shutdown(BulletWorld sim)
118{
119 BSAPICPP.Shutdown2(sim.ptr);
120}
314 121
315// ===================================================================================== 122public override bool PushUpdate(BulletBody obj)
316// Mesh, hull, shape and body creation helper routines 123{
317public abstract BulletShape CreateMeshShape2(BulletWorld world, 124 return BSAPICPP.PushUpdate2(obj.ptr);
318 int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices, 125}
319 int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices );
320 126
321public abstract BulletShape CreateHullShape2(BulletWorld world, 127public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value)
322 int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls); 128{
129 return BSAPICPP.UpdateParameter2(world.ptr, localID, parm, value);
130}
323 131
324public abstract BulletShape BuildHullShapeFromMesh2(BulletWorld world, BulletShape meshShape); 132// =====================================================================================
133// Mesh, hull, shape and body creation helper routines
134public override BulletShape CreateMeshShape(BulletWorld world,
135 int indicesCount, int[] indices,
136 int verticesCount, float[] vertices)
137{
138 return new BulletShape(
139 BSAPICPP.CreateMeshShape2(world.ptr, indicesCount, indices, verticesCount, vertices),
140 BSPhysicsShapeType.SHAPE_MESH);
141}
325 142
326public abstract BulletShape BuildNativeShape2(BulletWorld world, ShapeData shapeData); 143public override BulletShape CreateHullShape(BulletWorld world, int hullCount, float[] hulls)
144{
145 return new BulletShape(
146 BSAPICPP.CreateHullShape2(world.ptr, hullCount, hulls),
147 BSPhysicsShapeType.SHAPE_HULL);
148}
327 149
328public abstract bool IsNativeShape2(BulletShape shape); 150public override BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape)
151{
152 return new BulletShape(
153 BSAPICPP.BuildHullShapeFromMesh2(world.ptr, meshShape.ptr),
154 BSPhysicsShapeType.SHAPE_HULL);
155}
329 156
330public abstract void SetShapeCollisionMargin(BulletShape shape, float margin); 157public override BulletShape BuildNativeShape( BulletWorld world, ShapeData shapeData)
158{
159 return new BulletShape(
160 BSAPICPP.BuildNativeShape2(world.ptr, shapeData),
161 shapeData.Type);
162}
331 163
332public abstract BulletShape BuildCapsuleShape2(BulletWorld world, float radius, float height, Vector3 scale); 164public override bool IsNativeShape(BulletShape shape)
165{
166 if (shape.HasPhysicalShape)
167 return BSAPICPP.IsNativeShape2(shape.ptr);
168 return false;
169}
333 170
334public abstract BulletShape CreateCompoundShape2(BulletWorld sim, bool enableDynamicAabbTree); 171public override void SetShapeCollisionMargin(BulletShape shape, float margin)
172{
173 if (shape.HasPhysicalShape)
174 BSAPICPP.SetShapeCollisionMargin2(shape.ptr, margin);
175}
335 176
336public abstract int GetNumberOfCompoundChildren2(BulletShape cShape); 177public override BulletShape BuildCapsuleShape(BulletWorld world, float radius, float height, Vector3 scale)
178{
179 return new BulletShape(
180 BSAPICPP.BuildCapsuleShape2(world.ptr, radius, height, scale),
181 BSPhysicsShapeType.SHAPE_CAPSULE);
182}
337 183
338public abstract void AddChildShapeToCompoundShape2(BulletShape cShape, BulletShape addShape, Vector3 pos, Quaternion rot); 184public override BulletShape CreateCompoundShape(BulletWorld sim, bool enableDynamicAabbTree)
185{
186 return new BulletShape(
187 BSAPICPP.CreateCompoundShape2(sim.ptr, enableDynamicAabbTree),
188 BSPhysicsShapeType.SHAPE_COMPOUND);
339 189
340public abstract BulletShape GetChildShapeFromCompoundShapeIndex2(BulletShape cShape, int indx); 190}
341 191
342public abstract BulletShape RemoveChildShapeFromCompoundShapeIndex2(BulletShape cShape, int indx); 192public override int GetNumberOfCompoundChildren(BulletShape shape)
193{
194 if (shape.HasPhysicalShape)
195 return BSAPICPP.GetNumberOfCompoundChildren2(shape.ptr);
196 return 0;
197}
343 198
344public abstract void RemoveChildShapeFromCompoundShape2(BulletShape cShape, BulletShape removeShape); 199public override void AddChildShapeToCompoundShape(BulletShape cShape, BulletShape addShape, Vector3 pos, Quaternion rot)
200{
201 BSAPICPP.AddChildShapeToCompoundShape2(cShape.ptr, addShape.ptr, pos, rot);
202}
345 203
346public abstract void RecalculateCompoundShapeLocalAabb2(BulletShape cShape); 204public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx)
205{
206 return new BulletShape(BSAPICPP.GetChildShapeFromCompoundShapeIndex2(cShape.ptr, indx));
207}
347 208
348public abstract BulletShape DuplicateCollisionShape2(BulletWorld sim, BulletShape srcShape, uint id); 209public override BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx)
210{
211 return new BulletShape(BSAPICPP.RemoveChildShapeFromCompoundShapeIndex2(cShape.ptr, indx));
212}
349 213
350public abstract BulletBody CreateBodyFromShapeAndInfo2(BulletWorld sim, BulletShape shape, uint id, IntPtr constructionInfo); 214public override void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape)
215{
216 BSAPICPP.RemoveChildShapeFromCompoundShape2(cShape.ptr, removeShape.ptr);
217}
351 218
352public abstract bool DeleteCollisionShape2(BulletWorld world, BulletShape shape); 219public override void RecalculateCompoundShapeLocalAabb(BulletShape cShape)
220{
221 BSAPICPP.RecalculateCompoundShapeLocalAabb2(cShape.ptr);
222}
353 223
354public abstract int GetBodyType2(BulletBody obj); 224public override BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id)
225{
226 return new BulletShape(BSAPICPP.DuplicateCollisionShape2(sim.ptr, srcShape.ptr, id), srcShape.type);
227}
355 228
356public abstract BulletBody CreateBodyFromShape2(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); 229public override bool DeleteCollisionShape(BulletWorld world, BulletShape shape)
230{
231 return BSAPICPP.DeleteCollisionShape2(world.ptr, shape.ptr);
232}
357 233
358public abstract BulletBody CreateBodyWithDefaultMotionState2(BulletShape shape, uint id, Vector3 pos, Quaternion rot); 234public override int GetBodyType(BulletBody obj)
235{
236 return BSAPICPP.GetBodyType2(obj.ptr);
237}
359 238
360public abstract BulletBody CreateGhostFromShape2(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); 239public override BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot)
240{
241 return new BulletBody(id, BSAPICPP.CreateBodyFromShape2(sim.ptr, shape.ptr, id, pos, rot));
242}
361 243
362public abstract IntPtr AllocateBodyInfo2(BulletBody obj); 244public override BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, uint id, Vector3 pos, Quaternion rot)
245{
246 return new BulletBody(id, BSAPICPP.CreateBodyWithDefaultMotionState2(shape.ptr, id, pos, rot));
247}
363 248
364public abstract void ReleaseBodyInfo2(IntPtr obj); 249public override BulletBody CreateGhostFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot)
250{
251 return new BulletBody(id, BSAPICPP.CreateGhostFromShape2(sim.ptr, shape.ptr, id, pos, rot));
252}
365 253
366public abstract void DestroyObject2(BulletWorld sim, BulletBody obj); 254public override void DestroyObject(BulletWorld sim, BulletBody obj)
255{
256 BSAPICPP.DestroyObject2(sim.ptr, obj.ptr);
257}
367 258
368// ===================================================================================== 259// =====================================================================================
369// Terrain creation and helper routines 260// Terrain creation and helper routines
370public abstract IntPtr CreateHeightMapInfo2(BulletWorld sim, uint id, Vector3 minCoords, Vector3 maxCoords, 261public override BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin)
371 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin); 262{
372 263 return new BulletShape(BSAPICPP.CreateGroundPlaneShape2(id, height, collisionMargin), BSPhysicsShapeType.SHAPE_GROUNDPLANE);
373public abstract IntPtr FillHeightMapInfo2(BulletWorld sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords, 264}
374 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
375
376public abstract bool ReleaseHeightMapInfo2(IntPtr heightMapInfo);
377
378public abstract BulletBody CreateGroundPlaneShape2(uint id, float height, float collisionMargin);
379 265
380public abstract BulletBody CreateTerrainShape2(IntPtr mapInfo); 266public override BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap,
267 float scaleFactor, float collisionMargin)
268{
269 return new BulletShape(BSAPICPP.CreateTerrainShape2(id, size, minHeight, maxHeight, heightMap, scaleFactor, collisionMargin),
270 BSPhysicsShapeType.SHAPE_TERRAIN);
271}
381 272
382// ===================================================================================== 273// =====================================================================================
383// Constraint creation and helper routines 274// Constraint creation and helper routines
384public abstract BulletConstraint Create6DofConstraint2(BulletWorld world, BulletBody obj1, BulletBody obj2, 275public override BulletConstraint Create6DofConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
385 Vector3 frame1loc, Quaternion frame1rot, 276 Vector3 frame1loc, Quaternion frame1rot,
386 Vector3 frame2loc, Quaternion frame2rot, 277 Vector3 frame2loc, Quaternion frame2rot,
387 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); 278 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
279{
280 return new BulletConstraint(BSAPICPP.Create6DofConstraint2(world.ptr, obj1.ptr, obj2.ptr, frame1loc, frame1rot,
281 frame2loc, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
282}
388 283
389public abstract BulletConstraint Create6DofConstraintToPoint2(BulletWorld world, BulletBody obj1, BulletBody obj2, 284public override BulletConstraint Create6DofConstraintToPoint(BulletWorld world, BulletBody obj1, BulletBody obj2,
390 Vector3 joinPoint, 285 Vector3 joinPoint,
391 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); 286 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
287{
288 return new BulletConstraint(BSAPICPP.Create6DofConstraintToPoint2(world.ptr, obj1.ptr, obj2.ptr,
289 joinPoint, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
290}
392 291
393public abstract BulletConstraint CreateHingeConstraint2(BulletWorld world, BulletBody obj1, BulletBody obj2, 292public override BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
394 Vector3 pivotinA, Vector3 pivotinB, 293 Vector3 pivotinA, Vector3 pivotinB,
395 Vector3 axisInA, Vector3 axisInB, 294 Vector3 axisInA, Vector3 axisInB,
396 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); 295 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
296{
297 return new BulletConstraint(BSAPICPP.CreateHingeConstraint2(world.ptr, obj1.ptr, obj2.ptr,
298 pivotinA, pivotinB, axisInA, axisInB, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
299}
397 300
398public abstract void SetConstraintEnable2(BulletConstraint constrain, float numericTrueFalse); 301public override void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse)
302{
303 BSAPICPP.SetConstraintEnable2(constrain.ptr, numericTrueFalse);
304}
399 305
400public abstract void SetConstraintNumSolverIterations2(BulletConstraint constrain, float iterations); 306public override void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations)
307{
308 BSAPICPP.SetConstraintNumSolverIterations2(constrain.ptr, iterations);
309}
401 310
402public abstract bool SetFrames2(BulletConstraint constrain, 311public override bool SetFrames(BulletConstraint constrain,
403 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot); 312 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot)
313{
314 return BSAPICPP.SetFrames2(constrain.ptr, frameA, frameArot, frameB, frameBrot);
315}
404 316
405public abstract bool SetLinearLimits2(BulletConstraint constrain, Vector3 low, Vector3 hi); 317public override bool SetLinearLimits(BulletConstraint constrain, Vector3 low, Vector3 hi)
318{
319 return BSAPICPP.SetLinearLimits2(constrain.ptr, low, hi);
320}
406 321
407public abstract bool SetAngularLimits2(BulletConstraint constrain, Vector3 low, Vector3 hi); 322public override bool SetAngularLimits(BulletConstraint constrain, Vector3 low, Vector3 hi)
323{
324 return BSAPICPP.SetAngularLimits2(constrain.ptr, low, hi);
325}
408 326
409public abstract bool UseFrameOffset2(BulletConstraint constrain, float enable); 327public override bool UseFrameOffset(BulletConstraint constrain, float enable)
328{
329 return BSAPICPP.UseFrameOffset2(constrain.ptr, enable);
330}
410 331
411public abstract bool TranslationalLimitMotor2(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce); 332public override bool TranslationalLimitMotor(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce)
333{
334 return BSAPICPP.TranslationalLimitMotor2(constrain.ptr, enable, targetVel, maxMotorForce);
335}
412 336
413public abstract bool SetBreakingImpulseThreshold2(BulletConstraint constrain, float threshold); 337public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold)
338{
339 return BSAPICPP.SetBreakingImpulseThreshold2(constrain.ptr, threshold);
340}
414 341
415public abstract bool CalculateTransforms2(BulletConstraint constrain); 342public override bool CalculateTransforms(BulletConstraint constrain)
343{
344 return BSAPICPP.CalculateTransforms2(constrain.ptr);
345}
416 346
417public abstract bool SetConstraintParam2(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); 347public override bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis)
348{
349 return BSAPICPP.SetConstraintParam2(constrain.ptr, paramIndex, value, axis);
350}
418 351
419public abstract bool DestroyConstraint2(BulletWorld world, BulletConstraint constrain); 352public override bool DestroyConstraint(BulletWorld world, BulletConstraint constrain)
353{
354 return BSAPICPP.DestroyConstraint2(world.ptr, constrain.ptr);
355}
420 356
421// ===================================================================================== 357// =====================================================================================
422// btCollisionWorld entries 358// btCollisionWorld entries
423public abstract void UpdateSingleAabb2(BulletWorld world, BulletBody obj); 359public override void UpdateSingleAabb(BulletWorld world, BulletBody obj)
360{
361 BSAPICPP.UpdateSingleAabb2(world.ptr, obj.ptr);
362}
424 363
425public abstract void UpdateAabbs2(BulletWorld world); 364public override void UpdateAabbs(BulletWorld world)
365{
366 BSAPICPP.UpdateAabbs2(world.ptr);
367}
426 368
427public abstract bool GetForceUpdateAllAabbs2(BulletWorld world); 369public override bool GetForceUpdateAllAabbs(BulletWorld world)
370{
371 return BSAPICPP.GetForceUpdateAllAabbs2(world.ptr);
372}
428 373
429public abstract void SetForceUpdateAllAabbs2(BulletWorld world, bool force); 374public override void SetForceUpdateAllAabbs(BulletWorld world, bool force)
375{
376 BSAPICPP.SetForceUpdateAllAabbs2(world.ptr, force);
377}
430 378
431// ===================================================================================== 379// =====================================================================================
432// btDynamicsWorld entries 380// btDynamicsWorld entries
433public abstract bool AddObjectToWorld2(BulletWorld world, BulletBody obj); 381public override bool AddObjectToWorld(BulletWorld world, BulletBody obj)
382{
383 return BSAPICPP.AddObjectToWorld2(world.ptr, obj.ptr);
384}
434 385
435public abstract bool RemoveObjectFromWorld2(BulletWorld world, BulletBody obj); 386public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj)
387{
388 return BSAPICPP.RemoveObjectFromWorld2(world.ptr, obj.ptr);
389}
436 390
437public abstract bool AddConstraintToWorld2(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects); 391public override bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects)
392{
393 return BSAPICPP.AddConstraintToWorld2(world.ptr, constrain.ptr, disableCollisionsBetweenLinkedObjects);
394}
438 395
439public abstract bool RemoveConstraintFromWorld2(BulletWorld world, BulletConstraint constrain); 396public override bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain)
397{
398 return BSAPICPP.RemoveConstraintFromWorld2(world.ptr, constrain.ptr);
399}
440// ===================================================================================== 400// =====================================================================================
441// btCollisionObject entries 401// btCollisionObject entries
442public abstract Vector3 GetAnisotripicFriction2(BulletConstraint constrain); 402public override Vector3 GetAnisotripicFriction(BulletConstraint constrain)
443 403{
444public abstract Vector3 SetAnisotripicFriction2(BulletConstraint constrain, Vector3 frict); 404 return BSAPICPP.GetAnisotripicFriction2(constrain.ptr);
445 405}
446public abstract bool HasAnisotripicFriction2(BulletConstraint constrain);
447
448public abstract void SetContactProcessingThreshold2(BulletBody obj, float val);
449
450public abstract float GetContactProcessingThreshold2(BulletBody obj);
451 406
452public abstract bool IsStaticObject2(BulletBody obj); 407public override Vector3 SetAnisotripicFriction(BulletConstraint constrain, Vector3 frict)
408{
409 return BSAPICPP.SetAnisotripicFriction2(constrain.ptr, frict);
410}
453 411
454public abstract bool IsKinematicObject2(BulletBody obj); 412public override bool HasAnisotripicFriction(BulletConstraint constrain)
413{
414 return BSAPICPP.HasAnisotripicFriction2(constrain.ptr);
415}
455 416
456public abstract bool IsStaticOrKinematicObject2(BulletBody obj); 417public override void SetContactProcessingThreshold(BulletBody obj, float val)
418{
419 BSAPICPP.SetContactProcessingThreshold2(obj.ptr, val);
420}
457 421
458public abstract bool HasContactResponse2(BulletBody obj); 422public override float GetContactProcessingThreshold(BulletBody obj)
423{
424 return BSAPICPP.GetContactProcessingThreshold2(obj.ptr);
425}
459 426
460public abstract void SetCollisionShape2(BulletWorld sim, BulletBody obj, BulletBody shape); 427public override bool IsStaticObject(BulletBody obj)
428{
429 return BSAPICPP.IsStaticObject2(obj.ptr);
430}
461 431
462public abstract BulletShape GetCollisionShape2(BulletBody obj); 432public override bool IsKinematicObject(BulletBody obj)
433{
434 return BSAPICPP.IsKinematicObject2(obj.ptr);
435}
463 436
464public abstract int GetActivationState2(BulletBody obj); 437public override bool IsStaticOrKinematicObject(BulletBody obj)
438{
439 return BSAPICPP.IsStaticOrKinematicObject2(obj.ptr);
440}
465 441
466public abstract void SetActivationState2(BulletBody obj, int state); 442public override bool HasContactResponse(BulletBody obj)
443{
444 return BSAPICPP.HasContactResponse2(obj.ptr);
445}
467 446
468public abstract void SetDeactivationTime2(BulletBody obj, float dtime); 447public override void SetCollisionShape(BulletWorld sim, BulletBody obj, BulletShape shape)
448{
449 BSAPICPP.SetCollisionShape2(sim.ptr, obj.ptr, shape.ptr);
450}
469 451
470public abstract float GetDeactivationTime2(BulletBody obj); 452public override BulletShape GetCollisionShape(BulletBody obj)
453{
454 return new BulletShape(BSAPICPP.GetCollisionShape2(obj.ptr));
455}
471 456
472public abstract void ForceActivationState2(BulletBody obj, ActivationState state); 457public override int GetActivationState(BulletBody obj)
458{
459 return BSAPICPP.GetActivationState2(obj.ptr);
460}
473 461
474public abstract void Activate2(BulletBody obj, bool forceActivation); 462public override void SetActivationState(BulletBody obj, int state)
463{
464 BSAPICPP.SetActivationState2(obj.ptr, state);
465}
475 466
476public abstract bool IsActive2(BulletBody obj); 467public override void SetDeactivationTime(BulletBody obj, float dtime)
468{
469 BSAPICPP.SetDeactivationTime2(obj.ptr, dtime);
470}
477 471
478public abstract void SetRestitution2(BulletBody obj, float val); 472public override float GetDeactivationTime(BulletBody obj)
473{
474 return BSAPICPP.GetDeactivationTime2(obj.ptr);
475}
479 476
480public abstract float GetRestitution2(BulletBody obj); 477public override void ForceActivationState(BulletBody obj, ActivationState state)
478{
479 BSAPICPP.ForceActivationState2(obj.ptr, state);
480}
481 481
482public abstract void SetFriction2(BulletBody obj, float val); 482public override void Activate(BulletBody obj, bool forceActivation)
483{
484 BSAPICPP.Activate2(obj.ptr, forceActivation);
485}
483 486
484public abstract float GetFriction2(BulletBody obj); 487public override bool IsActive(BulletBody obj)
488{
489 return BSAPICPP.IsActive2(obj.ptr);
490}
485 491
486 /* Haven't defined the type 'Transform' 492public override void SetRestitution(BulletBody obj, float val)
487public abstract Transform GetWorldTransform2(BulletBody obj); 493{
494 BSAPICPP.SetRestitution2(obj.ptr, val);
495}
488 496
489public abstract void setWorldTransform2(BulletBody obj, Transform trans); 497public override float GetRestitution(BulletBody obj)
490 */ 498{
499 return BSAPICPP.GetRestitution2(obj.ptr);
500}
491 501
492public abstract Vector3 GetPosition2(BulletBody obj); 502public override void SetFriction(BulletBody obj, float val)
503{
504 BSAPICPP.SetFriction2(obj.ptr, val);
505}
493 506
494public abstract Quaternion GetOrientation2(BulletBody obj); 507public override float GetFriction(BulletBody obj)
508{
509 return BSAPICPP.GetFriction2(obj.ptr);
510}
495 511
496public abstract void SetTranslation2(BulletBody obj, Vector3 position, Quaternion rotation); 512public override Vector3 GetPosition(BulletBody obj)
513{
514 return BSAPICPP.GetPosition2(obj.ptr);
515}
497 516
498public abstract IntPtr GetBroadphaseHandle2(BulletBody obj); 517public override Quaternion GetOrientation(BulletBody obj)
518{
519 return BSAPICPP.GetOrientation2(obj.ptr);
520}
499 521
500public abstract void SetBroadphaseHandle2(BulletBody obj, IntPtr handle); 522public override void SetTranslation(BulletBody obj, Vector3 position, Quaternion rotation)
523{
524 BSAPICPP.SetTranslation2(obj.ptr, position, rotation);
525}
501 526
502 /* 527 /*
503public abstract Transform GetInterpolationWorldTransform2(IntPtr obj); 528public override IntPtr GetBroadphaseHandle(BulletBody obj)
529{
530 return BSAPICPP.GetBroadphaseHandle2(obj.ptr);
531}
504 532
505public abstract void SetInterpolationWorldTransform2(IntPtr obj, Transform trans); 533public override void SetBroadphaseHandle(BulletBody obj, IntPtr handle)
534{
535 BSAPICPP.SetUserPointer2(obj.ptr, handle);
536}
506 */ 537 */
507 538
508public abstract void SetInterpolationLinearVelocity2(BulletBody obj, Vector3 vel); 539public override void SetInterpolationLinearVelocity(BulletBody obj, Vector3 vel)
540{
541 BSAPICPP.SetInterpolationLinearVelocity2(obj.ptr, vel);
542}
509 543
510public abstract void SetInterpolationAngularVelocity2(BulletBody obj, Vector3 vel); 544public override void SetInterpolationAngularVelocity(BulletBody obj, Vector3 vel)
545{
546 BSAPICPP.SetInterpolationAngularVelocity2(obj.ptr, vel);
547}
511 548
512public abstract void SetInterpolationVelocity2(BulletBody obj, Vector3 linearVel, Vector3 angularVel); 549public override void SetInterpolationVelocity(BulletBody obj, Vector3 linearVel, Vector3 angularVel)
550{
551 BSAPICPP.SetInterpolationVelocity2(obj.ptr, linearVel, angularVel);
552}
513 553
514public abstract float GetHitFraction2(BulletBody obj); 554public override float GetHitFraction(BulletBody obj)
555{
556 return BSAPICPP.GetHitFraction2(obj.ptr);
557}
515 558
516public abstract void SetHitFraction2(BulletBody obj, float val); 559public override void SetHitFraction(BulletBody obj, float val)
560{
561 BSAPICPP.SetHitFraction2(obj.ptr, val);
562}
517 563
518public abstract CollisionFlags GetCollisionFlags2(BulletBody obj); 564public override CollisionFlags GetCollisionFlags(BulletBody obj)
565{
566 return BSAPICPP.GetCollisionFlags2(obj.ptr);
567}
519 568
520public abstract CollisionFlags SetCollisionFlags2(BulletBody obj, CollisionFlags flags); 569public override CollisionFlags SetCollisionFlags(BulletBody obj, CollisionFlags flags)
570{
571 return BSAPICPP.SetCollisionFlags2(obj.ptr, flags);
572}
521 573
522public abstract CollisionFlags AddToCollisionFlags2(BulletBody obj, CollisionFlags flags); 574public override CollisionFlags AddToCollisionFlags(BulletBody obj, CollisionFlags flags)
575{
576 return BSAPICPP.AddToCollisionFlags2(obj.ptr, flags);
577}
523 578
524public abstract CollisionFlags RemoveFromCollisionFlags2(BulletBody obj, CollisionFlags flags); 579public override CollisionFlags RemoveFromCollisionFlags(BulletBody obj, CollisionFlags flags)
580{
581 return BSAPICPP.RemoveFromCollisionFlags2(obj.ptr, flags);
582}
525 583
526public abstract float GetCcdMotionThreshold2(BulletBody obj); 584public override float GetCcdMotionThreshold(BulletBody obj)
585{
586 return BSAPICPP.GetCcdMotionThreshold2(obj.ptr);
587}
527 588
528public abstract void SetCcdMotionThreshold2(BulletBody obj, float val);
529 589
530public abstract float GetCcdSweptSphereRadius2(BulletBody obj); 590public override void SetCcdMotionThreshold(BulletBody obj, float val)
591{
592 BSAPICPP.SetCcdMotionThreshold2(obj.ptr, val);
593}
531 594
532public abstract void SetCcdSweptSphereRadius2(BulletBody obj, float val); 595public override float GetCcdSweptSphereRadius(BulletBody obj)
596{
597 return BSAPICPP.GetCcdSweptSphereRadius2(obj.ptr);
598}
533 599
534public abstract IntPtr GetUserPointer2(BulletBody obj); 600public override void SetCcdSweptSphereRadius(BulletBody obj, float val)
601{
602 BSAPICPP.SetCcdSweptSphereRadius2(obj.ptr, val);
603}
535 604
536public abstract void SetUserPointer2(BulletBody obj, IntPtr val); 605public override IntPtr GetUserPointer(BulletBody obj)
606{
607 return BSAPICPP.GetUserPointer2(obj.ptr);
608}
609
610public override void SetUserPointer(BulletBody obj, IntPtr val)
611{
612 BSAPICPP.SetUserPointer2(obj.ptr, val);
613}
537 614
538// ===================================================================================== 615// =====================================================================================
539// btRigidBody entries 616// btRigidBody entries
540public abstract void ApplyGravity2(BulletBody obj); 617public override void ApplyGravity(BulletBody obj)
541 618{
542public abstract void SetGravity2(BulletBody obj, Vector3 val); 619 BSAPICPP.ApplyGravity2(obj.ptr);
543 620}
544public abstract Vector3 GetGravity2(BulletBody obj);
545 621
546public abstract void SetDamping2(BulletBody obj, float lin_damping, float ang_damping); 622public override void SetGravity(BulletBody obj, Vector3 val)
623{
624 BSAPICPP.SetGravity2(obj.ptr, val);
625}
547 626
548public abstract void SetLinearDamping2(BulletBody obj, float lin_damping); 627public override Vector3 GetGravity(BulletBody obj)
628{
629 return BSAPICPP.GetGravity2(obj.ptr);
630}
549 631
550public abstract void SetAngularDamping2(BulletBody obj, float ang_damping); 632public override void SetDamping(BulletBody obj, float lin_damping, float ang_damping)
633{
634 BSAPICPP.SetDamping2(obj.ptr, lin_damping, ang_damping);
635}
551 636
552public abstract float GetLinearDamping2(BulletBody obj); 637public override void SetLinearDamping(BulletBody obj, float lin_damping)
638{
639 BSAPICPP.SetLinearDamping2(obj.ptr, lin_damping);
640}
553 641
554public abstract float GetAngularDamping2(BulletBody obj); 642public override void SetAngularDamping(BulletBody obj, float ang_damping)
643{
644 BSAPICPP.SetAngularDamping2(obj.ptr, ang_damping);
645}
555 646
556public abstract float GetLinearSleepingThreshold2(BulletBody obj); 647public override float GetLinearDamping(BulletBody obj)
648{
649 return BSAPICPP.GetLinearDamping2(obj.ptr);
650}
557 651
652public override float GetAngularDamping(BulletBody obj)
653{
654 return BSAPICPP.GetAngularDamping2(obj.ptr);
655}
558 656
559public abstract void ApplyDamping2(BulletBody obj, float timeStep); 657public override float GetLinearSleepingThreshold(BulletBody obj)
658{
659 return BSAPICPP.GetLinearSleepingThreshold2(obj.ptr);
660}
560 661
561public abstract void SetMassProps2(BulletBody obj, float mass, Vector3 inertia); 662public override void ApplyDamping(BulletBody obj, float timeStep)
663{
664 BSAPICPP.ApplyDamping2(obj.ptr, timeStep);
665}
562 666
563public abstract Vector3 GetLinearFactor2(BulletBody obj); 667public override void SetMassProps(BulletBody obj, float mass, Vector3 inertia)
668{
669 BSAPICPP.SetMassProps2(obj.ptr, mass, inertia);
670}
564 671
565public abstract void SetLinearFactor2(BulletBody obj, Vector3 factor); 672public override Vector3 GetLinearFactor(BulletBody obj)
673{
674 return BSAPICPP.GetLinearFactor2(obj.ptr);
675}
566 676
567 /* 677public override void SetLinearFactor(BulletBody obj, Vector3 factor)
568public abstract void SetCenterOfMassTransform2(BulletBody obj, Transform trans); 678{
569 */ 679 BSAPICPP.SetLinearFactor2(obj.ptr, factor);
680}
570 681
571public abstract void SetCenterOfMassByPosRot2(BulletBody obj, Vector3 pos, Quaternion rot); 682public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot)
683{
684 BSAPICPP.SetCenterOfMassByPosRot2(obj.ptr, pos, rot);
685}
572 686
573// Add a force to the object as if its mass is one. 687// Add a force to the object as if its mass is one.
574public abstract void ApplyCentralForce2(BulletBody obj, Vector3 force); 688public override void ApplyCentralForce(BulletBody obj, Vector3 force)
689{
690 BSAPICPP.ApplyCentralForce2(obj.ptr, force);
691}
575 692
576// Set the force being applied to the object as if its mass is one. 693// Set the force being applied to the object as if its mass is one.
577public abstract void SetObjectForce2(BulletBody obj, Vector3 force); 694public override void SetObjectForce(BulletBody obj, Vector3 force)
695{
696 BSAPICPP.SetObjectForce2(obj.ptr, force);
697}
578 698
579public abstract Vector3 GetTotalForce2(BulletBody obj); 699public override Vector3 GetTotalForce(BulletBody obj)
700{
701 return BSAPICPP.GetTotalForce2(obj.ptr);
702}
580 703
581public abstract Vector3 GetTotalTorque2(BulletBody obj); 704public override Vector3 GetTotalTorque(BulletBody obj)
705{
706 return BSAPICPP.GetTotalTorque2(obj.ptr);
707}
582 708
583public abstract Vector3 GetInvInertiaDiagLocal2(BulletBody obj); 709public override Vector3 GetInvInertiaDiagLocal(BulletBody obj)
710{
711 return BSAPICPP.GetInvInertiaDiagLocal2(obj.ptr);
712}
584 713
585public abstract void SetInvInertiaDiagLocal2(BulletBody obj, Vector3 inert); 714public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert)
715{
716 BSAPICPP.SetInvInertiaDiagLocal2(obj.ptr, inert);
717}
586 718
587public abstract void SetSleepingThresholds2(BulletBody obj, float lin_threshold, float ang_threshold); 719public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold)
720{
721 BSAPICPP.SetSleepingThresholds2(obj.ptr, lin_threshold, ang_threshold);
722}
588 723
589public abstract void ApplyTorque2(BulletBody obj, Vector3 torque); 724public override void ApplyTorque(BulletBody obj, Vector3 torque)
725{
726 BSAPICPP.ApplyTorque2(obj.ptr, torque);
727}
590 728
591// Apply force at the given point. Will add torque to the object. 729// Apply force at the given point. Will add torque to the object.
592public abstract void ApplyForce2(BulletBody obj, Vector3 force, Vector3 pos); 730public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos)
731{
732 BSAPICPP.ApplyForce2(obj.ptr, force, pos);
733}
593 734
594// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass. 735// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
595public abstract void ApplyCentralImpulse2(BulletBody obj, Vector3 imp); 736public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp)
737{
738 BSAPICPP.ApplyCentralImpulse2(obj.ptr, imp);
739}
596 740
597// Apply impulse to the object's torque. Force is scaled by object's mass. 741// Apply impulse to the object's torque. Force is scaled by object's mass.
598public abstract void ApplyTorqueImpulse2(BulletBody obj, Vector3 imp); 742public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp)
743{
744 BSAPICPP.ApplyTorqueImpulse2(obj.ptr, imp);
745}
599 746
600// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces. 747// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
601public abstract void ApplyImpulse2(BulletBody obj, Vector3 imp, Vector3 pos); 748public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos)
602 749{
603public abstract void ClearForces2(BulletBody obj); 750 BSAPICPP.ApplyImpulse2(obj.ptr, imp, pos);
604 751}
605public abstract void ClearAllForces2(BulletBody obj);
606 752
607public abstract void UpdateInertiaTensor2(BulletBody obj); 753public override void ClearForces(BulletBody obj)
754{
755 BSAPICPP.ClearForces2(obj.ptr);
756}
608 757
758public override void ClearAllForces(BulletBody obj)
759{
760 BSAPICPP.ClearAllForces2(obj.ptr);
761}
609 762
610 /* 763public override void UpdateInertiaTensor(BulletBody obj)
611public abstract Transform GetCenterOfMassTransform2(BulletBody obj); 764{
612 */ 765 BSAPICPP.UpdateInertiaTensor2(obj.ptr);
766}
613 767
614public abstract Vector3 GetLinearVelocity2(BulletBody obj); 768public override Vector3 GetLinearVelocity(BulletBody obj)
769{
770 return BSAPICPP.GetLinearVelocity2(obj.ptr);
771}
615 772
616public abstract Vector3 GetAngularVelocity2(BulletBody obj); 773public override Vector3 GetAngularVelocity(BulletBody obj)
774{
775 return BSAPICPP.GetAngularVelocity2(obj.ptr);
776}
617 777
618public abstract void SetLinearVelocity2(BulletBody obj, Vector3 val); 778public override void SetLinearVelocity(BulletBody obj, Vector3 vel)
779{
780 BSAPICPP.SetLinearVelocity2(obj.ptr, vel);
781}
619 782
620public abstract void SetAngularVelocity2(BulletBody obj, Vector3 angularVelocity); 783public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity)
784{
785 BSAPICPP.SetAngularVelocity2(obj.ptr, angularVelocity);
786}
621 787
622public abstract Vector3 GetVelocityInLocalPoint2(BulletBody obj, Vector3 pos); 788public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos)
789{
790 return BSAPICPP.GetVelocityInLocalPoint2(obj.ptr, pos);
791}
623 792
624public abstract void Translate2(BulletBody obj, Vector3 trans); 793public override void Translate(BulletBody obj, Vector3 trans)
794{
795 BSAPICPP.Translate2(obj.ptr, trans);
796}
625 797
626public abstract void UpdateDeactivation2(BulletBody obj, float timeStep); 798public override void UpdateDeactivation(BulletBody obj, float timeStep)
799{
800 BSAPICPP.UpdateDeactivation2(obj.ptr, timeStep);
801}
627 802
628public abstract bool WantsSleeping2(BulletBody obj); 803public override bool WantsSleeping(BulletBody obj)
804{
805 return BSAPICPP.WantsSleeping2(obj.ptr);
806}
629 807
630public abstract void SetAngularFactor2(BulletBody obj, float factor); 808public override void SetAngularFactor(BulletBody obj, float factor)
809{
810 BSAPICPP.SetAngularFactor2(obj.ptr, factor);
811}
631 812
632public abstract void SetAngularFactorV2(BulletBody obj, Vector3 factor); 813public override void SetAngularFactorV(BulletBody obj, Vector3 factor)
814{
815 BSAPICPP.SetAngularFactorV2(obj.ptr, factor);
816}
633 817
634public abstract Vector3 GetAngularFactor2(BulletBody obj); 818public override Vector3 GetAngularFactor(BulletBody obj)
819{
820 return BSAPICPP.GetAngularFactor2(obj.ptr);
821}
635 822
636public abstract bool IsInWorld2(BulletBody obj); 823public override bool IsInWorld(BulletBody obj)
824{
825 return BSAPICPP.IsInWorld2(obj.ptr);
826}
637 827
638public abstract void AddConstraintRef2(BulletBody obj, BulletConstraint constrain); 828public override void AddConstraintRef(BulletBody obj, BulletConstraint constrain)
829{
830 BSAPICPP.AddConstraintRef2(obj.ptr, constrain.ptr);
831}
639 832
640public abstract void RemoveConstraintRef2(BulletBody obj, BulletConstraint constrain); 833public override void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain)
834{
835 BSAPICPP.RemoveConstraintRef2(obj.ptr, constrain.ptr);
836}
641 837
642public abstract BulletConstraint GetConstraintRef2(BulletBody obj, int index); 838public override BulletConstraint GetConstraintRef(BulletBody obj, int index)
839{
840 return new BulletConstraint(BSAPICPP.GetConstraintRef2(obj.ptr, index));
841}
643 842
644public abstract int GetNumConstraintRefs2(BulletBody obj); 843public override int GetNumConstraintRefs(BulletBody obj)
844{
845 return BSAPICPP.GetNumConstraintRefs2(obj.ptr);
846}
645 847
646public abstract bool SetCollisionGroupMask2(BulletBody body, uint filter, uint mask); 848public override bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask)
849{
850 return BSAPICPP.SetCollisionGroupMask2(body.ptr, filter, mask);
851}
647 852
648// ===================================================================================== 853// =====================================================================================
649// btCollisionShape entries 854// btCollisionShape entries
650 855
651public abstract float GetAngularMotionDisc2(BulletShape shape); 856public override float GetAngularMotionDisc(BulletShape shape)
857{
858 return BSAPICPP.GetAngularMotionDisc2(shape.ptr);
859}
860
861public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor)
862{
863 return BSAPICPP.GetContactBreakingThreshold2(shape.ptr, defaultFactor);
864}
865
866public override bool IsPolyhedral(BulletShape shape)
867{
868 return BSAPICPP.IsPolyhedral2(shape.ptr);
869}
870
871public override bool IsConvex2d(BulletShape shape)
872{
873 return BSAPICPP.IsConvex2d2(shape.ptr);
874}
652 875
653public abstract float GetContactBreakingThreshold2(BulletShape shape, float defaultFactor); 876public override bool IsConvex(BulletShape shape)
877{
878 return BSAPICPP.IsConvex2(shape.ptr);
879}
654 880
655public abstract bool IsPolyhedral2(BulletShape shape); 881public override bool IsNonMoving(BulletShape shape)
882{
883 return BSAPICPP.IsNonMoving2(shape.ptr);
884}
656 885
657public abstract bool IsConvex2d2(BulletShape shape); 886public override bool IsConcave(BulletShape shape)
887{
888 return BSAPICPP.IsConcave2(shape.ptr);
889}
658 890
659public abstract bool IsConvex2(BulletShape shape); 891public override bool IsCompound(BulletShape shape)
892{
893 return BSAPICPP.IsCompound2(shape.ptr);
894}
660 895
661public abstract bool IsNonMoving2(BulletShape shape); 896public override bool IsSoftBody(BulletShape shape)
897{
898 return BSAPICPP.IsSoftBody2(shape.ptr);
899}
900
901public override bool IsInfinite(BulletShape shape)
902{
903 return BSAPICPP.IsInfinite2(shape.ptr);
904}
905
906public override void SetLocalScaling(BulletShape shape, Vector3 scale)
907{
908 BSAPICPP.SetLocalScaling2(shape.ptr, scale);
909}
910
911public override Vector3 GetLocalScaling(BulletShape shape)
912{
913 return BSAPICPP.GetLocalScaling2(shape.ptr);
914}
662 915
663public abstract bool IsConcave2(BulletShape shape); 916public override Vector3 CalculateLocalInertia(BulletShape shape, float mass)
917{
918 return BSAPICPP.CalculateLocalInertia2(shape.ptr, mass);
919}
664 920
665public abstract bool IsCompound2(BulletShape shape); 921public override int GetShapeType(BulletShape shape)
922{
923 return BSAPICPP.GetShapeType2(shape.ptr);
924}
666 925
667public abstract bool IsSoftBody2(BulletShape shape); 926public override void SetMargin(BulletShape shape, float val)
927{
928 BSAPICPP.SetMargin2(shape.ptr, val);
929}
668 930
669public abstract bool IsInfinite2(BulletShape shape); 931public override float GetMargin(BulletShape shape)
932{
933 return BSAPICPP.GetMargin2(shape.ptr);
934}
670 935
671public abstract void SetLocalScaling2(BulletShape shape, Vector3 scale); 936// =====================================================================================
937// Debugging
938public override void DumpRigidBody(BulletWorld sim, BulletBody collisionObject)
939{
940 BSAPICPP.DumpRigidBody2(sim.ptr, collisionObject.ptr);
941}
672 942
673public abstract Vector3 GetLocalScaling2(BulletShape shape); 943public override void DumpCollisionShape(BulletWorld sim, BulletShape collisionShape)
944{
945 BSAPICPP.DumpCollisionShape2(sim.ptr, collisionShape.ptr);
946}
674 947
675public abstract Vector3 CalculateLocalInertia2(BulletShape shape, float mass); 948public override void DumpConstraint(BulletWorld sim, BulletConstraint constrain)
949{
950 BSAPICPP.DumpConstraint2(sim.ptr, constrain.ptr);
951}
676 952
677public abstract int GetShapeType2(BulletShape shape); 953public override void DumpActivationInfo(BulletWorld sim)
954{
955 BSAPICPP.DumpActivationInfo2(sim.ptr);
956}
678 957
679public abstract void SetMargin2(BulletShape shape, float val); 958public override void DumpAllInfo(BulletWorld sim)
959{
960 BSAPICPP.DumpAllInfo2(sim.ptr);
961}
680 962
681public abstract float GetMargin2(BulletShape shape); 963public override void DumpPhysicsStatistics(BulletWorld sim)
964{
965 BSAPICPP.DumpPhysicsStatistics2(sim.ptr);
966}
682 967
683};
684 968
685// =============================================================================== 969// =====================================================================================
686static class BulletSimAPI { 970// =====================================================================================
971// =====================================================================================
972// =====================================================================================
973// =====================================================================================
974// The actual interface to the unmanaged code
975static class BSAPICPP
976{
687// =============================================================================== 977// ===============================================================================
688// Link back to the managed code for outputting log messages 978// Link back to the managed code for outputting log messages
689[UnmanagedFunctionPointer(CallingConvention.Cdecl)] 979[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
@@ -698,23 +988,17 @@ public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
698 DebugLogCallback logRoutine); 988 DebugLogCallback logRoutine);
699 989
700[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 990[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
701public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value); 991public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
702 992 out int updatedEntityCount, out int collidersCount);
703[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
704public static extern void SetHeightMap2(IntPtr world, float[] heightmap);
705 993
706[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 994[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
707public static extern void Shutdown2(IntPtr sim); 995public static extern void Shutdown2(IntPtr sim);
708 996
709[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 997[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
710public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep, 998public static extern bool PushUpdate2(IntPtr obj);
711 out int updatedEntityCount,
712 out IntPtr updatedEntitiesPtr,
713 out int collidersCount,
714 out IntPtr collidersPtr);
715 999
716[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1000[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
717public static extern bool PushUpdate2(IntPtr obj); 1001public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
718 1002
719// ===================================================================================== 1003// =====================================================================================
720// Mesh, hull, shape and body creation helper routines 1004// Mesh, hull, shape and body creation helper routines
@@ -737,7 +1021,7 @@ public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData)
737public static extern bool IsNativeShape2(IntPtr shape); 1021public static extern bool IsNativeShape2(IntPtr shape);
738 1022
739[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1023[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
740public static extern void SetShapeCollisionMargin(IntPtr shape, float margin); 1024public static extern void SetShapeCollisionMargin2(IntPtr shape, float margin);
741 1025
742[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1026[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
743public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale); 1027public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale);
@@ -767,9 +1051,6 @@ public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape);
767public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id); 1051public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id);
768 1052
769[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1053[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
770public static extern IntPtr CreateBodyFromShapeAndInfo2(IntPtr sim, IntPtr shape, uint id, IntPtr constructionInfo);
771
772[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
773public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape); 1054public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
774 1055
775[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1056[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -785,32 +1066,17 @@ public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, uint
785public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot); 1066public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
786 1067
787[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1068[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
788public static extern IntPtr AllocateBodyInfo2(IntPtr obj);
789
790[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
791public static extern void ReleaseBodyInfo2(IntPtr obj);
792
793[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
794public static extern void DestroyObject2(IntPtr sim, IntPtr obj); 1069public static extern void DestroyObject2(IntPtr sim, IntPtr obj);
795 1070
796// ===================================================================================== 1071// =====================================================================================
797// Terrain creation and helper routines 1072// Terrain creation and helper routines
798[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1073[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
799public static extern IntPtr CreateHeightMapInfo2(IntPtr sim, uint id, Vector3 minCoords, Vector3 maxCoords,
800 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
801
802[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
803public static extern IntPtr FillHeightMapInfo2(IntPtr sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords,
804 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin);
805
806[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
807public static extern bool ReleaseHeightMapInfo2(IntPtr heightMapInfo);
808
809[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
810public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin); 1074public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin);
811 1075
812[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1076[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
813public static extern IntPtr CreateTerrainShape2(IntPtr mapInfo); 1077public static extern IntPtr CreateTerrainShape2(uint id, Vector3 size, float minHeight, float maxHeight,
1078 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap,
1079 float scaleFactor, float collisionMargin);
814 1080
815// ===================================================================================== 1081// =====================================================================================
816// Constraint creation and helper routines 1082// Constraint creation and helper routines
@@ -1273,4 +1539,7 @@ public static extern void DumpAllInfo2(IntPtr sim);
1273public static extern void DumpPhysicsStatistics2(IntPtr sim); 1539public static extern void DumpPhysicsStatistics2(IntPtr sim);
1274 1540
1275} 1541}
1542
1543}
1544
1276} 1545}