diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 086f0dc..65e3145 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | |||
@@ -32,6 +32,28 @@ using OpenMetaverse; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.Physics.BulletSPlugin { | 33 | namespace OpenSim.Region.Physics.BulletSPlugin { |
34 | 34 | ||
35 | // Classes to allow some type checking for the API | ||
36 | public struct BulletSim | ||
37 | { | ||
38 | public BulletSim(uint id, IntPtr xx) { ID = id; Ptr = xx; } | ||
39 | public IntPtr Ptr; | ||
40 | public uint ID; | ||
41 | } | ||
42 | |||
43 | public struct BulletBody | ||
44 | { | ||
45 | public BulletBody(uint id, IntPtr xx) { ID = id; Ptr = xx; } | ||
46 | public IntPtr Ptr; | ||
47 | public uint ID; | ||
48 | } | ||
49 | |||
50 | public struct BulletConstraint | ||
51 | { | ||
52 | public BulletConstraint(IntPtr xx) { Ptr = xx; } | ||
53 | public IntPtr Ptr; | ||
54 | } | ||
55 | |||
56 | // =============================================================================== | ||
35 | [StructLayout(LayoutKind.Sequential)] | 57 | [StructLayout(LayoutKind.Sequential)] |
36 | public struct ConvexHull | 58 | public struct ConvexHull |
37 | { | 59 | { |
@@ -142,10 +164,32 @@ public struct ConfigurationParameters | |||
142 | public float shouldEnableFrictionCaching; | 164 | public float shouldEnableFrictionCaching; |
143 | public float numberOfSolverIterations; | 165 | public float numberOfSolverIterations; |
144 | 166 | ||
167 | public float linkConstraintUseFrameOffset; | ||
168 | public float linkConstraintEnableTransMotor; | ||
169 | public float linkConstraintTransMotorMaxVel; | ||
170 | public float linkConstraintTransMotorMaxForce; | ||
171 | |||
145 | public const float numericTrue = 1f; | 172 | public const float numericTrue = 1f; |
146 | public const float numericFalse = 0f; | 173 | public const float numericFalse = 0f; |
147 | } | 174 | } |
148 | 175 | ||
176 | // Values used by Bullet and BulletSim to control collisions | ||
177 | public enum CollisionFlags : uint | ||
178 | { | ||
179 | STATIC_OBJECT = 1 << 0, | ||
180 | KINEMATIC_OBJECT = 1 << 1, | ||
181 | NO_CONTACT_RESPONSE = 1 << 2, | ||
182 | CUSTOM_MATERIAL_CALLBACK = 1 << 3, | ||
183 | CHARACTER_OBJECT = 1 << 4, | ||
184 | DISABLE_VISUALIZE_OBJECT = 1 << 5, | ||
185 | DISABLE_SPU_COLLISION_PROCESS = 1 << 6, | ||
186 | // Following used by BulletSim to control collisions | ||
187 | VOLUME_DETECT_OBJECT = 1 << 10, | ||
188 | PHANTOM_OBJECT = 1 << 11, | ||
189 | PHYSICAL_OBJECT = 1 << 12, | ||
190 | }; | ||
191 | |||
192 | // =============================================================================== | ||
149 | static class BulletSimAPI { | 193 | static class BulletSimAPI { |
150 | 194 | ||
151 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 195 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -195,6 +239,7 @@ public static extern bool DestroyMesh(uint worldID, System.UInt64 meshKey); | |||
195 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 239 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
196 | public static extern bool CreateObject(uint worldID, ShapeData shapeData); | 240 | public static extern bool CreateObject(uint worldID, ShapeData shapeData); |
197 | 241 | ||
242 | /* Remove old functionality | ||
198 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 243 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
199 | public static extern void CreateLinkset(uint worldID, int objectCount, ShapeData[] shapeDatas); | 244 | public static extern void CreateLinkset(uint worldID, int objectCount, ShapeData[] shapeDatas); |
200 | 245 | ||
@@ -209,11 +254,15 @@ public static extern bool RemoveConstraintByID(uint worldID, uint id1); | |||
209 | 254 | ||
210 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 255 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
211 | public static extern bool RemoveConstraint(uint worldID, uint id1, uint id2); | 256 | public static extern bool RemoveConstraint(uint worldID, uint id1, uint id2); |
257 | */ | ||
212 | 258 | ||
213 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 259 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
214 | public static extern Vector3 GetObjectPosition(uint WorldID, uint id); | 260 | public static extern Vector3 GetObjectPosition(uint WorldID, uint id); |
215 | 261 | ||
216 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 262 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
263 | public static extern Quaternion GetObjectOrientation(uint WorldID, uint id); | ||
264 | |||
265 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
217 | public static extern bool SetObjectTranslation(uint worldID, uint id, Vector3 position, Quaternion rotation); | 266 | public static extern bool SetObjectTranslation(uint worldID, uint id, Vector3 position, Quaternion rotation); |
218 | 267 | ||
219 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 268 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -268,5 +317,175 @@ public static extern void DumpBulletStatistics(); | |||
268 | public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); | 317 | public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); |
269 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 318 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
270 | public static extern void SetDebugLogCallback(DebugLogCallback callback); | 319 | public static extern void SetDebugLogCallback(DebugLogCallback callback); |
320 | |||
321 | // =============================================================================== | ||
322 | // =============================================================================== | ||
323 | // =============================================================================== | ||
324 | // A new version of the API that enables moving all the logic out of the C++ code and into | ||
325 | // the C# code. This will make modifications easier for the next person. | ||
326 | // This interface passes the actual pointers to the objects in the unmanaged | ||
327 | // address space. All the management (calls for creation/destruction/lookup) | ||
328 | // is done in the C# code. | ||
329 | // The names have a "2" tacked on. This will be removed as the C# code gets rebuilt | ||
330 | // and the old code is removed. | ||
331 | |||
332 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
333 | public static extern IntPtr GetSimHandle2(uint worldID); | ||
334 | |||
335 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
336 | public static extern IntPtr GetBodyHandleWorldID2(uint worldID, uint id); | ||
337 | |||
338 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
339 | public static extern IntPtr GetBodyHandle2(IntPtr sim, uint id); | ||
340 | |||
341 | // =============================================================================== | ||
342 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
343 | public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms, | ||
344 | int maxCollisions, IntPtr collisionArray, | ||
345 | int maxUpdates, IntPtr updateArray); | ||
346 | |||
347 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
348 | public static extern bool UpdateParameter2(IntPtr sim, uint localID, String parm, float value); | ||
349 | |||
350 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
351 | public static extern void SetHeightmap2(IntPtr sim, float[] heightmap); | ||
352 | |||
353 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
354 | public static extern void Shutdown2(IntPtr sim); | ||
355 | |||
356 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
357 | public static extern int PhysicsStep2(IntPtr sim, float timeStep, int maxSubSteps, float fixedTimeStep, | ||
358 | out int updatedEntityCount, | ||
359 | out IntPtr updatedEntitiesPtr, | ||
360 | out int collidersCount, | ||
361 | out IntPtr collidersPtr); | ||
362 | |||
363 | /* | ||
364 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
365 | public static extern IntPtr CreateMesh2(IntPtr sim, int indicesCount, int* indices, int verticesCount, float* vertices ); | ||
366 | |||
367 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
368 | public static extern bool BuildHull2(IntPtr sim, IntPtr mesh); | ||
369 | |||
370 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
371 | public static extern bool ReleaseHull2(IntPtr sim, IntPtr mesh); | ||
372 | |||
373 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
374 | public static extern bool DestroyMesh2(IntPtr sim, IntPtr mesh); | ||
375 | |||
376 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
377 | public static extern IntPtr CreateObject2(IntPtr sim, ShapeData shapeData); | ||
378 | */ | ||
379 | |||
380 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
381 | public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2, | ||
382 | Vector3 frame1loc, Quaternion frame1rot, | ||
383 | Vector3 frame2loc, Quaternion frame2rot); | ||
384 | |||
385 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
386 | public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi); | ||
387 | |||
388 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
389 | public static extern bool SetAngularLimits2(IntPtr constrain, Vector3 low, Vector3 hi); | ||
390 | |||
391 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
392 | public static extern bool UseFrameOffset2(IntPtr constrain, float enable); | ||
393 | |||
394 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
395 | public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce); | ||
396 | |||
397 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
398 | public static extern bool CalculateTransforms2(IntPtr constrain); | ||
399 | |||
400 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
401 | public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain); | ||
402 | |||
403 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
404 | public static extern Vector3 GetPosition2(IntPtr obj); | ||
405 | |||
406 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
407 | public static extern Quaternion GetOrientation2(IntPtr obj); | ||
408 | |||
409 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
410 | public static extern bool SetTranslation2(IntPtr obj, Vector3 position, Quaternion rotation); | ||
411 | |||
412 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
413 | public static extern bool SetVelocity2(IntPtr obj, Vector3 velocity); | ||
414 | |||
415 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
416 | public static extern bool SetAngularVelocity2(IntPtr obj, Vector3 angularVelocity); | ||
417 | |||
418 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
419 | public static extern bool SetObjectForce2(IntPtr obj, Vector3 force); | ||
420 | |||
421 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
422 | public static extern bool SetCcdMotionThreshold2(IntPtr obj, float val); | ||
423 | |||
424 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
425 | public static extern bool SetCcdSweepSphereRadius2(IntPtr obj, float val); | ||
426 | |||
427 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
428 | public static extern bool SetDamping2(IntPtr obj, float lin_damping, float ang_damping); | ||
429 | |||
430 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
431 | public static extern bool SetDeactivationTime2(IntPtr obj, float val); | ||
432 | |||
433 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
434 | public static extern bool SetSleepingThresholds2(IntPtr obj, float lin_threshold, float ang_threshold); | ||
435 | |||
436 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
437 | public static extern bool SetContactProcessingThreshold2(IntPtr obj, float val); | ||
438 | |||
439 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
440 | public static extern bool SetFriction2(IntPtr obj, float val); | ||
441 | |||
442 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
443 | public static extern bool SetRestitution2(IntPtr obj, float val); | ||
444 | |||
445 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
446 | public static extern bool SetLinearVelocity2(IntPtr obj, Vector3 val); | ||
447 | |||
448 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
449 | public static extern bool SetInterpolation2(IntPtr obj, Vector3 lin, Vector3 ang); | ||
450 | |||
451 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
452 | public static extern IntPtr SetCollisionFlags2(IntPtr obj, uint flags); | ||
453 | |||
454 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
455 | public static extern IntPtr AddToCollisionFlags2(IntPtr obj, uint flags); | ||
456 | |||
457 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
458 | public static extern IntPtr RemoveFromCollisionFlags2(IntPtr obj, uint flags); | ||
459 | |||
460 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
461 | public static extern bool SetMassProps2(IntPtr obj, float mass, Vector3 inertia); | ||
462 | |||
463 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
464 | public static extern bool UpdateInertiaTensor2(IntPtr obj); | ||
465 | |||
466 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
467 | public static extern bool SetGravity2(IntPtr obj, Vector3 val); | ||
468 | |||
469 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
470 | public static extern IntPtr ClearForces2(IntPtr obj); | ||
471 | |||
472 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
473 | public static extern bool SetMargin2(IntPtr obj, float val); | ||
474 | |||
475 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
476 | public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj); | ||
477 | |||
478 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
479 | public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj); | ||
480 | |||
481 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
482 | public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj); | ||
483 | |||
484 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
485 | public static extern bool DestroyObject2(IntPtr world, uint id); | ||
486 | |||
487 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
488 | public static extern void DumpPhysicsStatistics2(IntPtr sim); | ||
489 | |||
271 | } | 490 | } |
272 | } | 491 | } |