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