aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs1987
1 files changed, 1987 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
new file mode 100755
index 0000000..77ea3ed
--- /dev/null
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
@@ -0,0 +1,1987 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyrightD
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Runtime.InteropServices;
31using System.Security;
32using System.Text;
33
34using OpenSim.Framework;
35
36using OpenMetaverse;
37
38namespace OpenSim.Region.Physics.BulletSPlugin
39{
40public sealed class BSAPIUnman : BSAPITemplate
41{
42
43private sealed class BulletWorldUnman : BulletWorld
44{
45 public IntPtr ptr;
46 public BulletWorldUnman(uint id, BSScene physScene, IntPtr xx)
47 : base(id, physScene)
48 {
49 ptr = xx;
50 }
51}
52
53private sealed class BulletBodyUnman : BulletBody
54{
55 public IntPtr ptr;
56 public BulletBodyUnman(uint id, IntPtr xx)
57 : base(id)
58 {
59 ptr = xx;
60 }
61 public override bool HasPhysicalBody
62 {
63 get { return ptr != IntPtr.Zero; }
64 }
65 public override void Clear()
66 {
67 ptr = IntPtr.Zero;
68 }
69 public override string AddrString
70 {
71 get { return ptr.ToString("X"); }
72 }
73}
74
75private sealed class BulletShapeUnman : BulletShape
76{
77 public IntPtr ptr;
78 public BulletShapeUnman(IntPtr xx, BSPhysicsShapeType typ)
79 : base()
80 {
81 ptr = xx;
82 type = typ;
83 }
84 public override bool HasPhysicalShape
85 {
86 get { return ptr != IntPtr.Zero; }
87 }
88 public override void Clear()
89 {
90 ptr = IntPtr.Zero;
91 }
92 public override BulletShape Clone()
93 {
94 return new BulletShapeUnman(ptr, type);
95 }
96 public override bool ReferenceSame(BulletShape other)
97 {
98 BulletShapeUnman otheru = other as BulletShapeUnman;
99 return (otheru != null) && (this.ptr == otheru.ptr);
100
101 }
102 public override string AddrString
103 {
104 get { return ptr.ToString("X"); }
105 }
106}
107private sealed class BulletConstraintUnman : BulletConstraint
108{
109 public BulletConstraintUnman(IntPtr xx) : base()
110 {
111 ptr = xx;
112 }
113 public IntPtr ptr;
114
115 public override void Clear()
116 {
117 ptr = IntPtr.Zero;
118 }
119 public override bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } }
120
121 // Used for log messages for a unique display of the memory/object allocated to this instance
122 public override string AddrString
123 {
124 get { return ptr.ToString("X"); }
125 }
126}
127
128// We pin the memory passed between the managed and unmanaged code.
129GCHandle m_paramsHandle;
130private GCHandle m_collisionArrayPinnedHandle;
131private GCHandle m_updateArrayPinnedHandle;
132
133// Handle to the callback used by the unmanaged code to call into the managed code.
134// Used for debug logging.
135// Need to store the handle in a persistant variable so it won't be freed.
136private BSAPICPP.DebugLogCallback m_DebugLogCallbackHandle;
137
138private BSScene PhysicsScene { get; set; }
139
140public override string BulletEngineName { get { return "BulletUnmanaged"; } }
141public override string BulletEngineVersion { get; protected set; }
142
143public BSAPIUnman(string paramName, BSScene physScene)
144{
145 PhysicsScene = physScene;
146
147 // Do something fancy with the paramName to get the right DLL implementation
148 // like "Bullet-2.80-OpenCL-Intel" loading the version for Intel based OpenCL implementation, etc.
149 if (Util.IsWindows())
150 Util.LoadArchSpecificWindowsDll("BulletSim.dll");
151 // If not Windows, loading is performed by the
152 // Mono loader as specified in
153 // "bin/Physics/OpenSim.Region.Physics.BulletSPlugin.dll.config".
154}
155
156// Initialization and simulation
157public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms,
158 int maxCollisions, ref CollisionDesc[] collisionArray,
159 int maxUpdates, ref EntityProperties[] updateArray
160 )
161{
162 // Pin down the memory that will be used to pass object collisions and updates back from unmanaged code
163 m_paramsHandle = GCHandle.Alloc(parms, GCHandleType.Pinned);
164 m_collisionArrayPinnedHandle = GCHandle.Alloc(collisionArray, GCHandleType.Pinned);
165 m_updateArrayPinnedHandle = GCHandle.Alloc(updateArray, GCHandleType.Pinned);
166
167 // If Debug logging level, enable logging from the unmanaged code
168 m_DebugLogCallbackHandle = null;
169 if (BSScene.m_log.IsDebugEnabled && PhysicsScene.PhysicsLogging.Enabled)
170 {
171 BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader);
172 if (PhysicsScene.PhysicsLogging.Enabled)
173 // The handle is saved in a variable to make sure it doesn't get freed after this call
174 m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLoggerPhysLog);
175 else
176 m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLogger);
177 }
178
179 // Get the version of the DLL
180 // TODO: this doesn't work yet. Something wrong with marshaling the returned string.
181 // BulletEngineVersion = BulletSimAPI.GetVersion2();
182 BulletEngineVersion = "";
183
184 // Call the unmanaged code with the buffers and other information
185 return new BulletWorldUnman(0, PhysicsScene, BSAPICPP.Initialize2(maxPosition, m_paramsHandle.AddrOfPinnedObject(),
186 maxCollisions, m_collisionArrayPinnedHandle.AddrOfPinnedObject(),
187 maxUpdates, m_updateArrayPinnedHandle.AddrOfPinnedObject(),
188 m_DebugLogCallbackHandle));
189
190}
191
192// Called directly from unmanaged code so don't do much
193private void BulletLogger(string msg)
194{
195 BSScene.m_log.Debug("[BULLETS UNMANAGED]:" + msg);
196}
197
198// Called directly from unmanaged code so don't do much
199private void BulletLoggerPhysLog(string msg)
200{
201 PhysicsScene.DetailLog("[BULLETS UNMANAGED]:" + msg);
202}
203
204public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
205 out int updatedEntityCount, out int collidersCount)
206{
207 BulletWorldUnman worldu = world as BulletWorldUnman;
208 return BSAPICPP.PhysicsStep2(worldu.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount);
209}
210
211public override void Shutdown(BulletWorld world)
212{
213 BulletWorldUnman worldu = world as BulletWorldUnman;
214 BSAPICPP.Shutdown2(worldu.ptr);
215
216 if (m_paramsHandle.IsAllocated)
217 {
218 m_paramsHandle.Free();
219 }
220 if (m_collisionArrayPinnedHandle.IsAllocated)
221 {
222 m_collisionArrayPinnedHandle.Free();
223 }
224 if (m_updateArrayPinnedHandle.IsAllocated)
225 {
226 m_updateArrayPinnedHandle.Free();
227 }
228}
229
230public override bool PushUpdate(BulletBody obj)
231{
232 BulletBodyUnman bodyu = obj as BulletBodyUnman;
233 return BSAPICPP.PushUpdate2(bodyu.ptr);
234}
235
236public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value)
237{
238 BulletWorldUnman worldu = world as BulletWorldUnman;
239 return BSAPICPP.UpdateParameter2(worldu.ptr, localID, parm, value);
240}
241
242// =====================================================================================
243// Mesh, hull, shape and body creation helper routines
244public override BulletShape CreateMeshShape(BulletWorld world,
245 int indicesCount, int[] indices,
246 int verticesCount, float[] vertices)
247{
248 BulletWorldUnman worldu = world as BulletWorldUnman;
249 return new BulletShapeUnman(
250 BSAPICPP.CreateMeshShape2(worldu.ptr, indicesCount, indices, verticesCount, vertices),
251 BSPhysicsShapeType.SHAPE_MESH);
252}
253
254public override BulletShape CreateHullShape(BulletWorld world, int hullCount, float[] hulls)
255{
256 BulletWorldUnman worldu = world as BulletWorldUnman;
257 return new BulletShapeUnman(
258 BSAPICPP.CreateHullShape2(worldu.ptr, hullCount, hulls),
259 BSPhysicsShapeType.SHAPE_HULL);
260}
261
262public override BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape)
263{
264 BulletWorldUnman worldu = world as BulletWorldUnman;
265 BulletShapeUnman shapeu = meshShape as BulletShapeUnman;
266 return new BulletShapeUnman(
267 BSAPICPP.BuildHullShapeFromMesh2(worldu.ptr, shapeu.ptr),
268 BSPhysicsShapeType.SHAPE_HULL);
269}
270
271public override BulletShape BuildNativeShape(BulletWorld world, ShapeData shapeData)
272{
273 BulletWorldUnman worldu = world as BulletWorldUnman;
274 return new BulletShapeUnman(BSAPICPP.BuildNativeShape2(worldu.ptr, shapeData), shapeData.Type);
275}
276
277public override bool IsNativeShape(BulletShape shape)
278{
279 BulletShapeUnman shapeu = shape as BulletShapeUnman;
280 if (shapeu != null && shapeu.HasPhysicalShape)
281 return BSAPICPP.IsNativeShape2(shapeu.ptr);
282 return false;
283}
284
285public override void SetShapeCollisionMargin(BulletShape shape, float margin)
286{
287 BulletShapeUnman shapeu = shape as BulletShapeUnman;
288 if (shapeu != null && shapeu.HasPhysicalShape)
289 BSAPICPP.SetShapeCollisionMargin(shapeu.ptr, margin);
290}
291
292public override BulletShape BuildCapsuleShape(BulletWorld world, float radius, float height, Vector3 scale)
293{
294 BulletWorldUnman worldu = world as BulletWorldUnman;
295 return new BulletShapeUnman(
296 BSAPICPP.BuildCapsuleShape2(worldu.ptr, radius, height, scale),
297 BSPhysicsShapeType.SHAPE_CAPSULE);
298}
299
300public override BulletShape CreateCompoundShape(BulletWorld world, bool enableDynamicAabbTree)
301{
302 BulletWorldUnman worldu = world as BulletWorldUnman;
303 return new BulletShapeUnman(
304 BSAPICPP.CreateCompoundShape2(worldu.ptr, enableDynamicAabbTree),
305 BSPhysicsShapeType.SHAPE_COMPOUND);
306
307}
308
309public override int GetNumberOfCompoundChildren(BulletShape shape)
310{
311 BulletShapeUnman shapeu = shape as BulletShapeUnman;
312 if (shapeu != null && shapeu.HasPhysicalShape)
313 return BSAPICPP.GetNumberOfCompoundChildren2(shapeu.ptr);
314 return 0;
315}
316
317public override void AddChildShapeToCompoundShape(BulletShape shape, BulletShape addShape, Vector3 pos, Quaternion rot)
318{
319 BulletShapeUnman shapeu = shape as BulletShapeUnman;
320 BulletShapeUnman addShapeu = addShape as BulletShapeUnman;
321 BSAPICPP.AddChildShapeToCompoundShape2(shapeu.ptr, addShapeu.ptr, pos, rot);
322}
323
324public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape shape, int indx)
325{
326 BulletShapeUnman shapeu = shape as BulletShapeUnman;
327 return new BulletShapeUnman(BSAPICPP.GetChildShapeFromCompoundShapeIndex2(shapeu.ptr, indx), BSPhysicsShapeType.SHAPE_UNKNOWN);
328}
329
330public override BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape shape, int indx)
331{
332 BulletShapeUnman shapeu = shape as BulletShapeUnman;
333 return new BulletShapeUnman(BSAPICPP.RemoveChildShapeFromCompoundShapeIndex2(shapeu.ptr, indx), BSPhysicsShapeType.SHAPE_UNKNOWN);
334}
335
336public override void RemoveChildShapeFromCompoundShape(BulletShape shape, BulletShape removeShape)
337{
338 BulletShapeUnman shapeu = shape as BulletShapeUnman;
339 BulletShapeUnman removeShapeu = removeShape as BulletShapeUnman;
340 BSAPICPP.RemoveChildShapeFromCompoundShape2(shapeu.ptr, removeShapeu.ptr);
341}
342
343public override void UpdateChildTransform(BulletShape pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb)
344{
345 BulletShapeUnman shapeu = pShape as BulletShapeUnman;
346 BSAPICPP.UpdateChildTransform2(shapeu.ptr, childIndex, pos, rot, shouldRecalculateLocalAabb);
347}
348
349public override void RecalculateCompoundShapeLocalAabb(BulletShape shape)
350{
351 BulletShapeUnman shapeu = shape as BulletShapeUnman;
352 BSAPICPP.RecalculateCompoundShapeLocalAabb2(shapeu.ptr);
353}
354
355public override BulletShape DuplicateCollisionShape(BulletWorld world, BulletShape srcShape, uint id)
356{
357 BulletWorldUnman worldu = world as BulletWorldUnman;
358 BulletShapeUnman srcShapeu = srcShape as BulletShapeUnman;
359 return new BulletShapeUnman(BSAPICPP.DuplicateCollisionShape2(worldu.ptr, srcShapeu.ptr, id), srcShape.type);
360}
361
362public override bool DeleteCollisionShape(BulletWorld world, BulletShape shape)
363{
364 BulletWorldUnman worldu = world as BulletWorldUnman;
365 BulletShapeUnman shapeu = shape as BulletShapeUnman;
366 return BSAPICPP.DeleteCollisionShape2(worldu.ptr, shapeu.ptr);
367}
368
369public override CollisionObjectTypes GetBodyType(BulletBody obj)
370{
371 BulletBodyUnman bodyu = obj as BulletBodyUnman;
372 return (CollisionObjectTypes)BSAPICPP.GetBodyType2(bodyu.ptr);
373}
374
375public override BulletBody CreateBodyFromShape(BulletWorld world, BulletShape shape, uint id, Vector3 pos, Quaternion rot)
376{
377 BulletWorldUnman worldu = world as BulletWorldUnman;
378 BulletShapeUnman shapeu = shape as BulletShapeUnman;
379 return new BulletBodyUnman(id, BSAPICPP.CreateBodyFromShape2(worldu.ptr, shapeu.ptr, id, pos, rot));
380}
381
382public override BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, uint id, Vector3 pos, Quaternion rot)
383{
384 BulletShapeUnman shapeu = shape as BulletShapeUnman;
385 return new BulletBodyUnman(id, BSAPICPP.CreateBodyWithDefaultMotionState2(shapeu.ptr, id, pos, rot));
386}
387
388public override BulletBody CreateGhostFromShape(BulletWorld world, BulletShape shape, uint id, Vector3 pos, Quaternion rot)
389{
390 BulletWorldUnman worldu = world as BulletWorldUnman;
391 BulletShapeUnman shapeu = shape as BulletShapeUnman;
392 return new BulletBodyUnman(id, BSAPICPP.CreateGhostFromShape2(worldu.ptr, shapeu.ptr, id, pos, rot));
393}
394
395public override void DestroyObject(BulletWorld world, BulletBody obj)
396{
397 BulletWorldUnman worldu = world as BulletWorldUnman;
398 BulletBodyUnman bodyu = obj as BulletBodyUnman;
399 BSAPICPP.DestroyObject2(worldu.ptr, bodyu.ptr);
400}
401
402// =====================================================================================
403// Terrain creation and helper routines
404public override BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin)
405{
406 return new BulletShapeUnman(BSAPICPP.CreateGroundPlaneShape2(id, height, collisionMargin), BSPhysicsShapeType.SHAPE_GROUNDPLANE);
407}
408
409public override BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap,
410 float scaleFactor, float collisionMargin)
411{
412 return new BulletShapeUnman(BSAPICPP.CreateTerrainShape2(id, size, minHeight, maxHeight, heightMap, scaleFactor, collisionMargin),
413 BSPhysicsShapeType.SHAPE_TERRAIN);
414}
415
416// =====================================================================================
417// Constraint creation and helper routines
418public override BulletConstraint Create6DofConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
419 Vector3 frame1loc, Quaternion frame1rot,
420 Vector3 frame2loc, Quaternion frame2rot,
421 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
422{
423 BulletWorldUnman worldu = world as BulletWorldUnman;
424 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
425 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
426 return new BulletConstraintUnman(BSAPICPP.Create6DofConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, frame1loc, frame1rot,
427 frame2loc, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
428}
429
430public override BulletConstraint Create6DofConstraintToPoint(BulletWorld world, BulletBody obj1, BulletBody obj2,
431 Vector3 joinPoint,
432 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
433{
434 BulletWorldUnman worldu = world as BulletWorldUnman;
435 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
436 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
437 return new BulletConstraintUnman(BSAPICPP.Create6DofConstraintToPoint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr,
438 joinPoint, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
439}
440
441public override BulletConstraint Create6DofConstraintFixed(BulletWorld world, BulletBody obj1,
442 Vector3 frameInBloc, Quaternion frameInBrot,
443 bool useLinearReferenceFrameB, bool disableCollisionsBetweenLinkedBodies)
444{
445 BulletWorldUnman worldu = world as BulletWorldUnman;
446 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
447 return new BulletConstraintUnman(BSAPICPP.Create6DofConstraintFixed2(worldu.ptr, bodyu1.ptr,
448 frameInBloc, frameInBrot, useLinearReferenceFrameB, disableCollisionsBetweenLinkedBodies));
449}
450
451public override BulletConstraint Create6DofSpringConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
452 Vector3 frame1loc, Quaternion frame1rot,
453 Vector3 frame2loc, Quaternion frame2rot,
454 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
455{
456 BulletWorldUnman worldu = world as BulletWorldUnman;
457 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
458 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
459 return new BulletConstraintUnman(BSAPICPP.Create6DofSpringConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, frame1loc, frame1rot,
460 frame2loc, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
461}
462
463public override BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
464 Vector3 pivotinA, Vector3 pivotinB,
465 Vector3 axisInA, Vector3 axisInB,
466 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
467{
468 BulletWorldUnman worldu = world as BulletWorldUnman;
469 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
470 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
471 return new BulletConstraintUnman(BSAPICPP.CreateHingeConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr,
472 pivotinA, pivotinB, axisInA, axisInB, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
473}
474
475public override BulletConstraint CreateSliderConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
476 Vector3 frame1loc, Quaternion frame1rot,
477 Vector3 frame2loc, Quaternion frame2rot,
478 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
479{
480 BulletWorldUnman worldu = world as BulletWorldUnman;
481 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
482 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
483 return new BulletConstraintUnman(BSAPICPP.CreateSliderConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, frame1loc, frame1rot,
484 frame2loc, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
485}
486
487public override BulletConstraint CreateConeTwistConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
488 Vector3 frame1loc, Quaternion frame1rot,
489 Vector3 frame2loc, Quaternion frame2rot,
490 bool disableCollisionsBetweenLinkedBodies)
491{
492 BulletWorldUnman worldu = world as BulletWorldUnman;
493 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
494 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
495 return new BulletConstraintUnman(BSAPICPP.CreateConeTwistConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, frame1loc, frame1rot,
496 frame2loc, frame2rot, disableCollisionsBetweenLinkedBodies));
497}
498
499public override BulletConstraint CreateGearConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
500 Vector3 axisInA, Vector3 axisInB,
501 float ratio, bool disableCollisionsBetweenLinkedBodies)
502{
503 BulletWorldUnman worldu = world as BulletWorldUnman;
504 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
505 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
506 return new BulletConstraintUnman(BSAPICPP.CreateGearConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, axisInA, axisInB,
507 ratio, disableCollisionsBetweenLinkedBodies));
508}
509
510public override BulletConstraint CreatePoint2PointConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
511 Vector3 pivotInA, Vector3 pivotInB,
512 bool disableCollisionsBetweenLinkedBodies)
513{
514 BulletWorldUnman worldu = world as BulletWorldUnman;
515 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
516 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
517 return new BulletConstraintUnman(BSAPICPP.CreatePoint2PointConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, pivotInA, pivotInB,
518 disableCollisionsBetweenLinkedBodies));
519}
520
521public override void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse)
522{
523 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
524 BSAPICPP.SetConstraintEnable2(constrainu.ptr, numericTrueFalse);
525}
526
527public override void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations)
528{
529 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
530 BSAPICPP.SetConstraintNumSolverIterations2(constrainu.ptr, iterations);
531}
532
533public override bool SetFrames(BulletConstraint constrain,
534 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot)
535{
536 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
537 return BSAPICPP.SetFrames2(constrainu.ptr, frameA, frameArot, frameB, frameBrot);
538}
539
540public override bool SetLinearLimits(BulletConstraint constrain, Vector3 low, Vector3 hi)
541{
542 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
543 return BSAPICPP.SetLinearLimits2(constrainu.ptr, low, hi);
544}
545
546public override bool SetAngularLimits(BulletConstraint constrain, Vector3 low, Vector3 hi)
547{
548 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
549 return BSAPICPP.SetAngularLimits2(constrainu.ptr, low, hi);
550}
551
552public override bool UseFrameOffset(BulletConstraint constrain, float enable)
553{
554 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
555 return BSAPICPP.UseFrameOffset2(constrainu.ptr, enable);
556}
557
558public override bool TranslationalLimitMotor(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce)
559{
560 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
561 return BSAPICPP.TranslationalLimitMotor2(constrainu.ptr, enable, targetVel, maxMotorForce);
562}
563
564public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold)
565{
566 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
567 return BSAPICPP.SetBreakingImpulseThreshold2(constrainu.ptr, threshold);
568}
569
570public override bool CalculateTransforms(BulletConstraint constrain)
571{
572 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
573 return BSAPICPP.CalculateTransforms2(constrainu.ptr);
574}
575
576public override bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis)
577{
578 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
579 return BSAPICPP.SetConstraintParam2(constrainu.ptr, paramIndex, value, axis);
580}
581
582public override bool DestroyConstraint(BulletWorld world, BulletConstraint constrain)
583{
584 BulletWorldUnman worldu = world as BulletWorldUnman;
585 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
586 return BSAPICPP.DestroyConstraint2(worldu.ptr, constrainu.ptr);
587}
588
589// =====================================================================================
590// btCollisionWorld entries
591public override void UpdateSingleAabb(BulletWorld world, BulletBody obj)
592{
593 BulletWorldUnman worldu = world as BulletWorldUnman;
594 BulletBodyUnman bodyu = obj as BulletBodyUnman;
595 BSAPICPP.UpdateSingleAabb2(worldu.ptr, bodyu.ptr);
596}
597
598public override void UpdateAabbs(BulletWorld world)
599{
600 BulletWorldUnman worldu = world as BulletWorldUnman;
601 BSAPICPP.UpdateAabbs2(worldu.ptr);
602}
603
604public override bool GetForceUpdateAllAabbs(BulletWorld world)
605{
606 BulletWorldUnman worldu = world as BulletWorldUnman;
607 return BSAPICPP.GetForceUpdateAllAabbs2(worldu.ptr);
608}
609
610public override void SetForceUpdateAllAabbs(BulletWorld world, bool force)
611{
612 BulletWorldUnman worldu = world as BulletWorldUnman;
613 BSAPICPP.SetForceUpdateAllAabbs2(worldu.ptr, force);
614}
615
616// =====================================================================================
617// btDynamicsWorld entries
618public override bool AddObjectToWorld(BulletWorld world, BulletBody obj)
619{
620 BulletWorldUnman worldu = world as BulletWorldUnman;
621 BulletBodyUnman bodyu = obj as BulletBodyUnman;
622
623 // Bullet resets several variables when an object is added to the world.
624 // Gravity is reset to world default depending on the static/dynamic
625 // type. Of course, the collision flags in the broadphase proxy are initialized to default.
626 Vector3 origGrav = BSAPICPP.GetGravity2(bodyu.ptr);
627
628 bool ret = BSAPICPP.AddObjectToWorld2(worldu.ptr, bodyu.ptr);
629
630 if (ret)
631 {
632 BSAPICPP.SetGravity2(bodyu.ptr, origGrav);
633 obj.ApplyCollisionMask(world.physicsScene);
634 }
635 return ret;
636}
637
638public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj)
639{
640 BulletWorldUnman worldu = world as BulletWorldUnman;
641 BulletBodyUnman bodyu = obj as BulletBodyUnman;
642 return BSAPICPP.RemoveObjectFromWorld2(worldu.ptr, bodyu.ptr);
643}
644
645public override bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects)
646{
647 BulletWorldUnman worldu = world as BulletWorldUnman;
648 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
649 return BSAPICPP.AddConstraintToWorld2(worldu.ptr, constrainu.ptr, disableCollisionsBetweenLinkedObjects);
650}
651
652public override bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain)
653{
654 BulletWorldUnman worldu = world as BulletWorldUnman;
655 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
656 return BSAPICPP.RemoveConstraintFromWorld2(worldu.ptr, constrainu.ptr);
657}
658// =====================================================================================
659// btCollisionObject entries
660public override Vector3 GetAnisotripicFriction(BulletConstraint constrain)
661{
662 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
663 return BSAPICPP.GetAnisotripicFriction2(constrainu.ptr);
664}
665
666public override Vector3 SetAnisotripicFriction(BulletConstraint constrain, Vector3 frict)
667{
668 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
669 return BSAPICPP.SetAnisotripicFriction2(constrainu.ptr, frict);
670}
671
672public override bool HasAnisotripicFriction(BulletConstraint constrain)
673{
674 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
675 return BSAPICPP.HasAnisotripicFriction2(constrainu.ptr);
676}
677
678public override void SetContactProcessingThreshold(BulletBody obj, float val)
679{
680 BulletBodyUnman bodyu = obj as BulletBodyUnman;
681 BSAPICPP.SetContactProcessingThreshold2(bodyu.ptr, val);
682}
683
684public override float GetContactProcessingThreshold(BulletBody obj)
685{
686 BulletBodyUnman bodyu = obj as BulletBodyUnman;
687 return BSAPICPP.GetContactProcessingThreshold2(bodyu.ptr);
688}
689
690public override bool IsStaticObject(BulletBody obj)
691{
692 BulletBodyUnman bodyu = obj as BulletBodyUnman;
693 return BSAPICPP.IsStaticObject2(bodyu.ptr);
694}
695
696public override bool IsKinematicObject(BulletBody obj)
697{
698 BulletBodyUnman bodyu = obj as BulletBodyUnman;
699 return BSAPICPP.IsKinematicObject2(bodyu.ptr);
700}
701
702public override bool IsStaticOrKinematicObject(BulletBody obj)
703{
704 BulletBodyUnman bodyu = obj as BulletBodyUnman;
705 return BSAPICPP.IsStaticOrKinematicObject2(bodyu.ptr);
706}
707
708public override bool HasContactResponse(BulletBody obj)
709{
710 BulletBodyUnman bodyu = obj as BulletBodyUnman;
711 return BSAPICPP.HasContactResponse2(bodyu.ptr);
712}
713
714public override void SetCollisionShape(BulletWorld world, BulletBody obj, BulletShape shape)
715{
716 BulletWorldUnman worldu = world as BulletWorldUnman;
717 BulletBodyUnman bodyu = obj as BulletBodyUnman;
718 BulletShapeUnman shapeu = shape as BulletShapeUnman;
719 if (worldu != null && bodyu != null)
720 {
721 // Special case to allow the caller to zero out the reference to any physical shape
722 if (shapeu != null)
723 BSAPICPP.SetCollisionShape2(worldu.ptr, bodyu.ptr, shapeu.ptr);
724 else
725 BSAPICPP.SetCollisionShape2(worldu.ptr, bodyu.ptr, IntPtr.Zero);
726 }
727}
728
729public override BulletShape GetCollisionShape(BulletBody obj)
730{
731 BulletBodyUnman bodyu = obj as BulletBodyUnman;
732 return new BulletShapeUnman(BSAPICPP.GetCollisionShape2(bodyu.ptr), BSPhysicsShapeType.SHAPE_UNKNOWN);
733}
734
735public override int GetActivationState(BulletBody obj)
736{
737 BulletBodyUnman bodyu = obj as BulletBodyUnman;
738 return BSAPICPP.GetActivationState2(bodyu.ptr);
739}
740
741public override void SetActivationState(BulletBody obj, int state)
742{
743 BulletBodyUnman bodyu = obj as BulletBodyUnman;
744 BSAPICPP.SetActivationState2(bodyu.ptr, state);
745}
746
747public override void SetDeactivationTime(BulletBody obj, float dtime)
748{
749 BulletBodyUnman bodyu = obj as BulletBodyUnman;
750 BSAPICPP.SetDeactivationTime2(bodyu.ptr, dtime);
751}
752
753public override float GetDeactivationTime(BulletBody obj)
754{
755 BulletBodyUnman bodyu = obj as BulletBodyUnman;
756 return BSAPICPP.GetDeactivationTime2(bodyu.ptr);
757}
758
759public override void ForceActivationState(BulletBody obj, ActivationState state)
760{
761 BulletBodyUnman bodyu = obj as BulletBodyUnman;
762 BSAPICPP.ForceActivationState2(bodyu.ptr, state);
763}
764
765public override void Activate(BulletBody obj, bool forceActivation)
766{
767 BulletBodyUnman bodyu = obj as BulletBodyUnman;
768 BSAPICPP.Activate2(bodyu.ptr, forceActivation);
769}
770
771public override bool IsActive(BulletBody obj)
772{
773 BulletBodyUnman bodyu = obj as BulletBodyUnman;
774 return BSAPICPP.IsActive2(bodyu.ptr);
775}
776
777public override void SetRestitution(BulletBody obj, float val)
778{
779 BulletBodyUnman bodyu = obj as BulletBodyUnman;
780 BSAPICPP.SetRestitution2(bodyu.ptr, val);
781}
782
783public override float GetRestitution(BulletBody obj)
784{
785 BulletBodyUnman bodyu = obj as BulletBodyUnman;
786 return BSAPICPP.GetRestitution2(bodyu.ptr);
787}
788
789public override void SetFriction(BulletBody obj, float val)
790{
791 BulletBodyUnman bodyu = obj as BulletBodyUnman;
792 BSAPICPP.SetFriction2(bodyu.ptr, val);
793}
794
795public override float GetFriction(BulletBody obj)
796{
797 BulletBodyUnman bodyu = obj as BulletBodyUnman;
798 return BSAPICPP.GetFriction2(bodyu.ptr);
799}
800
801public override Vector3 GetPosition(BulletBody obj)
802{
803 BulletBodyUnman bodyu = obj as BulletBodyUnman;
804 return BSAPICPP.GetPosition2(bodyu.ptr);
805}
806
807public override Quaternion GetOrientation(BulletBody obj)
808{
809 BulletBodyUnman bodyu = obj as BulletBodyUnman;
810 return BSAPICPP.GetOrientation2(bodyu.ptr);
811}
812
813public override void SetTranslation(BulletBody obj, Vector3 position, Quaternion rotation)
814{
815 BulletBodyUnman bodyu = obj as BulletBodyUnman;
816 BSAPICPP.SetTranslation2(bodyu.ptr, position, rotation);
817}
818
819 /*
820public override IntPtr GetBroadphaseHandle(BulletBody obj)
821{
822 BulletBodyUnman bodyu = obj as BulletBodyUnman;
823 return BSAPICPP.GetBroadphaseHandle2(bodyu.ptr);
824}
825
826public override void SetBroadphaseHandle(BulletBody obj, IntPtr handle)
827{
828 BulletBodyUnman bodyu = obj as BulletBodyUnman;
829 BSAPICPP.SetUserPointer2(bodyu.ptr, handle);
830}
831 */
832
833public override void SetInterpolationLinearVelocity(BulletBody obj, Vector3 vel)
834{
835 BulletBodyUnman bodyu = obj as BulletBodyUnman;
836 BSAPICPP.SetInterpolationLinearVelocity2(bodyu.ptr, vel);
837}
838
839public override void SetInterpolationAngularVelocity(BulletBody obj, Vector3 vel)
840{
841 BulletBodyUnman bodyu = obj as BulletBodyUnman;
842 BSAPICPP.SetInterpolationAngularVelocity2(bodyu.ptr, vel);
843}
844
845public override void SetInterpolationVelocity(BulletBody obj, Vector3 linearVel, Vector3 angularVel)
846{
847 BulletBodyUnman bodyu = obj as BulletBodyUnman;
848 BSAPICPP.SetInterpolationVelocity2(bodyu.ptr, linearVel, angularVel);
849}
850
851public override float GetHitFraction(BulletBody obj)
852{
853 BulletBodyUnman bodyu = obj as BulletBodyUnman;
854 return BSAPICPP.GetHitFraction2(bodyu.ptr);
855}
856
857public override void SetHitFraction(BulletBody obj, float val)
858{
859 BulletBodyUnman bodyu = obj as BulletBodyUnman;
860 BSAPICPP.SetHitFraction2(bodyu.ptr, val);
861}
862
863public override CollisionFlags GetCollisionFlags(BulletBody obj)
864{
865 BulletBodyUnman bodyu = obj as BulletBodyUnman;
866 return BSAPICPP.GetCollisionFlags2(bodyu.ptr);
867}
868
869public override CollisionFlags SetCollisionFlags(BulletBody obj, CollisionFlags flags)
870{
871 BulletBodyUnman bodyu = obj as BulletBodyUnman;
872 return BSAPICPP.SetCollisionFlags2(bodyu.ptr, flags);
873}
874
875public override CollisionFlags AddToCollisionFlags(BulletBody obj, CollisionFlags flags)
876{
877 BulletBodyUnman bodyu = obj as BulletBodyUnman;
878 return BSAPICPP.AddToCollisionFlags2(bodyu.ptr, flags);
879}
880
881public override CollisionFlags RemoveFromCollisionFlags(BulletBody obj, CollisionFlags flags)
882{
883 BulletBodyUnman bodyu = obj as BulletBodyUnman;
884 return BSAPICPP.RemoveFromCollisionFlags2(bodyu.ptr, flags);
885}
886
887public override float GetCcdMotionThreshold(BulletBody obj)
888{
889 BulletBodyUnman bodyu = obj as BulletBodyUnman;
890 return BSAPICPP.GetCcdMotionThreshold2(bodyu.ptr);
891}
892
893
894public override void SetCcdMotionThreshold(BulletBody obj, float val)
895{
896 BulletBodyUnman bodyu = obj as BulletBodyUnman;
897 BSAPICPP.SetCcdMotionThreshold2(bodyu.ptr, val);
898}
899
900public override float GetCcdSweptSphereRadius(BulletBody obj)
901{
902 BulletBodyUnman bodyu = obj as BulletBodyUnman;
903 return BSAPICPP.GetCcdSweptSphereRadius2(bodyu.ptr);
904}
905
906public override void SetCcdSweptSphereRadius(BulletBody obj, float val)
907{
908 BulletBodyUnman bodyu = obj as BulletBodyUnman;
909 BSAPICPP.SetCcdSweptSphereRadius2(bodyu.ptr, val);
910}
911
912public override IntPtr GetUserPointer(BulletBody obj)
913{
914 BulletBodyUnman bodyu = obj as BulletBodyUnman;
915 return BSAPICPP.GetUserPointer2(bodyu.ptr);
916}
917
918public override void SetUserPointer(BulletBody obj, IntPtr val)
919{
920 BulletBodyUnman bodyu = obj as BulletBodyUnman;
921 BSAPICPP.SetUserPointer2(bodyu.ptr, val);
922}
923
924// =====================================================================================
925// btRigidBody entries
926public override void ApplyGravity(BulletBody obj)
927{
928 BulletBodyUnman bodyu = obj as BulletBodyUnman;
929 BSAPICPP.ApplyGravity2(bodyu.ptr);
930}
931
932public override void SetGravity(BulletBody obj, Vector3 val)
933{
934 BulletBodyUnman bodyu = obj as BulletBodyUnman;
935 BSAPICPP.SetGravity2(bodyu.ptr, val);
936}
937
938public override Vector3 GetGravity(BulletBody obj)
939{
940 BulletBodyUnman bodyu = obj as BulletBodyUnman;
941 return BSAPICPP.GetGravity2(bodyu.ptr);
942}
943
944public override void SetDamping(BulletBody obj, float lin_damping, float ang_damping)
945{
946 BulletBodyUnman bodyu = obj as BulletBodyUnman;
947 BSAPICPP.SetDamping2(bodyu.ptr, lin_damping, ang_damping);
948}
949
950public override void SetLinearDamping(BulletBody obj, float lin_damping)
951{
952 BulletBodyUnman bodyu = obj as BulletBodyUnman;
953 BSAPICPP.SetLinearDamping2(bodyu.ptr, lin_damping);
954}
955
956public override void SetAngularDamping(BulletBody obj, float ang_damping)
957{
958 BulletBodyUnman bodyu = obj as BulletBodyUnman;
959 BSAPICPP.SetAngularDamping2(bodyu.ptr, ang_damping);
960}
961
962public override float GetLinearDamping(BulletBody obj)
963{
964 BulletBodyUnman bodyu = obj as BulletBodyUnman;
965 return BSAPICPP.GetLinearDamping2(bodyu.ptr);
966}
967
968public override float GetAngularDamping(BulletBody obj)
969{
970 BulletBodyUnman bodyu = obj as BulletBodyUnman;
971 return BSAPICPP.GetAngularDamping2(bodyu.ptr);
972}
973
974public override float GetLinearSleepingThreshold(BulletBody obj)
975{
976 BulletBodyUnman bodyu = obj as BulletBodyUnman;
977 return BSAPICPP.GetLinearSleepingThreshold2(bodyu.ptr);
978}
979
980public override void ApplyDamping(BulletBody obj, float timeStep)
981{
982 BulletBodyUnman bodyu = obj as BulletBodyUnman;
983 BSAPICPP.ApplyDamping2(bodyu.ptr, timeStep);
984}
985
986public override void SetMassProps(BulletBody obj, float mass, Vector3 inertia)
987{
988 BulletBodyUnman bodyu = obj as BulletBodyUnman;
989 BSAPICPP.SetMassProps2(bodyu.ptr, mass, inertia);
990}
991
992public override Vector3 GetLinearFactor(BulletBody obj)
993{
994 BulletBodyUnman bodyu = obj as BulletBodyUnman;
995 return BSAPICPP.GetLinearFactor2(bodyu.ptr);
996}
997
998public override void SetLinearFactor(BulletBody obj, Vector3 factor)
999{
1000 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1001 BSAPICPP.SetLinearFactor2(bodyu.ptr, factor);
1002}
1003
1004public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot)
1005{
1006 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1007 BSAPICPP.SetCenterOfMassByPosRot2(bodyu.ptr, pos, rot);
1008}
1009
1010// Add a force to the object as if its mass is one.
1011// Deep down in Bullet: m_totalForce += force*m_linearFactor;
1012public override void ApplyCentralForce(BulletBody obj, Vector3 force)
1013{
1014 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1015 BSAPICPP.ApplyCentralForce2(bodyu.ptr, force);
1016}
1017
1018// Set the force being applied to the object as if its mass is one.
1019public override void SetObjectForce(BulletBody obj, Vector3 force)
1020{
1021 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1022 BSAPICPP.SetObjectForce2(bodyu.ptr, force);
1023}
1024
1025public override Vector3 GetTotalForce(BulletBody obj)
1026{
1027 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1028 return BSAPICPP.GetTotalForce2(bodyu.ptr);
1029}
1030
1031public override Vector3 GetTotalTorque(BulletBody obj)
1032{
1033 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1034 return BSAPICPP.GetTotalTorque2(bodyu.ptr);
1035}
1036
1037public override Vector3 GetInvInertiaDiagLocal(BulletBody obj)
1038{
1039 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1040 return BSAPICPP.GetInvInertiaDiagLocal2(bodyu.ptr);
1041}
1042
1043public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert)
1044{
1045 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1046 BSAPICPP.SetInvInertiaDiagLocal2(bodyu.ptr, inert);
1047}
1048
1049public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold)
1050{
1051 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1052 BSAPICPP.SetSleepingThresholds2(bodyu.ptr, lin_threshold, ang_threshold);
1053}
1054
1055// Deep down in Bullet: m_totalTorque += torque*m_angularFactor;
1056public override void ApplyTorque(BulletBody obj, Vector3 torque)
1057{
1058 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1059 BSAPICPP.ApplyTorque2(bodyu.ptr, torque);
1060}
1061
1062// Apply force at the given point. Will add torque to the object.
1063// Deep down in Bullet: applyCentralForce(force);
1064// applyTorque(rel_pos.cross(force*m_linearFactor));
1065public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos)
1066{
1067 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1068 BSAPICPP.ApplyForce2(bodyu.ptr, force, pos);
1069}
1070
1071// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
1072// Deep down in Bullet: m_linearVelocity += impulse *m_linearFactor * m_inverseMass;
1073public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp)
1074{
1075 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1076 BSAPICPP.ApplyCentralImpulse2(bodyu.ptr, imp);
1077}
1078
1079// Apply impulse to the object's torque. Force is scaled by object's mass.
1080// Deep down in Bullet: m_angularVelocity += m_invInertiaTensorWorld * torque * m_angularFactor;
1081public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp)
1082{
1083 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1084 BSAPICPP.ApplyTorqueImpulse2(bodyu.ptr, imp);
1085}
1086
1087// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
1088// Deep down in Bullet: applyCentralImpulse(impulse);
1089// applyTorqueImpulse(rel_pos.cross(impulse*m_linearFactor));
1090public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos)
1091{
1092 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1093 BSAPICPP.ApplyImpulse2(bodyu.ptr, imp, pos);
1094}
1095
1096public override void ClearForces(BulletBody obj)
1097{
1098 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1099 BSAPICPP.ClearForces2(bodyu.ptr);
1100}
1101
1102public override void ClearAllForces(BulletBody obj)
1103{
1104 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1105 BSAPICPP.ClearAllForces2(bodyu.ptr);
1106}
1107
1108public override void UpdateInertiaTensor(BulletBody obj)
1109{
1110 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1111 BSAPICPP.UpdateInertiaTensor2(bodyu.ptr);
1112}
1113
1114public override Vector3 GetLinearVelocity(BulletBody obj)
1115{
1116 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1117 return BSAPICPP.GetLinearVelocity2(bodyu.ptr);
1118}
1119
1120public override Vector3 GetAngularVelocity(BulletBody obj)
1121{
1122 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1123 return BSAPICPP.GetAngularVelocity2(bodyu.ptr);
1124}
1125
1126public override void SetLinearVelocity(BulletBody obj, Vector3 vel)
1127{
1128 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1129 BSAPICPP.SetLinearVelocity2(bodyu.ptr, vel);
1130}
1131
1132public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity)
1133{
1134 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1135 BSAPICPP.SetAngularVelocity2(bodyu.ptr, angularVelocity);
1136}
1137
1138public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos)
1139{
1140 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1141 return BSAPICPP.GetVelocityInLocalPoint2(bodyu.ptr, pos);
1142}
1143
1144public override void Translate(BulletBody obj, Vector3 trans)
1145{
1146 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1147 BSAPICPP.Translate2(bodyu.ptr, trans);
1148}
1149
1150public override void UpdateDeactivation(BulletBody obj, float timeStep)
1151{
1152 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1153 BSAPICPP.UpdateDeactivation2(bodyu.ptr, timeStep);
1154}
1155
1156public override bool WantsSleeping(BulletBody obj)
1157{
1158 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1159 return BSAPICPP.WantsSleeping2(bodyu.ptr);
1160}
1161
1162public override void SetAngularFactor(BulletBody obj, float factor)
1163{
1164 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1165 BSAPICPP.SetAngularFactor2(bodyu.ptr, factor);
1166}
1167
1168public override void SetAngularFactorV(BulletBody obj, Vector3 factor)
1169{
1170 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1171 BSAPICPP.SetAngularFactorV2(bodyu.ptr, factor);
1172}
1173
1174public override Vector3 GetAngularFactor(BulletBody obj)
1175{
1176 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1177 return BSAPICPP.GetAngularFactor2(bodyu.ptr);
1178}
1179
1180public override bool IsInWorld(BulletWorld world, BulletBody obj)
1181{
1182 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1183 return BSAPICPP.IsInWorld2(bodyu.ptr);
1184}
1185
1186public override void AddConstraintRef(BulletBody obj, BulletConstraint constrain)
1187{
1188 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1189 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
1190 BSAPICPP.AddConstraintRef2(bodyu.ptr, constrainu.ptr);
1191}
1192
1193public override void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain)
1194{
1195 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1196 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
1197 BSAPICPP.RemoveConstraintRef2(bodyu.ptr, constrainu.ptr);
1198}
1199
1200public override BulletConstraint GetConstraintRef(BulletBody obj, int index)
1201{
1202 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1203 return new BulletConstraintUnman(BSAPICPP.GetConstraintRef2(bodyu.ptr, index));
1204}
1205
1206public override int GetNumConstraintRefs(BulletBody obj)
1207{
1208 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1209 return BSAPICPP.GetNumConstraintRefs2(bodyu.ptr);
1210}
1211
1212public override bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask)
1213{
1214 BulletBodyUnman bodyu = body as BulletBodyUnman;
1215 return BSAPICPP.SetCollisionGroupMask2(bodyu.ptr, filter, mask);
1216}
1217
1218// =====================================================================================
1219// btCollisionShape entries
1220
1221public override float GetAngularMotionDisc(BulletShape shape)
1222{
1223 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1224 return BSAPICPP.GetAngularMotionDisc2(shapeu.ptr);
1225}
1226
1227public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor)
1228{
1229 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1230 return BSAPICPP.GetContactBreakingThreshold2(shapeu.ptr, defaultFactor);
1231}
1232
1233public override bool IsPolyhedral(BulletShape shape)
1234{
1235 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1236 return BSAPICPP.IsPolyhedral2(shapeu.ptr);
1237}
1238
1239public override bool IsConvex2d(BulletShape shape)
1240{
1241 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1242 return BSAPICPP.IsConvex2d2(shapeu.ptr);
1243}
1244
1245public override bool IsConvex(BulletShape shape)
1246{
1247 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1248 return BSAPICPP.IsConvex2(shapeu.ptr);
1249}
1250
1251public override bool IsNonMoving(BulletShape shape)
1252{
1253 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1254 return BSAPICPP.IsNonMoving2(shapeu.ptr);
1255}
1256
1257public override bool IsConcave(BulletShape shape)
1258{
1259 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1260 return BSAPICPP.IsConcave2(shapeu.ptr);
1261}
1262
1263public override bool IsCompound(BulletShape shape)
1264{
1265 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1266 return BSAPICPP.IsCompound2(shapeu.ptr);
1267}
1268
1269public override bool IsSoftBody(BulletShape shape)
1270{
1271 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1272 return BSAPICPP.IsSoftBody2(shapeu.ptr);
1273}
1274
1275public override bool IsInfinite(BulletShape shape)
1276{
1277 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1278 return BSAPICPP.IsInfinite2(shapeu.ptr);
1279}
1280
1281public override void SetLocalScaling(BulletShape shape, Vector3 scale)
1282{
1283 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1284 BSAPICPP.SetLocalScaling2(shapeu.ptr, scale);
1285}
1286
1287public override Vector3 GetLocalScaling(BulletShape shape)
1288{
1289 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1290 return BSAPICPP.GetLocalScaling2(shapeu.ptr);
1291}
1292
1293public override Vector3 CalculateLocalInertia(BulletShape shape, float mass)
1294{
1295 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1296 return BSAPICPP.CalculateLocalInertia2(shapeu.ptr, mass);
1297}
1298
1299public override int GetShapeType(BulletShape shape)
1300{
1301 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1302 return BSAPICPP.GetShapeType2(shapeu.ptr);
1303}
1304
1305public override void SetMargin(BulletShape shape, float val)
1306{
1307 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1308 BSAPICPP.SetMargin2(shapeu.ptr, val);
1309}
1310
1311public override float GetMargin(BulletShape shape)
1312{
1313 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1314 return BSAPICPP.GetMargin2(shapeu.ptr);
1315}
1316
1317// =====================================================================================
1318// Debugging
1319public override void DumpRigidBody(BulletWorld world, BulletBody collisionObject)
1320{
1321 BulletWorldUnman worldu = world as BulletWorldUnman;
1322 BulletBodyUnman bodyu = collisionObject as BulletBodyUnman;
1323 BSAPICPP.DumpRigidBody2(worldu.ptr, bodyu.ptr);
1324}
1325
1326public override void DumpCollisionShape(BulletWorld world, BulletShape collisionShape)
1327{
1328 BulletWorldUnman worldu = world as BulletWorldUnman;
1329 BulletShapeUnman shapeu = collisionShape as BulletShapeUnman;
1330 BSAPICPP.DumpCollisionShape2(worldu.ptr, shapeu.ptr);
1331}
1332
1333public override void DumpConstraint(BulletWorld world, BulletConstraint constrain)
1334{
1335 BulletWorldUnman worldu = world as BulletWorldUnman;
1336 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
1337 BSAPICPP.DumpConstraint2(worldu.ptr, constrainu.ptr);
1338}
1339
1340public override void DumpActivationInfo(BulletWorld world)
1341{
1342 BulletWorldUnman worldu = world as BulletWorldUnman;
1343 BSAPICPP.DumpActivationInfo2(worldu.ptr);
1344}
1345
1346public override void DumpAllInfo(BulletWorld world)
1347{
1348 BulletWorldUnman worldu = world as BulletWorldUnman;
1349 BSAPICPP.DumpAllInfo2(worldu.ptr);
1350}
1351
1352public override void DumpPhysicsStatistics(BulletWorld world)
1353{
1354 BulletWorldUnman worldu = world as BulletWorldUnman;
1355 BSAPICPP.DumpPhysicsStatistics2(worldu.ptr);
1356}
1357public override void ResetBroadphasePool(BulletWorld world)
1358{
1359 BulletWorldUnman worldu = world as BulletWorldUnman;
1360 BSAPICPP.ResetBroadphasePool(worldu.ptr);
1361}
1362public override void ResetConstraintSolver(BulletWorld world)
1363{
1364 BulletWorldUnman worldu = world as BulletWorldUnman;
1365 BSAPICPP.ResetConstraintSolver(worldu.ptr);
1366}
1367
1368// =====================================================================================
1369// =====================================================================================
1370// =====================================================================================
1371// =====================================================================================
1372// =====================================================================================
1373// The actual interface to the unmanaged code
1374static class BSAPICPP
1375{
1376// ===============================================================================
1377// Link back to the managed code for outputting log messages
1378[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
1379public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
1380
1381// ===============================================================================
1382// Initialization and simulation
1383[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1384public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
1385 int maxCollisions, IntPtr collisionArray,
1386 int maxUpdates, IntPtr updateArray,
1387 DebugLogCallback logRoutine);
1388
1389[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1390public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
1391 out int updatedEntityCount, out int collidersCount);
1392
1393[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1394public static extern void Shutdown2(IntPtr sim);
1395
1396[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1397public static extern bool PushUpdate2(IntPtr obj);
1398
1399[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1400public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
1401
1402// =====================================================================================
1403// Mesh, hull, shape and body creation helper routines
1404[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1405public static extern IntPtr CreateMeshShape2(IntPtr world,
1406 int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
1407 int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices );
1408
1409[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1410public static extern IntPtr CreateHullShape2(IntPtr world,
1411 int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls);
1412
1413[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1414public static extern IntPtr BuildHullShapeFromMesh2(IntPtr world, IntPtr meshShape);
1415
1416[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1417public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData);
1418
1419[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1420public static extern bool IsNativeShape2(IntPtr shape);
1421
1422[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1423public static extern void SetShapeCollisionMargin(IntPtr shape, float margin);
1424
1425[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1426public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale);
1427
1428[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1429public static extern IntPtr CreateCompoundShape2(IntPtr sim, bool enableDynamicAabbTree);
1430
1431[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1432public static extern int GetNumberOfCompoundChildren2(IntPtr cShape);
1433
1434[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1435public static extern void AddChildShapeToCompoundShape2(IntPtr cShape, IntPtr addShape, Vector3 pos, Quaternion rot);
1436
1437[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1438public static extern IntPtr GetChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx);
1439
1440[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1441public static extern IntPtr RemoveChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx);
1442
1443[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1444public static extern void RemoveChildShapeFromCompoundShape2(IntPtr cShape, IntPtr removeShape);
1445
1446[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1447public static extern void UpdateChildTransform2(IntPtr pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb);
1448
1449[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1450public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape);
1451
1452[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1453public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id);
1454
1455[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1456public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
1457
1458[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1459public static extern int GetBodyType2(IntPtr obj);
1460
1461[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1462public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
1463
1464[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1465public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, uint id, Vector3 pos, Quaternion rot);
1466
1467[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1468public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
1469
1470[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1471public static extern void DestroyObject2(IntPtr sim, IntPtr obj);
1472
1473// =====================================================================================
1474// Terrain creation and helper routines
1475[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1476public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin);
1477
1478[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1479public static extern IntPtr CreateTerrainShape2(uint id, Vector3 size, float minHeight, float maxHeight,
1480 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap,
1481 float scaleFactor, float collisionMargin);
1482
1483// =====================================================================================
1484// Constraint creation and helper routines
1485[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1486public static extern IntPtr Create6DofConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1487 Vector3 frame1loc, Quaternion frame1rot,
1488 Vector3 frame2loc, Quaternion frame2rot,
1489 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
1490
1491[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1492public static extern IntPtr Create6DofConstraintToPoint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1493 Vector3 joinPoint,
1494 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
1495
1496[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1497public static extern IntPtr Create6DofConstraintFixed2(IntPtr world, IntPtr obj1,
1498 Vector3 frameInBloc, Quaternion frameInBrot,
1499 bool useLinearReferenceFrameB, bool disableCollisionsBetweenLinkedBodies);
1500
1501[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1502public static extern IntPtr Create6DofSpringConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1503 Vector3 frame1loc, Quaternion frame1rot,
1504 Vector3 frame2loc, Quaternion frame2rot,
1505 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
1506
1507[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1508public static extern IntPtr CreateHingeConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1509 Vector3 pivotinA, Vector3 pivotinB,
1510 Vector3 axisInA, Vector3 axisInB,
1511 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
1512
1513[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1514public static extern IntPtr CreateSliderConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1515 Vector3 frameInAloc, Quaternion frameInArot,
1516 Vector3 frameInBloc, Quaternion frameInBrot,
1517 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
1518
1519[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1520public static extern IntPtr CreateConeTwistConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1521 Vector3 frameInAloc, Quaternion frameInArot,
1522 Vector3 frameInBloc, Quaternion frameInBrot,
1523 bool disableCollisionsBetweenLinkedBodies);
1524
1525[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1526public static extern IntPtr CreateGearConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1527 Vector3 axisInA, Vector3 axisInB,
1528 float ratio, bool disableCollisionsBetweenLinkedBodies);
1529
1530[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1531public static extern IntPtr CreatePoint2PointConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1532 Vector3 pivotInA, Vector3 pivotInB,
1533 bool disableCollisionsBetweenLinkedBodies);
1534
1535
1536[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1537public static extern void SetConstraintEnable2(IntPtr constrain, float numericTrueFalse);
1538
1539[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1540public static extern void SetConstraintNumSolverIterations2(IntPtr constrain, float iterations);
1541
1542[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1543public static extern bool SetFrames2(IntPtr constrain,
1544 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot);
1545
1546[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1547public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
1548
1549[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1550public static extern bool SetAngularLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
1551
1552[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1553public static extern bool UseFrameOffset2(IntPtr constrain, float enable);
1554
1555[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1556public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce);
1557
1558[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1559public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold);
1560
1561[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1562public static extern bool CalculateTransforms2(IntPtr constrain);
1563
1564[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1565public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
1566
1567[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1568public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain);
1569
1570// =====================================================================================
1571// btCollisionWorld entries
1572[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1573public static extern void UpdateSingleAabb2(IntPtr world, IntPtr obj);
1574
1575[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1576public static extern void UpdateAabbs2(IntPtr world);
1577
1578[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1579public static extern bool GetForceUpdateAllAabbs2(IntPtr world);
1580
1581[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1582public static extern void SetForceUpdateAllAabbs2(IntPtr world, bool force);
1583
1584// =====================================================================================
1585// btDynamicsWorld entries
1586[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1587public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj);
1588
1589[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1590public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
1591
1592[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1593public static extern bool AddConstraintToWorld2(IntPtr world, IntPtr constrain, bool disableCollisionsBetweenLinkedObjects);
1594
1595[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1596public static extern bool RemoveConstraintFromWorld2(IntPtr world, IntPtr constrain);
1597// =====================================================================================
1598// btCollisionObject entries
1599[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1600public static extern Vector3 GetAnisotripicFriction2(IntPtr constrain);
1601
1602[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1603public static extern Vector3 SetAnisotripicFriction2(IntPtr constrain, Vector3 frict);
1604
1605[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1606public static extern bool HasAnisotripicFriction2(IntPtr constrain);
1607
1608[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1609public static extern void SetContactProcessingThreshold2(IntPtr obj, float val);
1610
1611[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1612public static extern float GetContactProcessingThreshold2(IntPtr obj);
1613
1614[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1615public static extern bool IsStaticObject2(IntPtr obj);
1616
1617[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1618public static extern bool IsKinematicObject2(IntPtr obj);
1619
1620[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1621public static extern bool IsStaticOrKinematicObject2(IntPtr obj);
1622
1623[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1624public static extern bool HasContactResponse2(IntPtr obj);
1625
1626[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1627public static extern void SetCollisionShape2(IntPtr sim, IntPtr obj, IntPtr shape);
1628
1629[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1630public static extern IntPtr GetCollisionShape2(IntPtr obj);
1631
1632[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1633public static extern int GetActivationState2(IntPtr obj);
1634
1635[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1636public static extern void SetActivationState2(IntPtr obj, int state);
1637
1638[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1639public static extern void SetDeactivationTime2(IntPtr obj, float dtime);
1640
1641[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1642public static extern float GetDeactivationTime2(IntPtr obj);
1643
1644[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1645public static extern void ForceActivationState2(IntPtr obj, ActivationState state);
1646
1647[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1648public static extern void Activate2(IntPtr obj, bool forceActivation);
1649
1650[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1651public static extern bool IsActive2(IntPtr obj);
1652
1653[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1654public static extern void SetRestitution2(IntPtr obj, float val);
1655
1656[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1657public static extern float GetRestitution2(IntPtr obj);
1658
1659[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1660public static extern void SetFriction2(IntPtr obj, float val);
1661
1662[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1663public static extern float GetFriction2(IntPtr obj);
1664
1665 /* Haven't defined the type 'Transform'
1666[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1667public static extern Transform GetWorldTransform2(IntPtr obj);
1668
1669[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1670public static extern void setWorldTransform2(IntPtr obj, Transform trans);
1671 */
1672
1673[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1674public static extern Vector3 GetPosition2(IntPtr obj);
1675
1676[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1677public static extern Quaternion GetOrientation2(IntPtr obj);
1678
1679[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1680public static extern void SetTranslation2(IntPtr obj, Vector3 position, Quaternion rotation);
1681
1682[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1683public static extern IntPtr GetBroadphaseHandle2(IntPtr obj);
1684
1685[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1686public static extern void SetBroadphaseHandle2(IntPtr obj, IntPtr handle);
1687
1688 /*
1689[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1690public static extern Transform GetInterpolationWorldTransform2(IntPtr obj);
1691
1692[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1693public static extern void SetInterpolationWorldTransform2(IntPtr obj, Transform trans);
1694 */
1695
1696[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1697public static extern void SetInterpolationLinearVelocity2(IntPtr obj, Vector3 vel);
1698
1699[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1700public static extern void SetInterpolationAngularVelocity2(IntPtr obj, Vector3 vel);
1701
1702[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1703public static extern void SetInterpolationVelocity2(IntPtr obj, Vector3 linearVel, Vector3 angularVel);
1704
1705[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1706public static extern float GetHitFraction2(IntPtr obj);
1707
1708[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1709public static extern void SetHitFraction2(IntPtr obj, float val);
1710
1711[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1712public static extern CollisionFlags GetCollisionFlags2(IntPtr obj);
1713
1714[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1715public static extern CollisionFlags SetCollisionFlags2(IntPtr obj, CollisionFlags flags);
1716
1717[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1718public static extern CollisionFlags AddToCollisionFlags2(IntPtr obj, CollisionFlags flags);
1719
1720[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1721public static extern CollisionFlags RemoveFromCollisionFlags2(IntPtr obj, CollisionFlags flags);
1722
1723[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1724public static extern float GetCcdMotionThreshold2(IntPtr obj);
1725
1726[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1727public static extern void SetCcdMotionThreshold2(IntPtr obj, float val);
1728
1729[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1730public static extern float GetCcdSweptSphereRadius2(IntPtr obj);
1731
1732[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1733public static extern void SetCcdSweptSphereRadius2(IntPtr obj, float val);
1734
1735[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1736public static extern IntPtr GetUserPointer2(IntPtr obj);
1737
1738[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1739public static extern void SetUserPointer2(IntPtr obj, IntPtr val);
1740
1741// =====================================================================================
1742// btRigidBody entries
1743[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1744public static extern void ApplyGravity2(IntPtr obj);
1745
1746[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1747public static extern void SetGravity2(IntPtr obj, Vector3 val);
1748
1749[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1750public static extern Vector3 GetGravity2(IntPtr obj);
1751
1752[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1753public static extern void SetDamping2(IntPtr obj, float lin_damping, float ang_damping);
1754
1755[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1756public static extern void SetLinearDamping2(IntPtr obj, float lin_damping);
1757
1758[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1759public static extern void SetAngularDamping2(IntPtr obj, float ang_damping);
1760
1761[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1762public static extern float GetLinearDamping2(IntPtr obj);
1763
1764[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1765public static extern float GetAngularDamping2(IntPtr obj);
1766
1767[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1768public static extern float GetLinearSleepingThreshold2(IntPtr obj);
1769
1770[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1771public static extern float GetAngularSleepingThreshold2(IntPtr obj);
1772
1773[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1774public static extern void ApplyDamping2(IntPtr obj, float timeStep);
1775
1776[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1777public static extern void SetMassProps2(IntPtr obj, float mass, Vector3 inertia);
1778
1779[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1780public static extern Vector3 GetLinearFactor2(IntPtr obj);
1781
1782[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1783public static extern void SetLinearFactor2(IntPtr obj, Vector3 factor);
1784
1785 /*
1786[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1787public static extern void SetCenterOfMassTransform2(IntPtr obj, Transform trans);
1788 */
1789
1790[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1791public static extern void SetCenterOfMassByPosRot2(IntPtr obj, Vector3 pos, Quaternion rot);
1792
1793// Add a force to the object as if its mass is one.
1794[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1795public static extern void ApplyCentralForce2(IntPtr obj, Vector3 force);
1796
1797// Set the force being applied to the object as if its mass is one.
1798[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1799public static extern void SetObjectForce2(IntPtr obj, Vector3 force);
1800
1801[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1802public static extern Vector3 GetTotalForce2(IntPtr obj);
1803
1804[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1805public static extern Vector3 GetTotalTorque2(IntPtr obj);
1806
1807[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1808public static extern Vector3 GetInvInertiaDiagLocal2(IntPtr obj);
1809
1810[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1811public static extern void SetInvInertiaDiagLocal2(IntPtr obj, Vector3 inert);
1812
1813[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1814public static extern void SetSleepingThresholds2(IntPtr obj, float lin_threshold, float ang_threshold);
1815
1816[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1817public static extern void ApplyTorque2(IntPtr obj, Vector3 torque);
1818
1819// Apply force at the given point. Will add torque to the object.
1820[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1821public static extern void ApplyForce2(IntPtr obj, Vector3 force, Vector3 pos);
1822
1823// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
1824[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1825public static extern void ApplyCentralImpulse2(IntPtr obj, Vector3 imp);
1826
1827// Apply impulse to the object's torque. Force is scaled by object's mass.
1828[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1829public static extern void ApplyTorqueImpulse2(IntPtr obj, Vector3 imp);
1830
1831// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
1832[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1833public static extern void ApplyImpulse2(IntPtr obj, Vector3 imp, Vector3 pos);
1834
1835[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1836public static extern void ClearForces2(IntPtr obj);
1837
1838[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1839public static extern void ClearAllForces2(IntPtr obj);
1840
1841[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1842public static extern void UpdateInertiaTensor2(IntPtr obj);
1843
1844[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1845public static extern Vector3 GetCenterOfMassPosition2(IntPtr obj);
1846
1847 /*
1848[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1849public static extern Transform GetCenterOfMassTransform2(IntPtr obj);
1850 */
1851
1852[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1853public static extern Vector3 GetLinearVelocity2(IntPtr obj);
1854
1855[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1856public static extern Vector3 GetAngularVelocity2(IntPtr obj);
1857
1858[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1859public static extern void SetLinearVelocity2(IntPtr obj, Vector3 val);
1860
1861[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1862public static extern void SetAngularVelocity2(IntPtr obj, Vector3 angularVelocity);
1863
1864[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1865public static extern Vector3 GetVelocityInLocalPoint2(IntPtr obj, Vector3 pos);
1866
1867[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1868public static extern void Translate2(IntPtr obj, Vector3 trans);
1869
1870[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1871public static extern void UpdateDeactivation2(IntPtr obj, float timeStep);
1872
1873[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1874public static extern bool WantsSleeping2(IntPtr obj);
1875
1876[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1877public static extern void SetAngularFactor2(IntPtr obj, float factor);
1878
1879[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1880public static extern void SetAngularFactorV2(IntPtr obj, Vector3 factor);
1881
1882[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1883public static extern Vector3 GetAngularFactor2(IntPtr obj);
1884
1885[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1886public static extern bool IsInWorld2(IntPtr obj);
1887
1888[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1889public static extern void AddConstraintRef2(IntPtr obj, IntPtr constrain);
1890
1891[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1892public static extern void RemoveConstraintRef2(IntPtr obj, IntPtr constrain);
1893
1894[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1895public static extern IntPtr GetConstraintRef2(IntPtr obj, int index);
1896
1897[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1898public static extern int GetNumConstraintRefs2(IntPtr obj);
1899
1900[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1901public static extern bool SetCollisionGroupMask2(IntPtr body, uint filter, uint mask);
1902
1903// =====================================================================================
1904// btCollisionShape entries
1905
1906[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1907public static extern float GetAngularMotionDisc2(IntPtr shape);
1908
1909[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1910public static extern float GetContactBreakingThreshold2(IntPtr shape, float defaultFactor);
1911
1912[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1913public static extern bool IsPolyhedral2(IntPtr shape);
1914
1915[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1916public static extern bool IsConvex2d2(IntPtr shape);
1917
1918[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1919public static extern bool IsConvex2(IntPtr shape);
1920
1921[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1922public static extern bool IsNonMoving2(IntPtr shape);
1923
1924[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1925public static extern bool IsConcave2(IntPtr shape);
1926
1927[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1928public static extern bool IsCompound2(IntPtr shape);
1929
1930[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1931public static extern bool IsSoftBody2(IntPtr shape);
1932
1933[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1934public static extern bool IsInfinite2(IntPtr shape);
1935
1936[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1937public static extern void SetLocalScaling2(IntPtr shape, Vector3 scale);
1938
1939[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1940public static extern Vector3 GetLocalScaling2(IntPtr shape);
1941
1942[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1943public static extern Vector3 CalculateLocalInertia2(IntPtr shape, float mass);
1944
1945[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1946public static extern int GetShapeType2(IntPtr shape);
1947
1948[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1949public static extern void SetMargin2(IntPtr shape, float val);
1950
1951[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1952public static extern float GetMargin2(IntPtr shape);
1953
1954// =====================================================================================
1955// Debugging
1956[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1957public static extern void DumpRigidBody2(IntPtr sim, IntPtr collisionObject);
1958
1959[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1960public static extern void DumpCollisionShape2(IntPtr sim, IntPtr collisionShape);
1961
1962[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1963public static extern void DumpMapInfo2(IntPtr sim, IntPtr manInfo);
1964
1965[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1966public static extern void DumpConstraint2(IntPtr sim, IntPtr constrain);
1967
1968[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1969public static extern void DumpActivationInfo2(IntPtr sim);
1970
1971[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1972public static extern void DumpAllInfo2(IntPtr sim);
1973
1974[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1975public static extern void DumpPhysicsStatistics2(IntPtr sim);
1976
1977[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1978public static extern void ResetBroadphasePool(IntPtr sim);
1979
1980[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1981public static extern void ResetConstraintSolver(IntPtr sim);
1982
1983}
1984
1985}
1986
1987}