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.cs1839
1 files changed, 0 insertions, 1839 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
deleted file mode 100755
index 8c6e7d6..0000000
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
+++ /dev/null
@@ -1,1839 +0,0 @@
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
217public override bool PushUpdate(BulletBody obj)
218{
219 BulletBodyUnman bodyu = obj as BulletBodyUnman;
220 return BSAPICPP.PushUpdate2(bodyu.ptr);
221}
222
223public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value)
224{
225 BulletWorldUnman worldu = world as BulletWorldUnman;
226 return BSAPICPP.UpdateParameter2(worldu.ptr, localID, parm, value);
227}
228
229// =====================================================================================
230// Mesh, hull, shape and body creation helper routines
231public override BulletShape CreateMeshShape(BulletWorld world,
232 int indicesCount, int[] indices,
233 int verticesCount, float[] vertices)
234{
235 BulletWorldUnman worldu = world as BulletWorldUnman;
236 return new BulletShapeUnman(
237 BSAPICPP.CreateMeshShape2(worldu.ptr, indicesCount, indices, verticesCount, vertices),
238 BSPhysicsShapeType.SHAPE_MESH);
239}
240
241public override BulletShape CreateHullShape(BulletWorld world, int hullCount, float[] hulls)
242{
243 BulletWorldUnman worldu = world as BulletWorldUnman;
244 return new BulletShapeUnman(
245 BSAPICPP.CreateHullShape2(worldu.ptr, hullCount, hulls),
246 BSPhysicsShapeType.SHAPE_HULL);
247}
248
249public override BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape)
250{
251 BulletWorldUnman worldu = world as BulletWorldUnman;
252 BulletShapeUnman shapeu = meshShape as BulletShapeUnman;
253 return new BulletShapeUnman(
254 BSAPICPP.BuildHullShapeFromMesh2(worldu.ptr, shapeu.ptr),
255 BSPhysicsShapeType.SHAPE_HULL);
256}
257
258public override BulletShape BuildNativeShape(BulletWorld world, ShapeData shapeData)
259{
260 BulletWorldUnman worldu = world as BulletWorldUnman;
261 return new BulletShapeUnman(BSAPICPP.BuildNativeShape2(worldu.ptr, shapeData), shapeData.Type);
262}
263
264public override bool IsNativeShape(BulletShape shape)
265{
266 BulletShapeUnman shapeu = shape as BulletShapeUnman;
267 if (shapeu != null && shapeu.HasPhysicalShape)
268 return BSAPICPP.IsNativeShape2(shapeu.ptr);
269 return false;
270}
271
272public override void SetShapeCollisionMargin(BulletShape shape, float margin)
273{
274 BulletShapeUnman shapeu = shape as BulletShapeUnman;
275 if (shapeu != null && shapeu.HasPhysicalShape)
276 BSAPICPP.SetShapeCollisionMargin2(shapeu.ptr, margin);
277}
278
279public override BulletShape BuildCapsuleShape(BulletWorld world, float radius, float height, Vector3 scale)
280{
281 BulletWorldUnman worldu = world as BulletWorldUnman;
282 return new BulletShapeUnman(
283 BSAPICPP.BuildCapsuleShape2(worldu.ptr, radius, height, scale),
284 BSPhysicsShapeType.SHAPE_CAPSULE);
285}
286
287public override BulletShape CreateCompoundShape(BulletWorld world, bool enableDynamicAabbTree)
288{
289 BulletWorldUnman worldu = world as BulletWorldUnman;
290 return new BulletShapeUnman(
291 BSAPICPP.CreateCompoundShape2(worldu.ptr, enableDynamicAabbTree),
292 BSPhysicsShapeType.SHAPE_COMPOUND);
293
294}
295
296public override int GetNumberOfCompoundChildren(BulletShape shape)
297{
298 BulletShapeUnman shapeu = shape as BulletShapeUnman;
299 if (shapeu != null && shapeu.HasPhysicalShape)
300 return BSAPICPP.GetNumberOfCompoundChildren2(shapeu.ptr);
301 return 0;
302}
303
304public override void AddChildShapeToCompoundShape(BulletShape shape, BulletShape addShape, Vector3 pos, Quaternion rot)
305{
306 BulletShapeUnman shapeu = shape as BulletShapeUnman;
307 BulletShapeUnman addShapeu = addShape as BulletShapeUnman;
308 BSAPICPP.AddChildShapeToCompoundShape2(shapeu.ptr, addShapeu.ptr, pos, rot);
309}
310
311public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape shape, int indx)
312{
313 BulletShapeUnman shapeu = shape as BulletShapeUnman;
314 return new BulletShapeUnman(BSAPICPP.GetChildShapeFromCompoundShapeIndex2(shapeu.ptr, indx), BSPhysicsShapeType.SHAPE_UNKNOWN);
315}
316
317public override BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape shape, int indx)
318{
319 BulletShapeUnman shapeu = shape as BulletShapeUnman;
320 return new BulletShapeUnman(BSAPICPP.RemoveChildShapeFromCompoundShapeIndex2(shapeu.ptr, indx), BSPhysicsShapeType.SHAPE_UNKNOWN);
321}
322
323public override void RemoveChildShapeFromCompoundShape(BulletShape shape, BulletShape removeShape)
324{
325 BulletShapeUnman shapeu = shape as BulletShapeUnman;
326 BulletShapeUnman removeShapeu = removeShape as BulletShapeUnman;
327 BSAPICPP.RemoveChildShapeFromCompoundShape2(shapeu.ptr, removeShapeu.ptr);
328}
329
330public override void RecalculateCompoundShapeLocalAabb(BulletShape shape)
331{
332 BulletShapeUnman shapeu = shape as BulletShapeUnman;
333 BSAPICPP.RecalculateCompoundShapeLocalAabb2(shapeu.ptr);
334}
335
336public override BulletShape DuplicateCollisionShape(BulletWorld world, BulletShape srcShape, uint id)
337{
338 BulletWorldUnman worldu = world as BulletWorldUnman;
339 BulletShapeUnman srcShapeu = srcShape as BulletShapeUnman;
340 return new BulletShapeUnman(BSAPICPP.DuplicateCollisionShape2(worldu.ptr, srcShapeu.ptr, id), srcShape.type);
341}
342
343public override bool DeleteCollisionShape(BulletWorld world, BulletShape shape)
344{
345 BulletWorldUnman worldu = world as BulletWorldUnman;
346 BulletShapeUnman shapeu = shape as BulletShapeUnman;
347 return BSAPICPP.DeleteCollisionShape2(worldu.ptr, shapeu.ptr);
348}
349
350public override CollisionObjectTypes GetBodyType(BulletBody obj)
351{
352 BulletBodyUnman bodyu = obj as BulletBodyUnman;
353 return (CollisionObjectTypes)BSAPICPP.GetBodyType2(bodyu.ptr);
354}
355
356public override BulletBody CreateBodyFromShape(BulletWorld world, BulletShape shape, uint id, Vector3 pos, Quaternion rot)
357{
358 BulletWorldUnman worldu = world as BulletWorldUnman;
359 BulletShapeUnman shapeu = shape as BulletShapeUnman;
360 return new BulletBodyUnman(id, BSAPICPP.CreateBodyFromShape2(worldu.ptr, shapeu.ptr, id, pos, rot));
361}
362
363public override BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, uint id, Vector3 pos, Quaternion rot)
364{
365 BulletShapeUnman shapeu = shape as BulletShapeUnman;
366 return new BulletBodyUnman(id, BSAPICPP.CreateBodyWithDefaultMotionState2(shapeu.ptr, id, pos, rot));
367}
368
369public override BulletBody CreateGhostFromShape(BulletWorld world, BulletShape shape, uint id, Vector3 pos, Quaternion rot)
370{
371 BulletWorldUnman worldu = world as BulletWorldUnman;
372 BulletShapeUnman shapeu = shape as BulletShapeUnman;
373 return new BulletBodyUnman(id, BSAPICPP.CreateGhostFromShape2(worldu.ptr, shapeu.ptr, id, pos, rot));
374}
375
376public override void DestroyObject(BulletWorld world, BulletBody obj)
377{
378 BulletWorldUnman worldu = world as BulletWorldUnman;
379 BulletBodyUnman bodyu = obj as BulletBodyUnman;
380 BSAPICPP.DestroyObject2(worldu.ptr, bodyu.ptr);
381}
382
383// =====================================================================================
384// Terrain creation and helper routines
385public override BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin)
386{
387 return new BulletShapeUnman(BSAPICPP.CreateGroundPlaneShape2(id, height, collisionMargin), BSPhysicsShapeType.SHAPE_GROUNDPLANE);
388}
389
390public override BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap,
391 float scaleFactor, float collisionMargin)
392{
393 return new BulletShapeUnman(BSAPICPP.CreateTerrainShape2(id, size, minHeight, maxHeight, heightMap, scaleFactor, collisionMargin),
394 BSPhysicsShapeType.SHAPE_TERRAIN);
395}
396
397// =====================================================================================
398// Constraint creation and helper routines
399public override BulletConstraint Create6DofConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
400 Vector3 frame1loc, Quaternion frame1rot,
401 Vector3 frame2loc, Quaternion frame2rot,
402 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
403{
404 BulletWorldUnman worldu = world as BulletWorldUnman;
405 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
406 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
407 return new BulletConstraintUnman(BSAPICPP.Create6DofConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr, frame1loc, frame1rot,
408 frame2loc, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
409}
410
411public override BulletConstraint Create6DofConstraintToPoint(BulletWorld world, BulletBody obj1, BulletBody obj2,
412 Vector3 joinPoint,
413 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
414{
415 BulletWorldUnman worldu = world as BulletWorldUnman;
416 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
417 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
418 return new BulletConstraintUnman(BSAPICPP.Create6DofConstraintToPoint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr,
419 joinPoint, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
420}
421
422public override BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2,
423 Vector3 pivotinA, Vector3 pivotinB,
424 Vector3 axisInA, Vector3 axisInB,
425 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
426{
427 BulletWorldUnman worldu = world as BulletWorldUnman;
428 BulletBodyUnman bodyu1 = obj1 as BulletBodyUnman;
429 BulletBodyUnman bodyu2 = obj2 as BulletBodyUnman;
430 return new BulletConstraintUnman(BSAPICPP.CreateHingeConstraint2(worldu.ptr, bodyu1.ptr, bodyu2.ptr,
431 pivotinA, pivotinB, axisInA, axisInB, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies));
432}
433
434public override void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse)
435{
436 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
437 BSAPICPP.SetConstraintEnable2(constrainu.ptr, numericTrueFalse);
438}
439
440public override void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations)
441{
442 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
443 BSAPICPP.SetConstraintNumSolverIterations2(constrainu.ptr, iterations);
444}
445
446public override bool SetFrames(BulletConstraint constrain,
447 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot)
448{
449 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
450 return BSAPICPP.SetFrames2(constrainu.ptr, frameA, frameArot, frameB, frameBrot);
451}
452
453public override bool SetLinearLimits(BulletConstraint constrain, Vector3 low, Vector3 hi)
454{
455 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
456 return BSAPICPP.SetLinearLimits2(constrainu.ptr, low, hi);
457}
458
459public override bool SetAngularLimits(BulletConstraint constrain, Vector3 low, Vector3 hi)
460{
461 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
462 return BSAPICPP.SetAngularLimits2(constrainu.ptr, low, hi);
463}
464
465public override bool UseFrameOffset(BulletConstraint constrain, float enable)
466{
467 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
468 return BSAPICPP.UseFrameOffset2(constrainu.ptr, enable);
469}
470
471public override bool TranslationalLimitMotor(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce)
472{
473 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
474 return BSAPICPP.TranslationalLimitMotor2(constrainu.ptr, enable, targetVel, maxMotorForce);
475}
476
477public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold)
478{
479 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
480 return BSAPICPP.SetBreakingImpulseThreshold2(constrainu.ptr, threshold);
481}
482
483public override bool CalculateTransforms(BulletConstraint constrain)
484{
485 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
486 return BSAPICPP.CalculateTransforms2(constrainu.ptr);
487}
488
489public override bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis)
490{
491 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
492 return BSAPICPP.SetConstraintParam2(constrainu.ptr, paramIndex, value, axis);
493}
494
495public override bool DestroyConstraint(BulletWorld world, BulletConstraint constrain)
496{
497 BulletWorldUnman worldu = world as BulletWorldUnman;
498 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
499 return BSAPICPP.DestroyConstraint2(worldu.ptr, constrainu.ptr);
500}
501
502// =====================================================================================
503// btCollisionWorld entries
504public override void UpdateSingleAabb(BulletWorld world, BulletBody obj)
505{
506 BulletWorldUnman worldu = world as BulletWorldUnman;
507 BulletBodyUnman bodyu = obj as BulletBodyUnman;
508 BSAPICPP.UpdateSingleAabb2(worldu.ptr, bodyu.ptr);
509}
510
511public override void UpdateAabbs(BulletWorld world)
512{
513 BulletWorldUnman worldu = world as BulletWorldUnman;
514 BSAPICPP.UpdateAabbs2(worldu.ptr);
515}
516
517public override bool GetForceUpdateAllAabbs(BulletWorld world)
518{
519 BulletWorldUnman worldu = world as BulletWorldUnman;
520 return BSAPICPP.GetForceUpdateAllAabbs2(worldu.ptr);
521}
522
523public override void SetForceUpdateAllAabbs(BulletWorld world, bool force)
524{
525 BulletWorldUnman worldu = world as BulletWorldUnman;
526 BSAPICPP.SetForceUpdateAllAabbs2(worldu.ptr, force);
527}
528
529// =====================================================================================
530// btDynamicsWorld entries
531public override bool AddObjectToWorld(BulletWorld world, BulletBody obj)
532{
533 // Bullet resets several variables when an object is added to the world.
534 // Gravity is reset to world default depending on the static/dynamic
535 // type. Of course, the collision flags in the broadphase proxy are initialized to default.
536 BulletWorldUnman worldu = world as BulletWorldUnman;
537 BulletBodyUnman bodyu = obj as BulletBodyUnman;
538
539 Vector3 origGrav = BSAPICPP.GetGravity2(bodyu.ptr);
540
541 bool ret = BSAPICPP.AddObjectToWorld2(worldu.ptr, bodyu.ptr);
542
543 if (ret)
544 {
545 BSAPICPP.SetGravity2(bodyu.ptr, origGrav);
546 obj.ApplyCollisionMask(world.physicsScene);
547 }
548 return ret;
549}
550
551public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj)
552{
553 BulletWorldUnman worldu = world as BulletWorldUnman;
554 BulletBodyUnman bodyu = obj as BulletBodyUnman;
555 return BSAPICPP.RemoveObjectFromWorld2(worldu.ptr, bodyu.ptr);
556}
557
558public override bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects)
559{
560 BulletWorldUnman worldu = world as BulletWorldUnman;
561 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
562 return BSAPICPP.AddConstraintToWorld2(worldu.ptr, constrainu.ptr, disableCollisionsBetweenLinkedObjects);
563}
564
565public override bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain)
566{
567 BulletWorldUnman worldu = world as BulletWorldUnman;
568 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
569 return BSAPICPP.RemoveConstraintFromWorld2(worldu.ptr, constrainu.ptr);
570}
571// =====================================================================================
572// btCollisionObject entries
573public override Vector3 GetAnisotripicFriction(BulletConstraint constrain)
574{
575 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
576 return BSAPICPP.GetAnisotripicFriction2(constrainu.ptr);
577}
578
579public override Vector3 SetAnisotripicFriction(BulletConstraint constrain, Vector3 frict)
580{
581 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
582 return BSAPICPP.SetAnisotripicFriction2(constrainu.ptr, frict);
583}
584
585public override bool HasAnisotripicFriction(BulletConstraint constrain)
586{
587 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
588 return BSAPICPP.HasAnisotripicFriction2(constrainu.ptr);
589}
590
591public override void SetContactProcessingThreshold(BulletBody obj, float val)
592{
593 BulletBodyUnman bodyu = obj as BulletBodyUnman;
594 BSAPICPP.SetContactProcessingThreshold2(bodyu.ptr, val);
595}
596
597public override float GetContactProcessingThreshold(BulletBody obj)
598{
599 BulletBodyUnman bodyu = obj as BulletBodyUnman;
600 return BSAPICPP.GetContactProcessingThreshold2(bodyu.ptr);
601}
602
603public override bool IsStaticObject(BulletBody obj)
604{
605 BulletBodyUnman bodyu = obj as BulletBodyUnman;
606 return BSAPICPP.IsStaticObject2(bodyu.ptr);
607}
608
609public override bool IsKinematicObject(BulletBody obj)
610{
611 BulletBodyUnman bodyu = obj as BulletBodyUnman;
612 return BSAPICPP.IsKinematicObject2(bodyu.ptr);
613}
614
615public override bool IsStaticOrKinematicObject(BulletBody obj)
616{
617 BulletBodyUnman bodyu = obj as BulletBodyUnman;
618 return BSAPICPP.IsStaticOrKinematicObject2(bodyu.ptr);
619}
620
621public override bool HasContactResponse(BulletBody obj)
622{
623 BulletBodyUnman bodyu = obj as BulletBodyUnman;
624 return BSAPICPP.HasContactResponse2(bodyu.ptr);
625}
626
627public override void SetCollisionShape(BulletWorld world, BulletBody obj, BulletShape shape)
628{
629 BulletWorldUnman worldu = world as BulletWorldUnman;
630 BulletBodyUnman bodyu = obj as BulletBodyUnman;
631 BulletShapeUnman shapeu = shape as BulletShapeUnman;
632 if (worldu != null && bodyu != null)
633 {
634 // Special case to allow the caller to zero out the reference to any physical shape
635 if (shapeu != null)
636 BSAPICPP.SetCollisionShape2(worldu.ptr, bodyu.ptr, shapeu.ptr);
637 else
638 BSAPICPP.SetCollisionShape2(worldu.ptr, bodyu.ptr, IntPtr.Zero);
639 }
640}
641
642public override BulletShape GetCollisionShape(BulletBody obj)
643{
644 BulletBodyUnman bodyu = obj as BulletBodyUnman;
645 return new BulletShapeUnman(BSAPICPP.GetCollisionShape2(bodyu.ptr), BSPhysicsShapeType.SHAPE_UNKNOWN);
646}
647
648public override int GetActivationState(BulletBody obj)
649{
650 BulletBodyUnman bodyu = obj as BulletBodyUnman;
651 return BSAPICPP.GetActivationState2(bodyu.ptr);
652}
653
654public override void SetActivationState(BulletBody obj, int state)
655{
656 BulletBodyUnman bodyu = obj as BulletBodyUnman;
657 BSAPICPP.SetActivationState2(bodyu.ptr, state);
658}
659
660public override void SetDeactivationTime(BulletBody obj, float dtime)
661{
662 BulletBodyUnman bodyu = obj as BulletBodyUnman;
663 BSAPICPP.SetDeactivationTime2(bodyu.ptr, dtime);
664}
665
666public override float GetDeactivationTime(BulletBody obj)
667{
668 BulletBodyUnman bodyu = obj as BulletBodyUnman;
669 return BSAPICPP.GetDeactivationTime2(bodyu.ptr);
670}
671
672public override void ForceActivationState(BulletBody obj, ActivationState state)
673{
674 BulletBodyUnman bodyu = obj as BulletBodyUnman;
675 BSAPICPP.ForceActivationState2(bodyu.ptr, state);
676}
677
678public override void Activate(BulletBody obj, bool forceActivation)
679{
680 BulletBodyUnman bodyu = obj as BulletBodyUnman;
681 BSAPICPP.Activate2(bodyu.ptr, forceActivation);
682}
683
684public override bool IsActive(BulletBody obj)
685{
686 BulletBodyUnman bodyu = obj as BulletBodyUnman;
687 return BSAPICPP.IsActive2(bodyu.ptr);
688}
689
690public override void SetRestitution(BulletBody obj, float val)
691{
692 BulletBodyUnman bodyu = obj as BulletBodyUnman;
693 BSAPICPP.SetRestitution2(bodyu.ptr, val);
694}
695
696public override float GetRestitution(BulletBody obj)
697{
698 BulletBodyUnman bodyu = obj as BulletBodyUnman;
699 return BSAPICPP.GetRestitution2(bodyu.ptr);
700}
701
702public override void SetFriction(BulletBody obj, float val)
703{
704 BulletBodyUnman bodyu = obj as BulletBodyUnman;
705 BSAPICPP.SetFriction2(bodyu.ptr, val);
706}
707
708public override float GetFriction(BulletBody obj)
709{
710 BulletBodyUnman bodyu = obj as BulletBodyUnman;
711 return BSAPICPP.GetFriction2(bodyu.ptr);
712}
713
714public override Vector3 GetPosition(BulletBody obj)
715{
716 BulletBodyUnman bodyu = obj as BulletBodyUnman;
717 return BSAPICPP.GetPosition2(bodyu.ptr);
718}
719
720public override Quaternion GetOrientation(BulletBody obj)
721{
722 BulletBodyUnman bodyu = obj as BulletBodyUnman;
723 return BSAPICPP.GetOrientation2(bodyu.ptr);
724}
725
726public override void SetTranslation(BulletBody obj, Vector3 position, Quaternion rotation)
727{
728 BulletBodyUnman bodyu = obj as BulletBodyUnman;
729 BSAPICPP.SetTranslation2(bodyu.ptr, position, rotation);
730}
731
732 /*
733public override IntPtr GetBroadphaseHandle(BulletBody obj)
734{
735 BulletBodyUnman bodyu = obj as BulletBodyUnman;
736 return BSAPICPP.GetBroadphaseHandle2(bodyu.ptr);
737}
738
739public override void SetBroadphaseHandle(BulletBody obj, IntPtr handle)
740{
741 BulletBodyUnman bodyu = obj as BulletBodyUnman;
742 BSAPICPP.SetUserPointer2(bodyu.ptr, handle);
743}
744 */
745
746public override void SetInterpolationLinearVelocity(BulletBody obj, Vector3 vel)
747{
748 BulletBodyUnman bodyu = obj as BulletBodyUnman;
749 BSAPICPP.SetInterpolationLinearVelocity2(bodyu.ptr, vel);
750}
751
752public override void SetInterpolationAngularVelocity(BulletBody obj, Vector3 vel)
753{
754 BulletBodyUnman bodyu = obj as BulletBodyUnman;
755 BSAPICPP.SetInterpolationAngularVelocity2(bodyu.ptr, vel);
756}
757
758public override void SetInterpolationVelocity(BulletBody obj, Vector3 linearVel, Vector3 angularVel)
759{
760 BulletBodyUnman bodyu = obj as BulletBodyUnman;
761 BSAPICPP.SetInterpolationVelocity2(bodyu.ptr, linearVel, angularVel);
762}
763
764public override float GetHitFraction(BulletBody obj)
765{
766 BulletBodyUnman bodyu = obj as BulletBodyUnman;
767 return BSAPICPP.GetHitFraction2(bodyu.ptr);
768}
769
770public override void SetHitFraction(BulletBody obj, float val)
771{
772 BulletBodyUnman bodyu = obj as BulletBodyUnman;
773 BSAPICPP.SetHitFraction2(bodyu.ptr, val);
774}
775
776public override CollisionFlags GetCollisionFlags(BulletBody obj)
777{
778 BulletBodyUnman bodyu = obj as BulletBodyUnman;
779 return BSAPICPP.GetCollisionFlags2(bodyu.ptr);
780}
781
782public override CollisionFlags SetCollisionFlags(BulletBody obj, CollisionFlags flags)
783{
784 BulletBodyUnman bodyu = obj as BulletBodyUnman;
785 return BSAPICPP.SetCollisionFlags2(bodyu.ptr, flags);
786}
787
788public override CollisionFlags AddToCollisionFlags(BulletBody obj, CollisionFlags flags)
789{
790 BulletBodyUnman bodyu = obj as BulletBodyUnman;
791 return BSAPICPP.AddToCollisionFlags2(bodyu.ptr, flags);
792}
793
794public override CollisionFlags RemoveFromCollisionFlags(BulletBody obj, CollisionFlags flags)
795{
796 BulletBodyUnman bodyu = obj as BulletBodyUnman;
797 return BSAPICPP.RemoveFromCollisionFlags2(bodyu.ptr, flags);
798}
799
800public override float GetCcdMotionThreshold(BulletBody obj)
801{
802 BulletBodyUnman bodyu = obj as BulletBodyUnman;
803 return BSAPICPP.GetCcdMotionThreshold2(bodyu.ptr);
804}
805
806
807public override void SetCcdMotionThreshold(BulletBody obj, float val)
808{
809 BulletBodyUnman bodyu = obj as BulletBodyUnman;
810 BSAPICPP.SetCcdMotionThreshold2(bodyu.ptr, val);
811}
812
813public override float GetCcdSweptSphereRadius(BulletBody obj)
814{
815 BulletBodyUnman bodyu = obj as BulletBodyUnman;
816 return BSAPICPP.GetCcdSweptSphereRadius2(bodyu.ptr);
817}
818
819public override void SetCcdSweptSphereRadius(BulletBody obj, float val)
820{
821 BulletBodyUnman bodyu = obj as BulletBodyUnman;
822 BSAPICPP.SetCcdSweptSphereRadius2(bodyu.ptr, val);
823}
824
825public override IntPtr GetUserPointer(BulletBody obj)
826{
827 BulletBodyUnman bodyu = obj as BulletBodyUnman;
828 return BSAPICPP.GetUserPointer2(bodyu.ptr);
829}
830
831public override void SetUserPointer(BulletBody obj, IntPtr val)
832{
833 BulletBodyUnman bodyu = obj as BulletBodyUnman;
834 BSAPICPP.SetUserPointer2(bodyu.ptr, val);
835}
836
837// =====================================================================================
838// btRigidBody entries
839public override void ApplyGravity(BulletBody obj)
840{
841 BulletBodyUnman bodyu = obj as BulletBodyUnman;
842 BSAPICPP.ApplyGravity2(bodyu.ptr);
843}
844
845public override void SetGravity(BulletBody obj, Vector3 val)
846{
847 BulletBodyUnman bodyu = obj as BulletBodyUnman;
848 BSAPICPP.SetGravity2(bodyu.ptr, val);
849}
850
851public override Vector3 GetGravity(BulletBody obj)
852{
853 BulletBodyUnman bodyu = obj as BulletBodyUnman;
854 return BSAPICPP.GetGravity2(bodyu.ptr);
855}
856
857public override void SetDamping(BulletBody obj, float lin_damping, float ang_damping)
858{
859 BulletBodyUnman bodyu = obj as BulletBodyUnman;
860 BSAPICPP.SetDamping2(bodyu.ptr, lin_damping, ang_damping);
861}
862
863public override void SetLinearDamping(BulletBody obj, float lin_damping)
864{
865 BulletBodyUnman bodyu = obj as BulletBodyUnman;
866 BSAPICPP.SetLinearDamping2(bodyu.ptr, lin_damping);
867}
868
869public override void SetAngularDamping(BulletBody obj, float ang_damping)
870{
871 BulletBodyUnman bodyu = obj as BulletBodyUnman;
872 BSAPICPP.SetAngularDamping2(bodyu.ptr, ang_damping);
873}
874
875public override float GetLinearDamping(BulletBody obj)
876{
877 BulletBodyUnman bodyu = obj as BulletBodyUnman;
878 return BSAPICPP.GetLinearDamping2(bodyu.ptr);
879}
880
881public override float GetAngularDamping(BulletBody obj)
882{
883 BulletBodyUnman bodyu = obj as BulletBodyUnman;
884 return BSAPICPP.GetAngularDamping2(bodyu.ptr);
885}
886
887public override float GetLinearSleepingThreshold(BulletBody obj)
888{
889 BulletBodyUnman bodyu = obj as BulletBodyUnman;
890 return BSAPICPP.GetLinearSleepingThreshold2(bodyu.ptr);
891}
892
893public override void ApplyDamping(BulletBody obj, float timeStep)
894{
895 BulletBodyUnman bodyu = obj as BulletBodyUnman;
896 BSAPICPP.ApplyDamping2(bodyu.ptr, timeStep);
897}
898
899public override void SetMassProps(BulletBody obj, float mass, Vector3 inertia)
900{
901 BulletBodyUnman bodyu = obj as BulletBodyUnman;
902 BSAPICPP.SetMassProps2(bodyu.ptr, mass, inertia);
903}
904
905public override Vector3 GetLinearFactor(BulletBody obj)
906{
907 BulletBodyUnman bodyu = obj as BulletBodyUnman;
908 return BSAPICPP.GetLinearFactor2(bodyu.ptr);
909}
910
911public override void SetLinearFactor(BulletBody obj, Vector3 factor)
912{
913 BulletBodyUnman bodyu = obj as BulletBodyUnman;
914 BSAPICPP.SetLinearFactor2(bodyu.ptr, factor);
915}
916
917public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot)
918{
919 BulletBodyUnman bodyu = obj as BulletBodyUnman;
920 BSAPICPP.SetCenterOfMassByPosRot2(bodyu.ptr, pos, rot);
921}
922
923// Add a force to the object as if its mass is one.
924public override void ApplyCentralForce(BulletBody obj, Vector3 force)
925{
926 BulletBodyUnman bodyu = obj as BulletBodyUnman;
927 BSAPICPP.ApplyCentralForce2(bodyu.ptr, force);
928}
929
930// Set the force being applied to the object as if its mass is one.
931public override void SetObjectForce(BulletBody obj, Vector3 force)
932{
933 BulletBodyUnman bodyu = obj as BulletBodyUnman;
934 BSAPICPP.SetObjectForce2(bodyu.ptr, force);
935}
936
937public override Vector3 GetTotalForce(BulletBody obj)
938{
939 BulletBodyUnman bodyu = obj as BulletBodyUnman;
940 return BSAPICPP.GetTotalForce2(bodyu.ptr);
941}
942
943public override Vector3 GetTotalTorque(BulletBody obj)
944{
945 BulletBodyUnman bodyu = obj as BulletBodyUnman;
946 return BSAPICPP.GetTotalTorque2(bodyu.ptr);
947}
948
949public override Vector3 GetInvInertiaDiagLocal(BulletBody obj)
950{
951 BulletBodyUnman bodyu = obj as BulletBodyUnman;
952 return BSAPICPP.GetInvInertiaDiagLocal2(bodyu.ptr);
953}
954
955public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert)
956{
957 BulletBodyUnman bodyu = obj as BulletBodyUnman;
958 BSAPICPP.SetInvInertiaDiagLocal2(bodyu.ptr, inert);
959}
960
961public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold)
962{
963 BulletBodyUnman bodyu = obj as BulletBodyUnman;
964 BSAPICPP.SetSleepingThresholds2(bodyu.ptr, lin_threshold, ang_threshold);
965}
966
967public override void ApplyTorque(BulletBody obj, Vector3 torque)
968{
969 BulletBodyUnman bodyu = obj as BulletBodyUnman;
970 BSAPICPP.ApplyTorque2(bodyu.ptr, torque);
971}
972
973// Apply force at the given point. Will add torque to the object.
974public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos)
975{
976 BulletBodyUnman bodyu = obj as BulletBodyUnman;
977 BSAPICPP.ApplyForce2(bodyu.ptr, force, pos);
978}
979
980// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
981public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp)
982{
983 BulletBodyUnman bodyu = obj as BulletBodyUnman;
984 BSAPICPP.ApplyCentralImpulse2(bodyu.ptr, imp);
985}
986
987// Apply impulse to the object's torque. Force is scaled by object's mass.
988public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp)
989{
990 BulletBodyUnman bodyu = obj as BulletBodyUnman;
991 BSAPICPP.ApplyTorqueImpulse2(bodyu.ptr, imp);
992}
993
994// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
995public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos)
996{
997 BulletBodyUnman bodyu = obj as BulletBodyUnman;
998 BSAPICPP.ApplyImpulse2(bodyu.ptr, imp, pos);
999}
1000
1001public override void ClearForces(BulletBody obj)
1002{
1003 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1004 BSAPICPP.ClearForces2(bodyu.ptr);
1005}
1006
1007public override void ClearAllForces(BulletBody obj)
1008{
1009 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1010 BSAPICPP.ClearAllForces2(bodyu.ptr);
1011}
1012
1013public override void UpdateInertiaTensor(BulletBody obj)
1014{
1015 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1016 BSAPICPP.UpdateInertiaTensor2(bodyu.ptr);
1017}
1018
1019public override Vector3 GetLinearVelocity(BulletBody obj)
1020{
1021 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1022 return BSAPICPP.GetLinearVelocity2(bodyu.ptr);
1023}
1024
1025public override Vector3 GetAngularVelocity(BulletBody obj)
1026{
1027 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1028 return BSAPICPP.GetAngularVelocity2(bodyu.ptr);
1029}
1030
1031public override void SetLinearVelocity(BulletBody obj, Vector3 vel)
1032{
1033 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1034 BSAPICPP.SetLinearVelocity2(bodyu.ptr, vel);
1035}
1036
1037public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity)
1038{
1039 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1040 BSAPICPP.SetAngularVelocity2(bodyu.ptr, angularVelocity);
1041}
1042
1043public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos)
1044{
1045 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1046 return BSAPICPP.GetVelocityInLocalPoint2(bodyu.ptr, pos);
1047}
1048
1049public override void Translate(BulletBody obj, Vector3 trans)
1050{
1051 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1052 BSAPICPP.Translate2(bodyu.ptr, trans);
1053}
1054
1055public override void UpdateDeactivation(BulletBody obj, float timeStep)
1056{
1057 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1058 BSAPICPP.UpdateDeactivation2(bodyu.ptr, timeStep);
1059}
1060
1061public override bool WantsSleeping(BulletBody obj)
1062{
1063 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1064 return BSAPICPP.WantsSleeping2(bodyu.ptr);
1065}
1066
1067public override void SetAngularFactor(BulletBody obj, float factor)
1068{
1069 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1070 BSAPICPP.SetAngularFactor2(bodyu.ptr, factor);
1071}
1072
1073public override void SetAngularFactorV(BulletBody obj, Vector3 factor)
1074{
1075 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1076 BSAPICPP.SetAngularFactorV2(bodyu.ptr, factor);
1077}
1078
1079public override Vector3 GetAngularFactor(BulletBody obj)
1080{
1081 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1082 return BSAPICPP.GetAngularFactor2(bodyu.ptr);
1083}
1084
1085public override bool IsInWorld(BulletWorld world, BulletBody obj)
1086{
1087 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1088 return BSAPICPP.IsInWorld2(bodyu.ptr);
1089}
1090
1091public override void AddConstraintRef(BulletBody obj, BulletConstraint constrain)
1092{
1093 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1094 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
1095 BSAPICPP.AddConstraintRef2(bodyu.ptr, constrainu.ptr);
1096}
1097
1098public override void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain)
1099{
1100 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1101 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
1102 BSAPICPP.RemoveConstraintRef2(bodyu.ptr, constrainu.ptr);
1103}
1104
1105public override BulletConstraint GetConstraintRef(BulletBody obj, int index)
1106{
1107 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1108 return new BulletConstraintUnman(BSAPICPP.GetConstraintRef2(bodyu.ptr, index));
1109}
1110
1111public override int GetNumConstraintRefs(BulletBody obj)
1112{
1113 BulletBodyUnman bodyu = obj as BulletBodyUnman;
1114 return BSAPICPP.GetNumConstraintRefs2(bodyu.ptr);
1115}
1116
1117public override bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask)
1118{
1119 BulletBodyUnman bodyu = body as BulletBodyUnman;
1120 return BSAPICPP.SetCollisionGroupMask2(bodyu.ptr, filter, mask);
1121}
1122
1123// =====================================================================================
1124// btCollisionShape entries
1125
1126public override float GetAngularMotionDisc(BulletShape shape)
1127{
1128 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1129 return BSAPICPP.GetAngularMotionDisc2(shapeu.ptr);
1130}
1131
1132public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor)
1133{
1134 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1135 return BSAPICPP.GetContactBreakingThreshold2(shapeu.ptr, defaultFactor);
1136}
1137
1138public override bool IsPolyhedral(BulletShape shape)
1139{
1140 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1141 return BSAPICPP.IsPolyhedral2(shapeu.ptr);
1142}
1143
1144public override bool IsConvex2d(BulletShape shape)
1145{
1146 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1147 return BSAPICPP.IsConvex2d2(shapeu.ptr);
1148}
1149
1150public override bool IsConvex(BulletShape shape)
1151{
1152 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1153 return BSAPICPP.IsConvex2(shapeu.ptr);
1154}
1155
1156public override bool IsNonMoving(BulletShape shape)
1157{
1158 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1159 return BSAPICPP.IsNonMoving2(shapeu.ptr);
1160}
1161
1162public override bool IsConcave(BulletShape shape)
1163{
1164 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1165 return BSAPICPP.IsConcave2(shapeu.ptr);
1166}
1167
1168public override bool IsCompound(BulletShape shape)
1169{
1170 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1171 return BSAPICPP.IsCompound2(shapeu.ptr);
1172}
1173
1174public override bool IsSoftBody(BulletShape shape)
1175{
1176 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1177 return BSAPICPP.IsSoftBody2(shapeu.ptr);
1178}
1179
1180public override bool IsInfinite(BulletShape shape)
1181{
1182 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1183 return BSAPICPP.IsInfinite2(shapeu.ptr);
1184}
1185
1186public override void SetLocalScaling(BulletShape shape, Vector3 scale)
1187{
1188 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1189 BSAPICPP.SetLocalScaling2(shapeu.ptr, scale);
1190}
1191
1192public override Vector3 GetLocalScaling(BulletShape shape)
1193{
1194 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1195 return BSAPICPP.GetLocalScaling2(shapeu.ptr);
1196}
1197
1198public override Vector3 CalculateLocalInertia(BulletShape shape, float mass)
1199{
1200 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1201 return BSAPICPP.CalculateLocalInertia2(shapeu.ptr, mass);
1202}
1203
1204public override int GetShapeType(BulletShape shape)
1205{
1206 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1207 return BSAPICPP.GetShapeType2(shapeu.ptr);
1208}
1209
1210public override void SetMargin(BulletShape shape, float val)
1211{
1212 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1213 BSAPICPP.SetMargin2(shapeu.ptr, val);
1214}
1215
1216public override float GetMargin(BulletShape shape)
1217{
1218 BulletShapeUnman shapeu = shape as BulletShapeUnman;
1219 return BSAPICPP.GetMargin2(shapeu.ptr);
1220}
1221
1222// =====================================================================================
1223// Debugging
1224public override void DumpRigidBody(BulletWorld world, BulletBody collisionObject)
1225{
1226 BulletWorldUnman worldu = world as BulletWorldUnman;
1227 BulletBodyUnman bodyu = collisionObject as BulletBodyUnman;
1228 BSAPICPP.DumpRigidBody2(worldu.ptr, bodyu.ptr);
1229}
1230
1231public override void DumpCollisionShape(BulletWorld world, BulletShape collisionShape)
1232{
1233 BulletWorldUnman worldu = world as BulletWorldUnman;
1234 BulletShapeUnman shapeu = collisionShape as BulletShapeUnman;
1235 BSAPICPP.DumpCollisionShape2(worldu.ptr, shapeu.ptr);
1236}
1237
1238public override void DumpConstraint(BulletWorld world, BulletConstraint constrain)
1239{
1240 BulletWorldUnman worldu = world as BulletWorldUnman;
1241 BulletConstraintUnman constrainu = constrain as BulletConstraintUnman;
1242 BSAPICPP.DumpConstraint2(worldu.ptr, constrainu.ptr);
1243}
1244
1245public override void DumpActivationInfo(BulletWorld world)
1246{
1247 BulletWorldUnman worldu = world as BulletWorldUnman;
1248 BSAPICPP.DumpActivationInfo2(worldu.ptr);
1249}
1250
1251public override void DumpAllInfo(BulletWorld world)
1252{
1253 BulletWorldUnman worldu = world as BulletWorldUnman;
1254 BSAPICPP.DumpAllInfo2(worldu.ptr);
1255}
1256
1257public override void DumpPhysicsStatistics(BulletWorld world)
1258{
1259 BulletWorldUnman worldu = world as BulletWorldUnman;
1260 BSAPICPP.DumpPhysicsStatistics2(worldu.ptr);
1261}
1262
1263// =====================================================================================
1264// =====================================================================================
1265// =====================================================================================
1266// =====================================================================================
1267// =====================================================================================
1268// The actual interface to the unmanaged code
1269static class BSAPICPP
1270{
1271// ===============================================================================
1272// Link back to the managed code for outputting log messages
1273[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
1274public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
1275
1276// ===============================================================================
1277// Initialization and simulation
1278[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1279public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
1280 int maxCollisions, IntPtr collisionArray,
1281 int maxUpdates, IntPtr updateArray,
1282 DebugLogCallback logRoutine);
1283
1284[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1285public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
1286 out int updatedEntityCount, out int collidersCount);
1287
1288[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1289public static extern void Shutdown2(IntPtr sim);
1290
1291[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1292public static extern bool PushUpdate2(IntPtr obj);
1293
1294[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1295public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
1296
1297// =====================================================================================
1298// Mesh, hull, shape and body creation helper routines
1299[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1300public static extern IntPtr CreateMeshShape2(IntPtr world,
1301 int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
1302 int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices );
1303
1304[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1305public static extern IntPtr CreateHullShape2(IntPtr world,
1306 int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls);
1307
1308[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1309public static extern IntPtr BuildHullShapeFromMesh2(IntPtr world, IntPtr meshShape);
1310
1311[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1312public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData);
1313
1314[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1315public static extern bool IsNativeShape2(IntPtr shape);
1316
1317[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1318public static extern void SetShapeCollisionMargin2(IntPtr shape, float margin);
1319
1320[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1321public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale);
1322
1323[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1324public static extern IntPtr CreateCompoundShape2(IntPtr sim, bool enableDynamicAabbTree);
1325
1326[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1327public static extern int GetNumberOfCompoundChildren2(IntPtr cShape);
1328
1329[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1330public static extern void AddChildShapeToCompoundShape2(IntPtr cShape, IntPtr addShape, Vector3 pos, Quaternion rot);
1331
1332[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1333public static extern IntPtr GetChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx);
1334
1335[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1336public static extern IntPtr RemoveChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx);
1337
1338[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1339public static extern void RemoveChildShapeFromCompoundShape2(IntPtr cShape, IntPtr removeShape);
1340
1341[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1342public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape);
1343
1344[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1345public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id);
1346
1347[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1348public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape);
1349
1350[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1351public static extern int GetBodyType2(IntPtr obj);
1352
1353[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1354public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
1355
1356[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1357public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, uint id, Vector3 pos, Quaternion rot);
1358
1359[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1360public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot);
1361
1362[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1363public static extern void DestroyObject2(IntPtr sim, IntPtr obj);
1364
1365// =====================================================================================
1366// Terrain creation and helper routines
1367[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1368public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin);
1369
1370[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1371public static extern IntPtr CreateTerrainShape2(uint id, Vector3 size, float minHeight, float maxHeight,
1372 [MarshalAs(UnmanagedType.LPArray)] float[] heightMap,
1373 float scaleFactor, float collisionMargin);
1374
1375// =====================================================================================
1376// Constraint creation and helper routines
1377[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1378public static extern IntPtr Create6DofConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1379 Vector3 frame1loc, Quaternion frame1rot,
1380 Vector3 frame2loc, Quaternion frame2rot,
1381 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
1382
1383[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1384public static extern IntPtr Create6DofConstraintToPoint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1385 Vector3 joinPoint,
1386 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
1387
1388[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1389public static extern IntPtr CreateHingeConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
1390 Vector3 pivotinA, Vector3 pivotinB,
1391 Vector3 axisInA, Vector3 axisInB,
1392 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
1393
1394[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1395public static extern void SetConstraintEnable2(IntPtr constrain, float numericTrueFalse);
1396
1397[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1398public static extern void SetConstraintNumSolverIterations2(IntPtr constrain, float iterations);
1399
1400[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1401public static extern bool SetFrames2(IntPtr constrain,
1402 Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot);
1403
1404[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1405public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
1406
1407[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1408public static extern bool SetAngularLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
1409
1410[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1411public static extern bool UseFrameOffset2(IntPtr constrain, float enable);
1412
1413[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1414public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce);
1415
1416[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1417public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold);
1418
1419[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1420public static extern bool CalculateTransforms2(IntPtr constrain);
1421
1422[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1423public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
1424
1425[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1426public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain);
1427
1428// =====================================================================================
1429// btCollisionWorld entries
1430[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1431public static extern void UpdateSingleAabb2(IntPtr world, IntPtr obj);
1432
1433[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1434public static extern void UpdateAabbs2(IntPtr world);
1435
1436[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1437public static extern bool GetForceUpdateAllAabbs2(IntPtr world);
1438
1439[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1440public static extern void SetForceUpdateAllAabbs2(IntPtr world, bool force);
1441
1442// =====================================================================================
1443// btDynamicsWorld entries
1444[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1445public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj);
1446
1447[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1448public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
1449
1450[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1451public static extern bool AddConstraintToWorld2(IntPtr world, IntPtr constrain, bool disableCollisionsBetweenLinkedObjects);
1452
1453[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1454public static extern bool RemoveConstraintFromWorld2(IntPtr world, IntPtr constrain);
1455// =====================================================================================
1456// btCollisionObject entries
1457[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1458public static extern Vector3 GetAnisotripicFriction2(IntPtr constrain);
1459
1460[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1461public static extern Vector3 SetAnisotripicFriction2(IntPtr constrain, Vector3 frict);
1462
1463[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1464public static extern bool HasAnisotripicFriction2(IntPtr constrain);
1465
1466[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1467public static extern void SetContactProcessingThreshold2(IntPtr obj, float val);
1468
1469[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1470public static extern float GetContactProcessingThreshold2(IntPtr obj);
1471
1472[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1473public static extern bool IsStaticObject2(IntPtr obj);
1474
1475[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1476public static extern bool IsKinematicObject2(IntPtr obj);
1477
1478[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1479public static extern bool IsStaticOrKinematicObject2(IntPtr obj);
1480
1481[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1482public static extern bool HasContactResponse2(IntPtr obj);
1483
1484[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1485public static extern void SetCollisionShape2(IntPtr sim, IntPtr obj, IntPtr shape);
1486
1487[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1488public static extern IntPtr GetCollisionShape2(IntPtr obj);
1489
1490[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1491public static extern int GetActivationState2(IntPtr obj);
1492
1493[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1494public static extern void SetActivationState2(IntPtr obj, int state);
1495
1496[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1497public static extern void SetDeactivationTime2(IntPtr obj, float dtime);
1498
1499[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1500public static extern float GetDeactivationTime2(IntPtr obj);
1501
1502[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1503public static extern void ForceActivationState2(IntPtr obj, ActivationState state);
1504
1505[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1506public static extern void Activate2(IntPtr obj, bool forceActivation);
1507
1508[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1509public static extern bool IsActive2(IntPtr obj);
1510
1511[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1512public static extern void SetRestitution2(IntPtr obj, float val);
1513
1514[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1515public static extern float GetRestitution2(IntPtr obj);
1516
1517[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1518public static extern void SetFriction2(IntPtr obj, float val);
1519
1520[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1521public static extern float GetFriction2(IntPtr obj);
1522
1523 /* Haven't defined the type 'Transform'
1524[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1525public static extern Transform GetWorldTransform2(IntPtr obj);
1526
1527[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1528public static extern void setWorldTransform2(IntPtr obj, Transform trans);
1529 */
1530
1531[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1532public static extern Vector3 GetPosition2(IntPtr obj);
1533
1534[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1535public static extern Quaternion GetOrientation2(IntPtr obj);
1536
1537[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1538public static extern void SetTranslation2(IntPtr obj, Vector3 position, Quaternion rotation);
1539
1540[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1541public static extern IntPtr GetBroadphaseHandle2(IntPtr obj);
1542
1543[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1544public static extern void SetBroadphaseHandle2(IntPtr obj, IntPtr handle);
1545
1546 /*
1547[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1548public static extern Transform GetInterpolationWorldTransform2(IntPtr obj);
1549
1550[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1551public static extern void SetInterpolationWorldTransform2(IntPtr obj, Transform trans);
1552 */
1553
1554[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1555public static extern void SetInterpolationLinearVelocity2(IntPtr obj, Vector3 vel);
1556
1557[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1558public static extern void SetInterpolationAngularVelocity2(IntPtr obj, Vector3 vel);
1559
1560[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1561public static extern void SetInterpolationVelocity2(IntPtr obj, Vector3 linearVel, Vector3 angularVel);
1562
1563[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1564public static extern float GetHitFraction2(IntPtr obj);
1565
1566[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1567public static extern void SetHitFraction2(IntPtr obj, float val);
1568
1569[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1570public static extern CollisionFlags GetCollisionFlags2(IntPtr obj);
1571
1572[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1573public static extern CollisionFlags SetCollisionFlags2(IntPtr obj, CollisionFlags flags);
1574
1575[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1576public static extern CollisionFlags AddToCollisionFlags2(IntPtr obj, CollisionFlags flags);
1577
1578[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1579public static extern CollisionFlags RemoveFromCollisionFlags2(IntPtr obj, CollisionFlags flags);
1580
1581[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1582public static extern float GetCcdMotionThreshold2(IntPtr obj);
1583
1584[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1585public static extern void SetCcdMotionThreshold2(IntPtr obj, float val);
1586
1587[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1588public static extern float GetCcdSweptSphereRadius2(IntPtr obj);
1589
1590[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1591public static extern void SetCcdSweptSphereRadius2(IntPtr obj, float val);
1592
1593[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1594public static extern IntPtr GetUserPointer2(IntPtr obj);
1595
1596[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1597public static extern void SetUserPointer2(IntPtr obj, IntPtr val);
1598
1599// =====================================================================================
1600// btRigidBody entries
1601[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1602public static extern void ApplyGravity2(IntPtr obj);
1603
1604[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1605public static extern void SetGravity2(IntPtr obj, Vector3 val);
1606
1607[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1608public static extern Vector3 GetGravity2(IntPtr obj);
1609
1610[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1611public static extern void SetDamping2(IntPtr obj, float lin_damping, float ang_damping);
1612
1613[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1614public static extern void SetLinearDamping2(IntPtr obj, float lin_damping);
1615
1616[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1617public static extern void SetAngularDamping2(IntPtr obj, float ang_damping);
1618
1619[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1620public static extern float GetLinearDamping2(IntPtr obj);
1621
1622[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1623public static extern float GetAngularDamping2(IntPtr obj);
1624
1625[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1626public static extern float GetLinearSleepingThreshold2(IntPtr obj);
1627
1628[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1629public static extern float GetAngularSleepingThreshold2(IntPtr obj);
1630
1631[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1632public static extern void ApplyDamping2(IntPtr obj, float timeStep);
1633
1634[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1635public static extern void SetMassProps2(IntPtr obj, float mass, Vector3 inertia);
1636
1637[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1638public static extern Vector3 GetLinearFactor2(IntPtr obj);
1639
1640[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1641public static extern void SetLinearFactor2(IntPtr obj, Vector3 factor);
1642
1643 /*
1644[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1645public static extern void SetCenterOfMassTransform2(IntPtr obj, Transform trans);
1646 */
1647
1648[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1649public static extern void SetCenterOfMassByPosRot2(IntPtr obj, Vector3 pos, Quaternion rot);
1650
1651// Add a force to the object as if its mass is one.
1652[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1653public static extern void ApplyCentralForce2(IntPtr obj, Vector3 force);
1654
1655// Set the force being applied to the object as if its mass is one.
1656[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1657public static extern void SetObjectForce2(IntPtr obj, Vector3 force);
1658
1659[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1660public static extern Vector3 GetTotalForce2(IntPtr obj);
1661
1662[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1663public static extern Vector3 GetTotalTorque2(IntPtr obj);
1664
1665[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1666public static extern Vector3 GetInvInertiaDiagLocal2(IntPtr obj);
1667
1668[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1669public static extern void SetInvInertiaDiagLocal2(IntPtr obj, Vector3 inert);
1670
1671[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1672public static extern void SetSleepingThresholds2(IntPtr obj, float lin_threshold, float ang_threshold);
1673
1674[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1675public static extern void ApplyTorque2(IntPtr obj, Vector3 torque);
1676
1677// Apply force at the given point. Will add torque to the object.
1678[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1679public static extern void ApplyForce2(IntPtr obj, Vector3 force, Vector3 pos);
1680
1681// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
1682[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1683public static extern void ApplyCentralImpulse2(IntPtr obj, Vector3 imp);
1684
1685// Apply impulse to the object's torque. Force is scaled by object's mass.
1686[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1687public static extern void ApplyTorqueImpulse2(IntPtr obj, Vector3 imp);
1688
1689// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
1690[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1691public static extern void ApplyImpulse2(IntPtr obj, Vector3 imp, Vector3 pos);
1692
1693[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1694public static extern void ClearForces2(IntPtr obj);
1695
1696[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1697public static extern void ClearAllForces2(IntPtr obj);
1698
1699[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1700public static extern void UpdateInertiaTensor2(IntPtr obj);
1701
1702[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1703public static extern Vector3 GetCenterOfMassPosition2(IntPtr obj);
1704
1705 /*
1706[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1707public static extern Transform GetCenterOfMassTransform2(IntPtr obj);
1708 */
1709
1710[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1711public static extern Vector3 GetLinearVelocity2(IntPtr obj);
1712
1713[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1714public static extern Vector3 GetAngularVelocity2(IntPtr obj);
1715
1716[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1717public static extern void SetLinearVelocity2(IntPtr obj, Vector3 val);
1718
1719[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1720public static extern void SetAngularVelocity2(IntPtr obj, Vector3 angularVelocity);
1721
1722[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1723public static extern Vector3 GetVelocityInLocalPoint2(IntPtr obj, Vector3 pos);
1724
1725[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1726public static extern void Translate2(IntPtr obj, Vector3 trans);
1727
1728[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1729public static extern void UpdateDeactivation2(IntPtr obj, float timeStep);
1730
1731[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1732public static extern bool WantsSleeping2(IntPtr obj);
1733
1734[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1735public static extern void SetAngularFactor2(IntPtr obj, float factor);
1736
1737[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1738public static extern void SetAngularFactorV2(IntPtr obj, Vector3 factor);
1739
1740[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1741public static extern Vector3 GetAngularFactor2(IntPtr obj);
1742
1743[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1744public static extern bool IsInWorld2(IntPtr obj);
1745
1746[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1747public static extern void AddConstraintRef2(IntPtr obj, IntPtr constrain);
1748
1749[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1750public static extern void RemoveConstraintRef2(IntPtr obj, IntPtr constrain);
1751
1752[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1753public static extern IntPtr GetConstraintRef2(IntPtr obj, int index);
1754
1755[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1756public static extern int GetNumConstraintRefs2(IntPtr obj);
1757
1758[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1759public static extern bool SetCollisionGroupMask2(IntPtr body, uint filter, uint mask);
1760
1761// =====================================================================================
1762// btCollisionShape entries
1763
1764[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1765public static extern float GetAngularMotionDisc2(IntPtr shape);
1766
1767[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1768public static extern float GetContactBreakingThreshold2(IntPtr shape, float defaultFactor);
1769
1770[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1771public static extern bool IsPolyhedral2(IntPtr shape);
1772
1773[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1774public static extern bool IsConvex2d2(IntPtr shape);
1775
1776[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1777public static extern bool IsConvex2(IntPtr shape);
1778
1779[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1780public static extern bool IsNonMoving2(IntPtr shape);
1781
1782[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1783public static extern bool IsConcave2(IntPtr shape);
1784
1785[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1786public static extern bool IsCompound2(IntPtr shape);
1787
1788[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1789public static extern bool IsSoftBody2(IntPtr shape);
1790
1791[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1792public static extern bool IsInfinite2(IntPtr shape);
1793
1794[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1795public static extern void SetLocalScaling2(IntPtr shape, Vector3 scale);
1796
1797[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1798public static extern Vector3 GetLocalScaling2(IntPtr shape);
1799
1800[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1801public static extern Vector3 CalculateLocalInertia2(IntPtr shape, float mass);
1802
1803[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1804public static extern int GetShapeType2(IntPtr shape);
1805
1806[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1807public static extern void SetMargin2(IntPtr shape, float val);
1808
1809[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1810public static extern float GetMargin2(IntPtr shape);
1811
1812// =====================================================================================
1813// Debugging
1814[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1815public static extern void DumpRigidBody2(IntPtr sim, IntPtr collisionObject);
1816
1817[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1818public static extern void DumpCollisionShape2(IntPtr sim, IntPtr collisionShape);
1819
1820[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1821public static extern void DumpMapInfo2(IntPtr sim, IntPtr manInfo);
1822
1823[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1824public static extern void DumpConstraint2(IntPtr sim, IntPtr constrain);
1825
1826[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1827public static extern void DumpActivationInfo2(IntPtr sim);
1828
1829[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1830public static extern void DumpAllInfo2(IntPtr sim);
1831
1832[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1833public static extern void DumpPhysicsStatistics2(IntPtr sim);
1834
1835}
1836
1837}
1838
1839}