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