BulletSimAPI.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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.Runtime.InteropServices;
  29. using System.Security;
  30. using System.Text;
  31. using OpenMetaverse;
  32. namespace OpenSim.Region.Physics.BulletSPlugin {
  33. // Classes to allow some type checking for the API
  34. public struct BulletSim
  35. {
  36. public BulletSim(uint id, IntPtr xx) { ID = id; Ptr = xx; }
  37. public IntPtr Ptr;
  38. public uint ID;
  39. }
  40. public struct BulletBody
  41. {
  42. public BulletBody(uint id, IntPtr xx) { ID = id; Ptr = xx; }
  43. public IntPtr Ptr;
  44. public uint ID;
  45. }
  46. public struct BulletConstraint
  47. {
  48. public BulletConstraint(IntPtr xx) { Ptr = xx; }
  49. public IntPtr Ptr;
  50. }
  51. // ===============================================================================
  52. [StructLayout(LayoutKind.Sequential)]
  53. public struct ConvexHull
  54. {
  55. Vector3 Offset;
  56. int VertexCount;
  57. Vector3[] Vertices;
  58. }
  59. [StructLayout(LayoutKind.Sequential)]
  60. public struct ShapeData
  61. {
  62. public enum PhysicsShapeType
  63. {
  64. SHAPE_UNKNOWN = 0,
  65. SHAPE_AVATAR = 1,
  66. SHAPE_BOX = 2,
  67. SHAPE_CONE = 3,
  68. SHAPE_CYLINDER = 4,
  69. SHAPE_SPHERE = 5,
  70. SHAPE_MESH = 6,
  71. SHAPE_HULL = 7
  72. };
  73. public uint ID;
  74. public PhysicsShapeType Type;
  75. public Vector3 Position;
  76. public Quaternion Rotation;
  77. public Vector3 Velocity;
  78. public Vector3 Scale;
  79. public float Mass;
  80. public float Buoyancy;
  81. public System.UInt64 HullKey;
  82. public System.UInt64 MeshKey;
  83. public float Friction;
  84. public float Restitution;
  85. public float Collidable; // true of things bump into this
  86. public float Static; // true if a static object. Otherwise gravity, etc.
  87. // note that bools are passed as floats since bool size changes by language and architecture
  88. public const float numericTrue = 1f;
  89. public const float numericFalse = 0f;
  90. }
  91. [StructLayout(LayoutKind.Sequential)]
  92. public struct SweepHit
  93. {
  94. public uint ID;
  95. public float Fraction;
  96. public Vector3 Normal;
  97. public Vector3 Point;
  98. }
  99. [StructLayout(LayoutKind.Sequential)]
  100. public struct RaycastHit
  101. {
  102. public uint ID;
  103. public float Fraction;
  104. public Vector3 Normal;
  105. }
  106. [StructLayout(LayoutKind.Sequential)]
  107. public struct CollisionDesc
  108. {
  109. public uint aID;
  110. public uint bID;
  111. public Vector3 point;
  112. public Vector3 normal;
  113. }
  114. [StructLayout(LayoutKind.Sequential)]
  115. public struct EntityProperties
  116. {
  117. public uint ID;
  118. public Vector3 Position;
  119. public Quaternion Rotation;
  120. public Vector3 Velocity;
  121. public Vector3 Acceleration;
  122. public Vector3 RotationalVelocity;
  123. }
  124. // Format of this structure must match the definition in the C++ code
  125. [StructLayout(LayoutKind.Sequential)]
  126. public struct ConfigurationParameters
  127. {
  128. public float defaultFriction;
  129. public float defaultDensity;
  130. public float defaultRestitution;
  131. public float collisionMargin;
  132. public float gravity;
  133. public float linearDamping;
  134. public float angularDamping;
  135. public float deactivationTime;
  136. public float linearSleepingThreshold;
  137. public float angularSleepingThreshold;
  138. public float ccdMotionThreshold;
  139. public float ccdSweptSphereRadius;
  140. public float contactProcessingThreshold;
  141. public float terrainFriction;
  142. public float terrainHitFraction;
  143. public float terrainRestitution;
  144. public float avatarFriction;
  145. public float avatarDensity;
  146. public float avatarRestitution;
  147. public float avatarCapsuleRadius;
  148. public float avatarCapsuleHeight;
  149. public float avatarContactProcessingThreshold;
  150. public float maxPersistantManifoldPoolSize;
  151. public float shouldDisableContactPoolDynamicAllocation;
  152. public float shouldForceUpdateAllAabbs;
  153. public float shouldRandomizeSolverOrder;
  154. public float shouldSplitSimulationIslands;
  155. public float shouldEnableFrictionCaching;
  156. public float numberOfSolverIterations;
  157. public float linkConstraintUseFrameOffset;
  158. public float linkConstraintEnableTransMotor;
  159. public float linkConstraintTransMotorMaxVel;
  160. public float linkConstraintTransMotorMaxForce;
  161. public float linkConstraintERP;
  162. public float linkConstraintCFM;
  163. public const float numericTrue = 1f;
  164. public const float numericFalse = 0f;
  165. }
  166. // Values used by Bullet and BulletSim to control collisions
  167. public enum CollisionFlags : uint
  168. {
  169. CF_STATIC_OBJECT = 1 << 0,
  170. CF_KINEMATIC_OBJECT = 1 << 1,
  171. CF_NO_CONTACT_RESPONSE = 1 << 2,
  172. CF_CUSTOM_MATERIAL_CALLBACK = 1 << 3,
  173. CF_CHARACTER_OBJECT = 1 << 4,
  174. CF_DISABLE_VISUALIZE_OBJECT = 1 << 5,
  175. CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6,
  176. // Following used by BulletSim to control collisions
  177. BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10,
  178. BS_VOLUME_DETECT_OBJECT = 1 << 11,
  179. BS_PHANTOM_OBJECT = 1 << 12,
  180. BS_PHYSICAL_OBJECT = 1 << 13,
  181. };
  182. // CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0
  183. // ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2.
  184. public enum ConstraintParams : int
  185. {
  186. BT_CONSTRAINT_ERP = 1, // this one is not used in Bullet as of 20120730
  187. BT_CONSTRAINT_STOP_ERP,
  188. BT_CONSTRAINT_CFM,
  189. BT_CONSTRAINT_STOP_CFM,
  190. };
  191. public enum ConstraintParamAxis : int
  192. {
  193. AXIS_LINEAR_X = 0,
  194. AXIS_LINEAR_Y,
  195. AXIS_LINEAR_Z,
  196. AXIS_ANGULAR_X,
  197. AXIS_ANGULAR_Y,
  198. AXIS_ANGULAR_Z,
  199. AXIS_LINEAR_ALL = 20, // these last three added by BulletSim so we don't have to do zillions of calls
  200. AXIS_ANGULAR_ALL,
  201. AXIS_ALL
  202. };
  203. // ===============================================================================
  204. static class BulletSimAPI {
  205. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  206. [return: MarshalAs(UnmanagedType.LPStr)]
  207. public static extern string GetVersion();
  208. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  209. public static extern uint Initialize(Vector3 maxPosition, IntPtr parms,
  210. int maxCollisions, IntPtr collisionArray,
  211. int maxUpdates, IntPtr updateArray);
  212. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  213. public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
  214. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  215. public static extern void Shutdown(uint worldID);
  216. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  217. public static extern bool UpdateParameter(uint worldID, uint localID,
  218. [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value);
  219. // ===============================================================================
  220. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  221. public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep,
  222. out int updatedEntityCount,
  223. out IntPtr updatedEntitiesPtr,
  224. out int collidersCount,
  225. out IntPtr collidersPtr);
  226. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  227. public static extern bool CreateHull(uint worldID, System.UInt64 meshKey,
  228. int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls
  229. );
  230. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  231. public static extern bool CreateMesh(uint worldID, System.UInt64 meshKey,
  232. int indexCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
  233. int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices
  234. );
  235. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  236. public static extern bool DestroyHull(uint worldID, System.UInt64 meshKey);
  237. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  238. public static extern bool DestroyMesh(uint worldID, System.UInt64 meshKey);
  239. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  240. public static extern bool CreateObject(uint worldID, ShapeData shapeData);
  241. /* Remove old functionality
  242. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  243. public static extern void CreateLinkset(uint worldID, int objectCount, ShapeData[] shapeDatas);
  244. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  245. public static extern void AddConstraint(uint worldID, uint id1, uint id2,
  246. Vector3 frame1, Quaternion frame1rot,
  247. Vector3 frame2, Quaternion frame2rot,
  248. Vector3 lowLinear, Vector3 hiLinear, Vector3 lowAngular, Vector3 hiAngular);
  249. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  250. public static extern bool RemoveConstraintByID(uint worldID, uint id1);
  251. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  252. public static extern bool RemoveConstraint(uint worldID, uint id1, uint id2);
  253. */
  254. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  255. public static extern Vector3 GetObjectPosition(uint WorldID, uint id);
  256. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  257. public static extern Quaternion GetObjectOrientation(uint WorldID, uint id);
  258. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  259. public static extern bool SetObjectTranslation(uint worldID, uint id, Vector3 position, Quaternion rotation);
  260. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  261. public static extern bool SetObjectVelocity(uint worldID, uint id, Vector3 velocity);
  262. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  263. public static extern bool SetObjectAngularVelocity(uint worldID, uint id, Vector3 angularVelocity);
  264. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  265. public static extern bool SetObjectForce(uint worldID, uint id, Vector3 force);
  266. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  267. public static extern bool SetObjectScaleMass(uint worldID, uint id, Vector3 scale, float mass, bool isDynamic);
  268. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  269. public static extern bool SetObjectCollidable(uint worldID, uint id, bool phantom);
  270. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  271. public static extern bool SetObjectDynamic(uint worldID, uint id, bool isDynamic, float mass);
  272. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  273. public static extern bool SetObjectGhost(uint worldID, uint id, bool ghostly);
  274. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  275. public static extern bool SetObjectProperties(uint worldID, uint id, bool isStatic, bool isSolid, bool genCollisions, float mass);
  276. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  277. public static extern bool SetObjectBuoyancy(uint worldID, uint id, float buoyancy);
  278. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  279. public static extern bool HasObject(uint worldID, uint id);
  280. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  281. public static extern bool DestroyObject(uint worldID, uint id);
  282. // ===============================================================================
  283. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  284. public static extern SweepHit ConvexSweepTest(uint worldID, uint id, Vector3 to, float extraMargin);
  285. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  286. public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vector3 to);
  287. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  288. public static extern Vector3 RecoverFromPenetration(uint worldID, uint id);
  289. // ===============================================================================
  290. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  291. public static extern void DumpBulletStatistics();
  292. // Log a debug message
  293. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  294. public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
  295. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  296. public static extern void SetDebugLogCallback(DebugLogCallback callback);
  297. // ===============================================================================
  298. // ===============================================================================
  299. // ===============================================================================
  300. // A new version of the API that enables moving all the logic out of the C++ code and into
  301. // the C# code. This will make modifications easier for the next person.
  302. // This interface passes the actual pointers to the objects in the unmanaged
  303. // address space. All the management (calls for creation/destruction/lookup)
  304. // is done in the C# code.
  305. // The names have a "2" tacked on. This will be removed as the C# code gets rebuilt
  306. // and the old code is removed.
  307. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  308. public static extern IntPtr GetSimHandle2(uint worldID);
  309. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  310. public static extern IntPtr GetBodyHandleWorldID2(uint worldID, uint id);
  311. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  312. public static extern IntPtr GetBodyHandle2(IntPtr sim, uint id);
  313. // ===============================================================================
  314. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  315. public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
  316. int maxCollisions, IntPtr collisionArray,
  317. int maxUpdates, IntPtr updateArray);
  318. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  319. public static extern bool UpdateParameter2(IntPtr sim, uint localID, String parm, float value);
  320. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  321. public static extern void SetHeightmap2(IntPtr sim, float[] heightmap);
  322. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  323. public static extern void Shutdown2(IntPtr sim);
  324. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  325. public static extern int PhysicsStep2(IntPtr sim, float timeStep, int maxSubSteps, float fixedTimeStep,
  326. out int updatedEntityCount,
  327. out IntPtr updatedEntitiesPtr,
  328. out int collidersCount,
  329. out IntPtr collidersPtr);
  330. /*
  331. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  332. public static extern IntPtr CreateMesh2(IntPtr sim, int indicesCount, int* indices, int verticesCount, float* vertices );
  333. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  334. public static extern bool BuildHull2(IntPtr sim, IntPtr mesh);
  335. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  336. public static extern bool ReleaseHull2(IntPtr sim, IntPtr mesh);
  337. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  338. public static extern bool DestroyMesh2(IntPtr sim, IntPtr mesh);
  339. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  340. public static extern IntPtr CreateObject2(IntPtr sim, ShapeData shapeData);
  341. */
  342. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  343. public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2,
  344. Vector3 frame1loc, Quaternion frame1rot,
  345. Vector3 frame2loc, Quaternion frame2rot,
  346. bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
  347. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  348. public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
  349. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  350. public static extern bool SetAngularLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
  351. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  352. public static extern bool UseFrameOffset2(IntPtr constrain, float enable);
  353. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  354. public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce);
  355. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  356. public static extern bool CalculateTransforms2(IntPtr constrain);
  357. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  358. public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
  359. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  360. public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain);
  361. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  362. public static extern Vector3 GetPosition2(IntPtr obj);
  363. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  364. public static extern Quaternion GetOrientation2(IntPtr obj);
  365. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  366. public static extern bool SetTranslation2(IntPtr obj, Vector3 position, Quaternion rotation);
  367. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  368. public static extern bool SetVelocity2(IntPtr obj, Vector3 velocity);
  369. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  370. public static extern bool SetAngularVelocity2(IntPtr obj, Vector3 angularVelocity);
  371. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  372. public static extern bool SetObjectForce2(IntPtr obj, Vector3 force);
  373. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  374. public static extern bool AddObjectForce2(IntPtr obj, Vector3 force);
  375. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  376. public static extern bool SetCcdMotionThreshold2(IntPtr obj, float val);
  377. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  378. public static extern bool SetCcdSweepSphereRadius2(IntPtr obj, float val);
  379. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  380. public static extern bool SetDamping2(IntPtr obj, float lin_damping, float ang_damping);
  381. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  382. public static extern bool SetDeactivationTime2(IntPtr obj, float val);
  383. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  384. public static extern bool SetSleepingThresholds2(IntPtr obj, float lin_threshold, float ang_threshold);
  385. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  386. public static extern bool SetContactProcessingThreshold2(IntPtr obj, float val);
  387. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  388. public static extern bool SetFriction2(IntPtr obj, float val);
  389. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  390. public static extern bool SetRestitution2(IntPtr obj, float val);
  391. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  392. public static extern bool SetLinearVelocity2(IntPtr obj, Vector3 val);
  393. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  394. public static extern bool SetInterpolation2(IntPtr obj, Vector3 lin, Vector3 ang);
  395. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  396. public static extern IntPtr SetCollisionFlags2(IntPtr obj, CollisionFlags flags);
  397. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  398. public static extern IntPtr AddToCollisionFlags2(IntPtr obj, CollisionFlags flags);
  399. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  400. public static extern IntPtr RemoveFromCollisionFlags2(IntPtr obj, CollisionFlags flags);
  401. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  402. public static extern bool SetMassProps2(IntPtr obj, float mass, Vector3 inertia);
  403. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  404. public static extern bool UpdateInertiaTensor2(IntPtr obj);
  405. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  406. public static extern bool SetGravity2(IntPtr obj, Vector3 val);
  407. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  408. public static extern IntPtr ClearForces2(IntPtr obj);
  409. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  410. public static extern bool SetMargin2(IntPtr obj, float val);
  411. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  412. public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj);
  413. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  414. public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj);
  415. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  416. public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
  417. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  418. public static extern bool DestroyObject2(IntPtr world, uint id);
  419. [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
  420. public static extern void DumpPhysicsStatistics2(IntPtr sim);
  421. }
  422. }