diff options
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | 1885 |
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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using System.Runtime.InteropServices; | ||
31 | using System.Security; | ||
32 | using System.Text; | ||
33 | |||
34 | using OpenSim.Framework; | ||
35 | |||
36 | using OpenMetaverse; | ||
37 | |||
38 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
39 | { | ||
40 | public sealed class BSAPIUnman : BSAPITemplate | ||
41 | { | ||
42 | |||
43 | private 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 | |||
53 | private 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 | |||
75 | private 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 | } | ||
107 | private 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. | ||
129 | GCHandle m_paramsHandle; | ||
130 | private GCHandle m_collisionArrayPinnedHandle; | ||
131 | private 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. | ||
136 | private BSAPICPP.DebugLogCallback m_DebugLogCallbackHandle; | ||
137 | |||
138 | private BSScene PhysicsScene { get; set; } | ||
139 | |||
140 | public override string BulletEngineName { get { return "BulletUnmanaged"; } } | ||
141 | public override string BulletEngineVersion { get; protected set; } | ||
142 | |||
143 | public 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 | ||
157 | public 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 | ||
193 | private 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 | ||
199 | private void BulletLoggerPhysLog(string msg) | ||
200 | { | ||
201 | PhysicsScene.DetailLog("[BULLETS UNMANAGED]:" + msg); | ||
202 | } | ||
203 | |||
204 | public 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 | |||
211 | public 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 | |||
230 | public override bool PushUpdate(BulletBody obj) | ||
231 | { | ||
232 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
233 | return BSAPICPP.PushUpdate2(bodyu.ptr); | ||
234 | } | ||
235 | |||
236 | public 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 | ||
244 | public 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 | |||
254 | public 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 | |||
262 | public 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 | |||
271 | public 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 | |||
277 | public 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 | |||
285 | public 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 | |||
292 | public 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 | |||
300 | public 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 | |||
309 | public 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 | |||
317 | public 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 | |||
324 | public 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 | |||
330 | public 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 | |||
336 | public 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 | |||
343 | public 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 | |||
349 | public override void RecalculateCompoundShapeLocalAabb(BulletShape shape) | ||
350 | { | ||
351 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
352 | BSAPICPP.RecalculateCompoundShapeLocalAabb2(shapeu.ptr); | ||
353 | } | ||
354 | |||
355 | public 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 | |||
362 | public 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 | |||
369 | public override CollisionObjectTypes GetBodyType(BulletBody obj) | ||
370 | { | ||
371 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
372 | return (CollisionObjectTypes)BSAPICPP.GetBodyType2(bodyu.ptr); | ||
373 | } | ||
374 | |||
375 | public 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 | |||
382 | public 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 | |||
388 | public 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 | |||
395 | public 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 | ||
404 | public override BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin) | ||
405 | { | ||
406 | return new BulletShapeUnman(BSAPICPP.CreateGroundPlaneShape2(id, height, collisionMargin), BSPhysicsShapeType.SHAPE_GROUNDPLANE); | ||
407 | } | ||
408 | |||
409 | public 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 | ||
418 | public 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 | |||
430 | public 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 | |||
441 | public 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 | |||
453 | public override void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse) | ||
454 | { | ||
455 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | ||
456 | BSAPICPP.SetConstraintEnable2(constrainu.ptr, numericTrueFalse); | ||
457 | } | ||
458 | |||
459 | public override void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations) | ||
460 | { | ||
461 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | ||
462 | BSAPICPP.SetConstraintNumSolverIterations2(constrainu.ptr, iterations); | ||
463 | } | ||
464 | |||
465 | public 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 | |||
472 | public 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 | |||
478 | public 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 | |||
484 | public override bool UseFrameOffset(BulletConstraint constrain, float enable) | ||
485 | { | ||
486 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | ||
487 | return BSAPICPP.UseFrameOffset2(constrainu.ptr, enable); | ||
488 | } | ||
489 | |||
490 | public 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 | |||
496 | public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold) | ||
497 | { | ||
498 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | ||
499 | return BSAPICPP.SetBreakingImpulseThreshold2(constrainu.ptr, threshold); | ||
500 | } | ||
501 | |||
502 | public override bool CalculateTransforms(BulletConstraint constrain) | ||
503 | { | ||
504 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | ||
505 | return BSAPICPP.CalculateTransforms2(constrainu.ptr); | ||
506 | } | ||
507 | |||
508 | public 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 | |||
514 | public 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 | ||
523 | public 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 | |||
530 | public override void UpdateAabbs(BulletWorld world) | ||
531 | { | ||
532 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
533 | BSAPICPP.UpdateAabbs2(worldu.ptr); | ||
534 | } | ||
535 | |||
536 | public override bool GetForceUpdateAllAabbs(BulletWorld world) | ||
537 | { | ||
538 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
539 | return BSAPICPP.GetForceUpdateAllAabbs2(worldu.ptr); | ||
540 | } | ||
541 | |||
542 | public 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 | ||
550 | public 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 | |||
570 | public 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 | |||
577 | public 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 | |||
584 | public 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 | ||
592 | public override Vector3 GetAnisotripicFriction(BulletConstraint constrain) | ||
593 | { | ||
594 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | ||
595 | return BSAPICPP.GetAnisotripicFriction2(constrainu.ptr); | ||
596 | } | ||
597 | |||
598 | public override Vector3 SetAnisotripicFriction(BulletConstraint constrain, Vector3 frict) | ||
599 | { | ||
600 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | ||
601 | return BSAPICPP.SetAnisotripicFriction2(constrainu.ptr, frict); | ||
602 | } | ||
603 | |||
604 | public override bool HasAnisotripicFriction(BulletConstraint constrain) | ||
605 | { | ||
606 | BulletConstraintUnman constrainu = constrain as BulletConstraintUnman; | ||
607 | return BSAPICPP.HasAnisotripicFriction2(constrainu.ptr); | ||
608 | } | ||
609 | |||
610 | public override void SetContactProcessingThreshold(BulletBody obj, float val) | ||
611 | { | ||
612 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
613 | BSAPICPP.SetContactProcessingThreshold2(bodyu.ptr, val); | ||
614 | } | ||
615 | |||
616 | public override float GetContactProcessingThreshold(BulletBody obj) | ||
617 | { | ||
618 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
619 | return BSAPICPP.GetContactProcessingThreshold2(bodyu.ptr); | ||
620 | } | ||
621 | |||
622 | public override bool IsStaticObject(BulletBody obj) | ||
623 | { | ||
624 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
625 | return BSAPICPP.IsStaticObject2(bodyu.ptr); | ||
626 | } | ||
627 | |||
628 | public override bool IsKinematicObject(BulletBody obj) | ||
629 | { | ||
630 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
631 | return BSAPICPP.IsKinematicObject2(bodyu.ptr); | ||
632 | } | ||
633 | |||
634 | public override bool IsStaticOrKinematicObject(BulletBody obj) | ||
635 | { | ||
636 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
637 | return BSAPICPP.IsStaticOrKinematicObject2(bodyu.ptr); | ||
638 | } | ||
639 | |||
640 | public override bool HasContactResponse(BulletBody obj) | ||
641 | { | ||
642 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
643 | return BSAPICPP.HasContactResponse2(bodyu.ptr); | ||
644 | } | ||
645 | |||
646 | public 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 | |||
661 | public 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 | |||
667 | public override int GetActivationState(BulletBody obj) | ||
668 | { | ||
669 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
670 | return BSAPICPP.GetActivationState2(bodyu.ptr); | ||
671 | } | ||
672 | |||
673 | public override void SetActivationState(BulletBody obj, int state) | ||
674 | { | ||
675 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
676 | BSAPICPP.SetActivationState2(bodyu.ptr, state); | ||
677 | } | ||
678 | |||
679 | public override void SetDeactivationTime(BulletBody obj, float dtime) | ||
680 | { | ||
681 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
682 | BSAPICPP.SetDeactivationTime2(bodyu.ptr, dtime); | ||
683 | } | ||
684 | |||
685 | public override float GetDeactivationTime(BulletBody obj) | ||
686 | { | ||
687 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
688 | return BSAPICPP.GetDeactivationTime2(bodyu.ptr); | ||
689 | } | ||
690 | |||
691 | public override void ForceActivationState(BulletBody obj, ActivationState state) | ||
692 | { | ||
693 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
694 | BSAPICPP.ForceActivationState2(bodyu.ptr, state); | ||
695 | } | ||
696 | |||
697 | public override void Activate(BulletBody obj, bool forceActivation) | ||
698 | { | ||
699 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
700 | BSAPICPP.Activate2(bodyu.ptr, forceActivation); | ||
701 | } | ||
702 | |||
703 | public override bool IsActive(BulletBody obj) | ||
704 | { | ||
705 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
706 | return BSAPICPP.IsActive2(bodyu.ptr); | ||
707 | } | ||
708 | |||
709 | public override void SetRestitution(BulletBody obj, float val) | ||
710 | { | ||
711 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
712 | BSAPICPP.SetRestitution2(bodyu.ptr, val); | ||
713 | } | ||
714 | |||
715 | public override float GetRestitution(BulletBody obj) | ||
716 | { | ||
717 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
718 | return BSAPICPP.GetRestitution2(bodyu.ptr); | ||
719 | } | ||
720 | |||
721 | public override void SetFriction(BulletBody obj, float val) | ||
722 | { | ||
723 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
724 | BSAPICPP.SetFriction2(bodyu.ptr, val); | ||
725 | } | ||
726 | |||
727 | public override float GetFriction(BulletBody obj) | ||
728 | { | ||
729 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
730 | return BSAPICPP.GetFriction2(bodyu.ptr); | ||
731 | } | ||
732 | |||
733 | public override Vector3 GetPosition(BulletBody obj) | ||
734 | { | ||
735 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
736 | return BSAPICPP.GetPosition2(bodyu.ptr); | ||
737 | } | ||
738 | |||
739 | public override Quaternion GetOrientation(BulletBody obj) | ||
740 | { | ||
741 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
742 | return BSAPICPP.GetOrientation2(bodyu.ptr); | ||
743 | } | ||
744 | |||
745 | public 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 | /* | ||
752 | public override IntPtr GetBroadphaseHandle(BulletBody obj) | ||
753 | { | ||
754 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
755 | return BSAPICPP.GetBroadphaseHandle2(bodyu.ptr); | ||
756 | } | ||
757 | |||
758 | public override void SetBroadphaseHandle(BulletBody obj, IntPtr handle) | ||
759 | { | ||
760 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
761 | BSAPICPP.SetUserPointer2(bodyu.ptr, handle); | ||
762 | } | ||
763 | */ | ||
764 | |||
765 | public override void SetInterpolationLinearVelocity(BulletBody obj, Vector3 vel) | ||
766 | { | ||
767 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
768 | BSAPICPP.SetInterpolationLinearVelocity2(bodyu.ptr, vel); | ||
769 | } | ||
770 | |||
771 | public override void SetInterpolationAngularVelocity(BulletBody obj, Vector3 vel) | ||
772 | { | ||
773 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
774 | BSAPICPP.SetInterpolationAngularVelocity2(bodyu.ptr, vel); | ||
775 | } | ||
776 | |||
777 | public 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 | |||
783 | public override float GetHitFraction(BulletBody obj) | ||
784 | { | ||
785 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
786 | return BSAPICPP.GetHitFraction2(bodyu.ptr); | ||
787 | } | ||
788 | |||
789 | public override void SetHitFraction(BulletBody obj, float val) | ||
790 | { | ||
791 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
792 | BSAPICPP.SetHitFraction2(bodyu.ptr, val); | ||
793 | } | ||
794 | |||
795 | public override CollisionFlags GetCollisionFlags(BulletBody obj) | ||
796 | { | ||
797 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
798 | return BSAPICPP.GetCollisionFlags2(bodyu.ptr); | ||
799 | } | ||
800 | |||
801 | public override CollisionFlags SetCollisionFlags(BulletBody obj, CollisionFlags flags) | ||
802 | { | ||
803 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
804 | return BSAPICPP.SetCollisionFlags2(bodyu.ptr, flags); | ||
805 | } | ||
806 | |||
807 | public override CollisionFlags AddToCollisionFlags(BulletBody obj, CollisionFlags flags) | ||
808 | { | ||
809 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
810 | return BSAPICPP.AddToCollisionFlags2(bodyu.ptr, flags); | ||
811 | } | ||
812 | |||
813 | public override CollisionFlags RemoveFromCollisionFlags(BulletBody obj, CollisionFlags flags) | ||
814 | { | ||
815 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
816 | return BSAPICPP.RemoveFromCollisionFlags2(bodyu.ptr, flags); | ||
817 | } | ||
818 | |||
819 | public override float GetCcdMotionThreshold(BulletBody obj) | ||
820 | { | ||
821 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
822 | return BSAPICPP.GetCcdMotionThreshold2(bodyu.ptr); | ||
823 | } | ||
824 | |||
825 | |||
826 | public override void SetCcdMotionThreshold(BulletBody obj, float val) | ||
827 | { | ||
828 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
829 | BSAPICPP.SetCcdMotionThreshold2(bodyu.ptr, val); | ||
830 | } | ||
831 | |||
832 | public override float GetCcdSweptSphereRadius(BulletBody obj) | ||
833 | { | ||
834 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
835 | return BSAPICPP.GetCcdSweptSphereRadius2(bodyu.ptr); | ||
836 | } | ||
837 | |||
838 | public override void SetCcdSweptSphereRadius(BulletBody obj, float val) | ||
839 | { | ||
840 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
841 | BSAPICPP.SetCcdSweptSphereRadius2(bodyu.ptr, val); | ||
842 | } | ||
843 | |||
844 | public override IntPtr GetUserPointer(BulletBody obj) | ||
845 | { | ||
846 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
847 | return BSAPICPP.GetUserPointer2(bodyu.ptr); | ||
848 | } | ||
849 | |||
850 | public 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 | ||
858 | public override void ApplyGravity(BulletBody obj) | ||
859 | { | ||
860 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
861 | BSAPICPP.ApplyGravity2(bodyu.ptr); | ||
862 | } | ||
863 | |||
864 | public override void SetGravity(BulletBody obj, Vector3 val) | ||
865 | { | ||
866 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
867 | BSAPICPP.SetGravity2(bodyu.ptr, val); | ||
868 | } | ||
869 | |||
870 | public override Vector3 GetGravity(BulletBody obj) | ||
871 | { | ||
872 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
873 | return BSAPICPP.GetGravity2(bodyu.ptr); | ||
874 | } | ||
875 | |||
876 | public 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 | |||
882 | public override void SetLinearDamping(BulletBody obj, float lin_damping) | ||
883 | { | ||
884 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
885 | BSAPICPP.SetLinearDamping2(bodyu.ptr, lin_damping); | ||
886 | } | ||
887 | |||
888 | public override void SetAngularDamping(BulletBody obj, float ang_damping) | ||
889 | { | ||
890 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
891 | BSAPICPP.SetAngularDamping2(bodyu.ptr, ang_damping); | ||
892 | } | ||
893 | |||
894 | public override float GetLinearDamping(BulletBody obj) | ||
895 | { | ||
896 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
897 | return BSAPICPP.GetLinearDamping2(bodyu.ptr); | ||
898 | } | ||
899 | |||
900 | public override float GetAngularDamping(BulletBody obj) | ||
901 | { | ||
902 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
903 | return BSAPICPP.GetAngularDamping2(bodyu.ptr); | ||
904 | } | ||
905 | |||
906 | public override float GetLinearSleepingThreshold(BulletBody obj) | ||
907 | { | ||
908 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
909 | return BSAPICPP.GetLinearSleepingThreshold2(bodyu.ptr); | ||
910 | } | ||
911 | |||
912 | public override void ApplyDamping(BulletBody obj, float timeStep) | ||
913 | { | ||
914 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
915 | BSAPICPP.ApplyDamping2(bodyu.ptr, timeStep); | ||
916 | } | ||
917 | |||
918 | public 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 | |||
924 | public override Vector3 GetLinearFactor(BulletBody obj) | ||
925 | { | ||
926 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
927 | return BSAPICPP.GetLinearFactor2(bodyu.ptr); | ||
928 | } | ||
929 | |||
930 | public override void SetLinearFactor(BulletBody obj, Vector3 factor) | ||
931 | { | ||
932 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
933 | BSAPICPP.SetLinearFactor2(bodyu.ptr, factor); | ||
934 | } | ||
935 | |||
936 | public 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; | ||
944 | public 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. | ||
951 | public override void SetObjectForce(BulletBody obj, Vector3 force) | ||
952 | { | ||
953 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
954 | BSAPICPP.SetObjectForce2(bodyu.ptr, force); | ||
955 | } | ||
956 | |||
957 | public override Vector3 GetTotalForce(BulletBody obj) | ||
958 | { | ||
959 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
960 | return BSAPICPP.GetTotalForce2(bodyu.ptr); | ||
961 | } | ||
962 | |||
963 | public override Vector3 GetTotalTorque(BulletBody obj) | ||
964 | { | ||
965 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
966 | return BSAPICPP.GetTotalTorque2(bodyu.ptr); | ||
967 | } | ||
968 | |||
969 | public override Vector3 GetInvInertiaDiagLocal(BulletBody obj) | ||
970 | { | ||
971 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
972 | return BSAPICPP.GetInvInertiaDiagLocal2(bodyu.ptr); | ||
973 | } | ||
974 | |||
975 | public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert) | ||
976 | { | ||
977 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
978 | BSAPICPP.SetInvInertiaDiagLocal2(bodyu.ptr, inert); | ||
979 | } | ||
980 | |||
981 | public 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; | ||
988 | public 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)); | ||
997 | public 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; | ||
1005 | public 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; | ||
1013 | public 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)); | ||
1022 | public 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 | |||
1028 | public override void ClearForces(BulletBody obj) | ||
1029 | { | ||
1030 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1031 | BSAPICPP.ClearForces2(bodyu.ptr); | ||
1032 | } | ||
1033 | |||
1034 | public override void ClearAllForces(BulletBody obj) | ||
1035 | { | ||
1036 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1037 | BSAPICPP.ClearAllForces2(bodyu.ptr); | ||
1038 | } | ||
1039 | |||
1040 | public override void UpdateInertiaTensor(BulletBody obj) | ||
1041 | { | ||
1042 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1043 | BSAPICPP.UpdateInertiaTensor2(bodyu.ptr); | ||
1044 | } | ||
1045 | |||
1046 | public override Vector3 GetLinearVelocity(BulletBody obj) | ||
1047 | { | ||
1048 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1049 | return BSAPICPP.GetLinearVelocity2(bodyu.ptr); | ||
1050 | } | ||
1051 | |||
1052 | public override Vector3 GetAngularVelocity(BulletBody obj) | ||
1053 | { | ||
1054 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1055 | return BSAPICPP.GetAngularVelocity2(bodyu.ptr); | ||
1056 | } | ||
1057 | |||
1058 | public override void SetLinearVelocity(BulletBody obj, Vector3 vel) | ||
1059 | { | ||
1060 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1061 | BSAPICPP.SetLinearVelocity2(bodyu.ptr, vel); | ||
1062 | } | ||
1063 | |||
1064 | public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity) | ||
1065 | { | ||
1066 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1067 | BSAPICPP.SetAngularVelocity2(bodyu.ptr, angularVelocity); | ||
1068 | } | ||
1069 | |||
1070 | public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos) | ||
1071 | { | ||
1072 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1073 | return BSAPICPP.GetVelocityInLocalPoint2(bodyu.ptr, pos); | ||
1074 | } | ||
1075 | |||
1076 | public override void Translate(BulletBody obj, Vector3 trans) | ||
1077 | { | ||
1078 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1079 | BSAPICPP.Translate2(bodyu.ptr, trans); | ||
1080 | } | ||
1081 | |||
1082 | public override void UpdateDeactivation(BulletBody obj, float timeStep) | ||
1083 | { | ||
1084 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1085 | BSAPICPP.UpdateDeactivation2(bodyu.ptr, timeStep); | ||
1086 | } | ||
1087 | |||
1088 | public override bool WantsSleeping(BulletBody obj) | ||
1089 | { | ||
1090 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1091 | return BSAPICPP.WantsSleeping2(bodyu.ptr); | ||
1092 | } | ||
1093 | |||
1094 | public override void SetAngularFactor(BulletBody obj, float factor) | ||
1095 | { | ||
1096 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1097 | BSAPICPP.SetAngularFactor2(bodyu.ptr, factor); | ||
1098 | } | ||
1099 | |||
1100 | public override void SetAngularFactorV(BulletBody obj, Vector3 factor) | ||
1101 | { | ||
1102 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1103 | BSAPICPP.SetAngularFactorV2(bodyu.ptr, factor); | ||
1104 | } | ||
1105 | |||
1106 | public override Vector3 GetAngularFactor(BulletBody obj) | ||
1107 | { | ||
1108 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1109 | return BSAPICPP.GetAngularFactor2(bodyu.ptr); | ||
1110 | } | ||
1111 | |||
1112 | public override bool IsInWorld(BulletWorld world, BulletBody obj) | ||
1113 | { | ||
1114 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1115 | return BSAPICPP.IsInWorld2(bodyu.ptr); | ||
1116 | } | ||
1117 | |||
1118 | public 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 | |||
1125 | public 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 | |||
1132 | public 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 | |||
1138 | public override int GetNumConstraintRefs(BulletBody obj) | ||
1139 | { | ||
1140 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | ||
1141 | return BSAPICPP.GetNumConstraintRefs2(bodyu.ptr); | ||
1142 | } | ||
1143 | |||
1144 | public 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 | |||
1153 | public override float GetAngularMotionDisc(BulletShape shape) | ||
1154 | { | ||
1155 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1156 | return BSAPICPP.GetAngularMotionDisc2(shapeu.ptr); | ||
1157 | } | ||
1158 | |||
1159 | public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor) | ||
1160 | { | ||
1161 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1162 | return BSAPICPP.GetContactBreakingThreshold2(shapeu.ptr, defaultFactor); | ||
1163 | } | ||
1164 | |||
1165 | public override bool IsPolyhedral(BulletShape shape) | ||
1166 | { | ||
1167 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1168 | return BSAPICPP.IsPolyhedral2(shapeu.ptr); | ||
1169 | } | ||
1170 | |||
1171 | public override bool IsConvex2d(BulletShape shape) | ||
1172 | { | ||
1173 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1174 | return BSAPICPP.IsConvex2d2(shapeu.ptr); | ||
1175 | } | ||
1176 | |||
1177 | public override bool IsConvex(BulletShape shape) | ||
1178 | { | ||
1179 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1180 | return BSAPICPP.IsConvex2(shapeu.ptr); | ||
1181 | } | ||
1182 | |||
1183 | public override bool IsNonMoving(BulletShape shape) | ||
1184 | { | ||
1185 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1186 | return BSAPICPP.IsNonMoving2(shapeu.ptr); | ||
1187 | } | ||
1188 | |||
1189 | public override bool IsConcave(BulletShape shape) | ||
1190 | { | ||
1191 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1192 | return BSAPICPP.IsConcave2(shapeu.ptr); | ||
1193 | } | ||
1194 | |||
1195 | public override bool IsCompound(BulletShape shape) | ||
1196 | { | ||
1197 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1198 | return BSAPICPP.IsCompound2(shapeu.ptr); | ||
1199 | } | ||
1200 | |||
1201 | public override bool IsSoftBody(BulletShape shape) | ||
1202 | { | ||
1203 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1204 | return BSAPICPP.IsSoftBody2(shapeu.ptr); | ||
1205 | } | ||
1206 | |||
1207 | public override bool IsInfinite(BulletShape shape) | ||
1208 | { | ||
1209 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1210 | return BSAPICPP.IsInfinite2(shapeu.ptr); | ||
1211 | } | ||
1212 | |||
1213 | public override void SetLocalScaling(BulletShape shape, Vector3 scale) | ||
1214 | { | ||
1215 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1216 | BSAPICPP.SetLocalScaling2(shapeu.ptr, scale); | ||
1217 | } | ||
1218 | |||
1219 | public override Vector3 GetLocalScaling(BulletShape shape) | ||
1220 | { | ||
1221 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1222 | return BSAPICPP.GetLocalScaling2(shapeu.ptr); | ||
1223 | } | ||
1224 | |||
1225 | public override Vector3 CalculateLocalInertia(BulletShape shape, float mass) | ||
1226 | { | ||
1227 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1228 | return BSAPICPP.CalculateLocalInertia2(shapeu.ptr, mass); | ||
1229 | } | ||
1230 | |||
1231 | public override int GetShapeType(BulletShape shape) | ||
1232 | { | ||
1233 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1234 | return BSAPICPP.GetShapeType2(shapeu.ptr); | ||
1235 | } | ||
1236 | |||
1237 | public override void SetMargin(BulletShape shape, float val) | ||
1238 | { | ||
1239 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1240 | BSAPICPP.SetMargin2(shapeu.ptr, val); | ||
1241 | } | ||
1242 | |||
1243 | public override float GetMargin(BulletShape shape) | ||
1244 | { | ||
1245 | BulletShapeUnman shapeu = shape as BulletShapeUnman; | ||
1246 | return BSAPICPP.GetMargin2(shapeu.ptr); | ||
1247 | } | ||
1248 | |||
1249 | // ===================================================================================== | ||
1250 | // Debugging | ||
1251 | public 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 | |||
1258 | public 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 | |||
1265 | public 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 | |||
1272 | public override void DumpActivationInfo(BulletWorld world) | ||
1273 | { | ||
1274 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
1275 | BSAPICPP.DumpActivationInfo2(worldu.ptr); | ||
1276 | } | ||
1277 | |||
1278 | public override void DumpAllInfo(BulletWorld world) | ||
1279 | { | ||
1280 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
1281 | BSAPICPP.DumpAllInfo2(worldu.ptr); | ||
1282 | } | ||
1283 | |||
1284 | public override void DumpPhysicsStatistics(BulletWorld world) | ||
1285 | { | ||
1286 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
1287 | BSAPICPP.DumpPhysicsStatistics2(worldu.ptr); | ||
1288 | } | ||
1289 | public override void ResetBroadphasePool(BulletWorld world) | ||
1290 | { | ||
1291 | BulletWorldUnman worldu = world as BulletWorldUnman; | ||
1292 | BSAPICPP.ResetBroadphasePool(worldu.ptr); | ||
1293 | } | ||
1294 | public 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 | ||
1306 | static class BSAPICPP | ||
1307 | { | ||
1308 | // =============================================================================== | ||
1309 | // Link back to the managed code for outputting log messages | ||
1310 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | ||
1311 | public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); | ||
1312 | |||
1313 | // =============================================================================== | ||
1314 | // Initialization and simulation | ||
1315 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1316 | public 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] | ||
1322 | public 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] | ||
1326 | public static extern void Shutdown2(IntPtr sim); | ||
1327 | |||
1328 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1329 | public static extern bool PushUpdate2(IntPtr obj); | ||
1330 | |||
1331 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1332 | public 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] | ||
1337 | public 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] | ||
1342 | public static extern IntPtr CreateHullShape2(IntPtr world, | ||
1343 | int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls); | ||
1344 | |||
1345 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1346 | public static extern IntPtr BuildHullShapeFromMesh2(IntPtr world, IntPtr meshShape); | ||
1347 | |||
1348 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1349 | public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData); | ||
1350 | |||
1351 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1352 | public static extern bool IsNativeShape2(IntPtr shape); | ||
1353 | |||
1354 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1355 | public static extern void SetShapeCollisionMargin2(IntPtr shape, float margin); | ||
1356 | |||
1357 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1358 | public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale); | ||
1359 | |||
1360 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1361 | public static extern IntPtr CreateCompoundShape2(IntPtr sim, bool enableDynamicAabbTree); | ||
1362 | |||
1363 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1364 | public static extern int GetNumberOfCompoundChildren2(IntPtr cShape); | ||
1365 | |||
1366 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1367 | public static extern void AddChildShapeToCompoundShape2(IntPtr cShape, IntPtr addShape, Vector3 pos, Quaternion rot); | ||
1368 | |||
1369 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1370 | public static extern IntPtr GetChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx); | ||
1371 | |||
1372 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1373 | public static extern IntPtr RemoveChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx); | ||
1374 | |||
1375 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1376 | public static extern void RemoveChildShapeFromCompoundShape2(IntPtr cShape, IntPtr removeShape); | ||
1377 | |||
1378 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1379 | public static extern void UpdateChildTransform2(IntPtr pShape, int childIndex, Vector3 pos, Quaternion rot, bool shouldRecalculateLocalAabb); | ||
1380 | |||
1381 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1382 | public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape); | ||
1383 | |||
1384 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1385 | public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id); | ||
1386 | |||
1387 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1388 | public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape); | ||
1389 | |||
1390 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1391 | public static extern int GetBodyType2(IntPtr obj); | ||
1392 | |||
1393 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1394 | public static extern IntPtr CreateBodyFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot); | ||
1395 | |||
1396 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1397 | public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, uint id, Vector3 pos, Quaternion rot); | ||
1398 | |||
1399 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1400 | public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot); | ||
1401 | |||
1402 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1403 | public static extern void DestroyObject2(IntPtr sim, IntPtr obj); | ||
1404 | |||
1405 | // ===================================================================================== | ||
1406 | // Terrain creation and helper routines | ||
1407 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1408 | public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin); | ||
1409 | |||
1410 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1411 | public 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] | ||
1418 | public 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] | ||
1424 | public 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] | ||
1429 | public 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] | ||
1435 | public static extern void SetConstraintEnable2(IntPtr constrain, float numericTrueFalse); | ||
1436 | |||
1437 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1438 | public static extern void SetConstraintNumSolverIterations2(IntPtr constrain, float iterations); | ||
1439 | |||
1440 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1441 | public static extern bool SetFrames2(IntPtr constrain, | ||
1442 | Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot); | ||
1443 | |||
1444 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1445 | public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi); | ||
1446 | |||
1447 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1448 | public static extern bool SetAngularLimits2(IntPtr constrain, Vector3 low, Vector3 hi); | ||
1449 | |||
1450 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1451 | public static extern bool UseFrameOffset2(IntPtr constrain, float enable); | ||
1452 | |||
1453 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1454 | public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce); | ||
1455 | |||
1456 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1457 | public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold); | ||
1458 | |||
1459 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1460 | public static extern bool CalculateTransforms2(IntPtr constrain); | ||
1461 | |||
1462 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1463 | public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); | ||
1464 | |||
1465 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1466 | public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain); | ||
1467 | |||
1468 | // ===================================================================================== | ||
1469 | // btCollisionWorld entries | ||
1470 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1471 | public static extern void UpdateSingleAabb2(IntPtr world, IntPtr obj); | ||
1472 | |||
1473 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1474 | public static extern void UpdateAabbs2(IntPtr world); | ||
1475 | |||
1476 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1477 | public static extern bool GetForceUpdateAllAabbs2(IntPtr world); | ||
1478 | |||
1479 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1480 | public static extern void SetForceUpdateAllAabbs2(IntPtr world, bool force); | ||
1481 | |||
1482 | // ===================================================================================== | ||
1483 | // btDynamicsWorld entries | ||
1484 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1485 | public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj); | ||
1486 | |||
1487 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1488 | public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj); | ||
1489 | |||
1490 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1491 | public static extern bool AddConstraintToWorld2(IntPtr world, IntPtr constrain, bool disableCollisionsBetweenLinkedObjects); | ||
1492 | |||
1493 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1494 | public static extern bool RemoveConstraintFromWorld2(IntPtr world, IntPtr constrain); | ||
1495 | // ===================================================================================== | ||
1496 | // btCollisionObject entries | ||
1497 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1498 | public static extern Vector3 GetAnisotripicFriction2(IntPtr constrain); | ||
1499 | |||
1500 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1501 | public static extern Vector3 SetAnisotripicFriction2(IntPtr constrain, Vector3 frict); | ||
1502 | |||
1503 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1504 | public static extern bool HasAnisotripicFriction2(IntPtr constrain); | ||
1505 | |||
1506 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1507 | public static extern void SetContactProcessingThreshold2(IntPtr obj, float val); | ||
1508 | |||
1509 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1510 | public static extern float GetContactProcessingThreshold2(IntPtr obj); | ||
1511 | |||
1512 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1513 | public static extern bool IsStaticObject2(IntPtr obj); | ||
1514 | |||
1515 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1516 | public static extern bool IsKinematicObject2(IntPtr obj); | ||
1517 | |||
1518 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1519 | public static extern bool IsStaticOrKinematicObject2(IntPtr obj); | ||
1520 | |||
1521 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1522 | public static extern bool HasContactResponse2(IntPtr obj); | ||
1523 | |||
1524 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1525 | public static extern void SetCollisionShape2(IntPtr sim, IntPtr obj, IntPtr shape); | ||
1526 | |||
1527 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1528 | public static extern IntPtr GetCollisionShape2(IntPtr obj); | ||
1529 | |||
1530 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1531 | public static extern int GetActivationState2(IntPtr obj); | ||
1532 | |||
1533 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1534 | public static extern void SetActivationState2(IntPtr obj, int state); | ||
1535 | |||
1536 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1537 | public static extern void SetDeactivationTime2(IntPtr obj, float dtime); | ||
1538 | |||
1539 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1540 | public static extern float GetDeactivationTime2(IntPtr obj); | ||
1541 | |||
1542 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1543 | public static extern void ForceActivationState2(IntPtr obj, ActivationState state); | ||
1544 | |||
1545 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1546 | public static extern void Activate2(IntPtr obj, bool forceActivation); | ||
1547 | |||
1548 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1549 | public static extern bool IsActive2(IntPtr obj); | ||
1550 | |||
1551 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1552 | public static extern void SetRestitution2(IntPtr obj, float val); | ||
1553 | |||
1554 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1555 | public static extern float GetRestitution2(IntPtr obj); | ||
1556 | |||
1557 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1558 | public static extern void SetFriction2(IntPtr obj, float val); | ||
1559 | |||
1560 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1561 | public static extern float GetFriction2(IntPtr obj); | ||
1562 | |||
1563 | /* Haven't defined the type 'Transform' | ||
1564 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1565 | public static extern Transform GetWorldTransform2(IntPtr obj); | ||
1566 | |||
1567 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1568 | public static extern void setWorldTransform2(IntPtr obj, Transform trans); | ||
1569 | */ | ||
1570 | |||
1571 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1572 | public static extern Vector3 GetPosition2(IntPtr obj); | ||
1573 | |||
1574 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1575 | public static extern Quaternion GetOrientation2(IntPtr obj); | ||
1576 | |||
1577 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1578 | public static extern void SetTranslation2(IntPtr obj, Vector3 position, Quaternion rotation); | ||
1579 | |||
1580 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1581 | public static extern IntPtr GetBroadphaseHandle2(IntPtr obj); | ||
1582 | |||
1583 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1584 | public static extern void SetBroadphaseHandle2(IntPtr obj, IntPtr handle); | ||
1585 | |||
1586 | /* | ||
1587 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1588 | public static extern Transform GetInterpolationWorldTransform2(IntPtr obj); | ||
1589 | |||
1590 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1591 | public static extern void SetInterpolationWorldTransform2(IntPtr obj, Transform trans); | ||
1592 | */ | ||
1593 | |||
1594 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1595 | public static extern void SetInterpolationLinearVelocity2(IntPtr obj, Vector3 vel); | ||
1596 | |||
1597 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1598 | public static extern void SetInterpolationAngularVelocity2(IntPtr obj, Vector3 vel); | ||
1599 | |||
1600 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1601 | public static extern void SetInterpolationVelocity2(IntPtr obj, Vector3 linearVel, Vector3 angularVel); | ||
1602 | |||
1603 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1604 | public static extern float GetHitFraction2(IntPtr obj); | ||
1605 | |||
1606 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1607 | public static extern void SetHitFraction2(IntPtr obj, float val); | ||
1608 | |||
1609 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1610 | public static extern CollisionFlags GetCollisionFlags2(IntPtr obj); | ||
1611 | |||
1612 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1613 | public static extern CollisionFlags SetCollisionFlags2(IntPtr obj, CollisionFlags flags); | ||
1614 | |||
1615 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1616 | public static extern CollisionFlags AddToCollisionFlags2(IntPtr obj, CollisionFlags flags); | ||
1617 | |||
1618 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1619 | public static extern CollisionFlags RemoveFromCollisionFlags2(IntPtr obj, CollisionFlags flags); | ||
1620 | |||
1621 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1622 | public static extern float GetCcdMotionThreshold2(IntPtr obj); | ||
1623 | |||
1624 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1625 | public static extern void SetCcdMotionThreshold2(IntPtr obj, float val); | ||
1626 | |||
1627 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1628 | public static extern float GetCcdSweptSphereRadius2(IntPtr obj); | ||
1629 | |||
1630 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1631 | public static extern void SetCcdSweptSphereRadius2(IntPtr obj, float val); | ||
1632 | |||
1633 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1634 | public static extern IntPtr GetUserPointer2(IntPtr obj); | ||
1635 | |||
1636 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1637 | public static extern void SetUserPointer2(IntPtr obj, IntPtr val); | ||
1638 | |||
1639 | // ===================================================================================== | ||
1640 | // btRigidBody entries | ||
1641 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1642 | public static extern void ApplyGravity2(IntPtr obj); | ||
1643 | |||
1644 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1645 | public static extern void SetGravity2(IntPtr obj, Vector3 val); | ||
1646 | |||
1647 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1648 | public static extern Vector3 GetGravity2(IntPtr obj); | ||
1649 | |||
1650 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1651 | public static extern void SetDamping2(IntPtr obj, float lin_damping, float ang_damping); | ||
1652 | |||
1653 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1654 | public static extern void SetLinearDamping2(IntPtr obj, float lin_damping); | ||
1655 | |||
1656 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1657 | public static extern void SetAngularDamping2(IntPtr obj, float ang_damping); | ||
1658 | |||
1659 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1660 | public static extern float GetLinearDamping2(IntPtr obj); | ||
1661 | |||
1662 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1663 | public static extern float GetAngularDamping2(IntPtr obj); | ||
1664 | |||
1665 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1666 | public static extern float GetLinearSleepingThreshold2(IntPtr obj); | ||
1667 | |||
1668 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1669 | public static extern float GetAngularSleepingThreshold2(IntPtr obj); | ||
1670 | |||
1671 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1672 | public static extern void ApplyDamping2(IntPtr obj, float timeStep); | ||
1673 | |||
1674 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1675 | public static extern void SetMassProps2(IntPtr obj, float mass, Vector3 inertia); | ||
1676 | |||
1677 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1678 | public static extern Vector3 GetLinearFactor2(IntPtr obj); | ||
1679 | |||
1680 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1681 | public static extern void SetLinearFactor2(IntPtr obj, Vector3 factor); | ||
1682 | |||
1683 | /* | ||
1684 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1685 | public static extern void SetCenterOfMassTransform2(IntPtr obj, Transform trans); | ||
1686 | */ | ||
1687 | |||
1688 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1689 | public 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] | ||
1693 | public 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] | ||
1697 | public static extern void SetObjectForce2(IntPtr obj, Vector3 force); | ||
1698 | |||
1699 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1700 | public static extern Vector3 GetTotalForce2(IntPtr obj); | ||
1701 | |||
1702 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1703 | public static extern Vector3 GetTotalTorque2(IntPtr obj); | ||
1704 | |||
1705 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1706 | public static extern Vector3 GetInvInertiaDiagLocal2(IntPtr obj); | ||
1707 | |||
1708 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1709 | public static extern void SetInvInertiaDiagLocal2(IntPtr obj, Vector3 inert); | ||
1710 | |||
1711 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1712 | public static extern void SetSleepingThresholds2(IntPtr obj, float lin_threshold, float ang_threshold); | ||
1713 | |||
1714 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1715 | public 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] | ||
1719 | public 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] | ||
1723 | public 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] | ||
1727 | public 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] | ||
1731 | public static extern void ApplyImpulse2(IntPtr obj, Vector3 imp, Vector3 pos); | ||
1732 | |||
1733 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1734 | public static extern void ClearForces2(IntPtr obj); | ||
1735 | |||
1736 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1737 | public static extern void ClearAllForces2(IntPtr obj); | ||
1738 | |||
1739 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1740 | public static extern void UpdateInertiaTensor2(IntPtr obj); | ||
1741 | |||
1742 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1743 | public static extern Vector3 GetCenterOfMassPosition2(IntPtr obj); | ||
1744 | |||
1745 | /* | ||
1746 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1747 | public static extern Transform GetCenterOfMassTransform2(IntPtr obj); | ||
1748 | */ | ||
1749 | |||
1750 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1751 | public static extern Vector3 GetLinearVelocity2(IntPtr obj); | ||
1752 | |||
1753 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1754 | public static extern Vector3 GetAngularVelocity2(IntPtr obj); | ||
1755 | |||
1756 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1757 | public static extern void SetLinearVelocity2(IntPtr obj, Vector3 val); | ||
1758 | |||
1759 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1760 | public static extern void SetAngularVelocity2(IntPtr obj, Vector3 angularVelocity); | ||
1761 | |||
1762 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1763 | public static extern Vector3 GetVelocityInLocalPoint2(IntPtr obj, Vector3 pos); | ||
1764 | |||
1765 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1766 | public static extern void Translate2(IntPtr obj, Vector3 trans); | ||
1767 | |||
1768 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1769 | public static extern void UpdateDeactivation2(IntPtr obj, float timeStep); | ||
1770 | |||
1771 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1772 | public static extern bool WantsSleeping2(IntPtr obj); | ||
1773 | |||
1774 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1775 | public static extern void SetAngularFactor2(IntPtr obj, float factor); | ||
1776 | |||
1777 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1778 | public static extern void SetAngularFactorV2(IntPtr obj, Vector3 factor); | ||
1779 | |||
1780 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1781 | public static extern Vector3 GetAngularFactor2(IntPtr obj); | ||
1782 | |||
1783 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1784 | public static extern bool IsInWorld2(IntPtr obj); | ||
1785 | |||
1786 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1787 | public static extern void AddConstraintRef2(IntPtr obj, IntPtr constrain); | ||
1788 | |||
1789 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1790 | public static extern void RemoveConstraintRef2(IntPtr obj, IntPtr constrain); | ||
1791 | |||
1792 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1793 | public static extern IntPtr GetConstraintRef2(IntPtr obj, int index); | ||
1794 | |||
1795 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1796 | public static extern int GetNumConstraintRefs2(IntPtr obj); | ||
1797 | |||
1798 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1799 | public static extern bool SetCollisionGroupMask2(IntPtr body, uint filter, uint mask); | ||
1800 | |||
1801 | // ===================================================================================== | ||
1802 | // btCollisionShape entries | ||
1803 | |||
1804 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1805 | public static extern float GetAngularMotionDisc2(IntPtr shape); | ||
1806 | |||
1807 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1808 | public static extern float GetContactBreakingThreshold2(IntPtr shape, float defaultFactor); | ||
1809 | |||
1810 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1811 | public static extern bool IsPolyhedral2(IntPtr shape); | ||
1812 | |||
1813 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1814 | public static extern bool IsConvex2d2(IntPtr shape); | ||
1815 | |||
1816 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1817 | public static extern bool IsConvex2(IntPtr shape); | ||
1818 | |||
1819 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1820 | public static extern bool IsNonMoving2(IntPtr shape); | ||
1821 | |||
1822 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1823 | public static extern bool IsConcave2(IntPtr shape); | ||
1824 | |||
1825 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1826 | public static extern bool IsCompound2(IntPtr shape); | ||
1827 | |||
1828 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1829 | public static extern bool IsSoftBody2(IntPtr shape); | ||
1830 | |||
1831 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1832 | public static extern bool IsInfinite2(IntPtr shape); | ||
1833 | |||
1834 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1835 | public static extern void SetLocalScaling2(IntPtr shape, Vector3 scale); | ||
1836 | |||
1837 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1838 | public static extern Vector3 GetLocalScaling2(IntPtr shape); | ||
1839 | |||
1840 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1841 | public static extern Vector3 CalculateLocalInertia2(IntPtr shape, float mass); | ||
1842 | |||
1843 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1844 | public static extern int GetShapeType2(IntPtr shape); | ||
1845 | |||
1846 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1847 | public static extern void SetMargin2(IntPtr shape, float val); | ||
1848 | |||
1849 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1850 | public static extern float GetMargin2(IntPtr shape); | ||
1851 | |||
1852 | // ===================================================================================== | ||
1853 | // Debugging | ||
1854 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1855 | public static extern void DumpRigidBody2(IntPtr sim, IntPtr collisionObject); | ||
1856 | |||
1857 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1858 | public static extern void DumpCollisionShape2(IntPtr sim, IntPtr collisionShape); | ||
1859 | |||
1860 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1861 | public static extern void DumpMapInfo2(IntPtr sim, IntPtr manInfo); | ||
1862 | |||
1863 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1864 | public static extern void DumpConstraint2(IntPtr sim, IntPtr constrain); | ||
1865 | |||
1866 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1867 | public static extern void DumpActivationInfo2(IntPtr sim); | ||
1868 | |||
1869 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1870 | public static extern void DumpAllInfo2(IntPtr sim); | ||
1871 | |||
1872 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1873 | public static extern void DumpPhysicsStatistics2(IntPtr sim); | ||
1874 | |||
1875 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1876 | public static extern void ResetBroadphasePool(IntPtr sim); | ||
1877 | |||
1878 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
1879 | public static extern void ResetConstraintSolver(IntPtr sim); | ||
1880 | |||
1881 | } | ||
1882 | |||
1883 | } | ||
1884 | |||
1885 | } | ||