Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/Bullet-C-Api.h @ 8444

Last change on this file since 8444 was 8393, checked in by rgrieder, 14 years ago

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

  • Property svn:eol-style set to native
File size: 7.1 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16/*
17        Draft high-level generic physics C-API. For low-level access, use the physics SDK native API's.
18        Work in progress, functionality will be added on demand.
19
20        If possible, use the richer Bullet C++ API, by including "btBulletDynamicsCommon.h"
21*/
22
23#ifndef BULLET_C_API_H
24#define BULLET_C_API_H
25
26#define PL_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
27
28#ifdef BT_USE_DOUBLE_PRECISION
29typedef double  plReal;
30#else
31typedef float   plReal;
32#endif
33
34typedef plReal  plVector3[3];
35typedef plReal  plQuaternion[4];
36
37#ifdef __cplusplus
38extern "C" { 
39#endif
40
41/**     Particular physics SDK (C-API) */
42        PL_DECLARE_HANDLE(plPhysicsSdkHandle);
43
44/**     Dynamics world, belonging to some physics SDK (C-API)*/
45        PL_DECLARE_HANDLE(plDynamicsWorldHandle);
46
47/** Rigid Body that can be part of a Dynamics World (C-API)*/   
48        PL_DECLARE_HANDLE(plRigidBodyHandle);
49
50/**     Collision Shape/Geometry, property of a Rigid Body (C-API)*/
51        PL_DECLARE_HANDLE(plCollisionShapeHandle);
52
53/** Constraint for Rigid Bodies (C-API)*/
54        PL_DECLARE_HANDLE(plConstraintHandle);
55
56/** Triangle Mesh interface (C-API)*/
57        PL_DECLARE_HANDLE(plMeshInterfaceHandle);
58
59/** Broadphase Scene/Proxy Handles (C-API)*/
60        PL_DECLARE_HANDLE(plCollisionBroadphaseHandle);
61        PL_DECLARE_HANDLE(plBroadphaseProxyHandle);
62        PL_DECLARE_HANDLE(plCollisionWorldHandle);
63
64/**
65        Create and Delete a Physics SDK
66*/
67
68        extern  plPhysicsSdkHandle      plNewBulletSdk(void); //this could be also another sdk, like ODE, PhysX etc.
69        extern  void            plDeletePhysicsSdk(plPhysicsSdkHandle   physicsSdk);
70
71/** Collision World, not strictly necessary, you can also just create a Dynamics World with Rigid Bodies which internally manages the Collision World with Collision Objects */
72
73        typedef void(*btBroadphaseCallback)(void* clientData, void* object1,void* object2);
74
75        extern plCollisionBroadphaseHandle      plCreateSapBroadphase(btBroadphaseCallback beginCallback,btBroadphaseCallback endCallback);
76
77        extern void     plDestroyBroadphase(plCollisionBroadphaseHandle bp);
78
79        extern  plBroadphaseProxyHandle plCreateProxy(plCollisionBroadphaseHandle bp, void* clientData, plReal minX,plReal minY,plReal minZ, plReal maxX,plReal maxY, plReal maxZ);
80
81        extern void plDestroyProxy(plCollisionBroadphaseHandle bp, plBroadphaseProxyHandle proxyHandle);
82
83        extern void plSetBoundingBox(plBroadphaseProxyHandle proxyHandle, plReal minX,plReal minY,plReal minZ, plReal maxX,plReal maxY, plReal maxZ);
84
85/* todo: add pair cache support with queries like add/remove/find pair */
86       
87        extern plCollisionWorldHandle plCreateCollisionWorld(plPhysicsSdkHandle physicsSdk);
88
89/* todo: add/remove objects */
90       
91
92/* Dynamics World */
93
94        extern  plDynamicsWorldHandle plCreateDynamicsWorld(plPhysicsSdkHandle physicsSdk);
95
96        extern  void           plDeleteDynamicsWorld(plDynamicsWorldHandle world);
97
98        extern  void    plStepSimulation(plDynamicsWorldHandle, plReal  timeStep);
99
100        extern  void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object);
101
102        extern  void plRemoveRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object);
103
104
105/* Rigid Body  */
106
107        extern  plRigidBodyHandle plCreateRigidBody(    void* user_data,  float mass, plCollisionShapeHandle cshape );
108
109        extern  void plDeleteRigidBody(plRigidBodyHandle body);
110
111
112/* Collision Shape definition */
113
114        extern  plCollisionShapeHandle plNewSphereShape(plReal radius);
115        extern  plCollisionShapeHandle plNewBoxShape(plReal x, plReal y, plReal z);
116        extern  plCollisionShapeHandle plNewCapsuleShape(plReal radius, plReal height); 
117        extern  plCollisionShapeHandle plNewConeShape(plReal radius, plReal height);
118        extern  plCollisionShapeHandle plNewCylinderShape(plReal radius, plReal height);
119        extern  plCollisionShapeHandle plNewCompoundShape(void);
120        extern  void    plAddChildShape(plCollisionShapeHandle compoundShape,plCollisionShapeHandle childShape, plVector3 childPos,plQuaternion childOrn);
121
122        extern  void plDeleteShape(plCollisionShapeHandle shape);
123
124        /* Convex Meshes */
125        extern  plCollisionShapeHandle plNewConvexHullShape(void);
126        extern  void            plAddVertex(plCollisionShapeHandle convexHull, plReal x,plReal y,plReal z);
127/* Concave static triangle meshes */
128        extern  plMeshInterfaceHandle              plNewMeshInterface(void);
129        extern  void            plAddTriangle(plMeshInterfaceHandle meshHandle, plVector3 v0,plVector3 v1,plVector3 v2);
130        extern  plCollisionShapeHandle plNewStaticTriangleMeshShape(plMeshInterfaceHandle);
131
132        extern  void plSetScaling(plCollisionShapeHandle shape, plVector3 scaling);
133
134/* SOLID has Response Callback/Table/Management */
135/* PhysX has Triggers, User Callbacks and filtering */
136/* ODE has the typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2); */
137
138/*      typedef void plUpdatedPositionCallback(void* userData, plRigidBodyHandle        rbHandle, plVector3 pos); */
139/*      typedef void plUpdatedOrientationCallback(void* userData, plRigidBodyHandle     rbHandle, plQuaternion orientation); */
140
141        /* get world transform */
142        extern void     plGetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix);
143        extern void     plGetPosition(plRigidBodyHandle object,plVector3 position);
144        extern void plGetOrientation(plRigidBodyHandle object,plQuaternion orientation);
145
146        /* set world transform (position/orientation) */
147        extern  void plSetPosition(plRigidBodyHandle object, const plVector3 position);
148        extern  void plSetOrientation(plRigidBodyHandle object, const plQuaternion orientation);
149        extern  void plSetEuler(plReal yaw,plReal pitch,plReal roll, plQuaternion orient);
150        extern  void plSetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix);
151
152        typedef struct plRayCastResult {
153                plRigidBodyHandle               m_body; 
154                plCollisionShapeHandle  m_shape;               
155                plVector3                               m_positionWorld;               
156                plVector3                               m_normalWorld;
157        } plRayCastResult;
158
159        extern  int plRayCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plRayCastResult res);
160
161        /* Sweep API */
162
163        /* extern  plRigidBodyHandle plObjectCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plVector3 hitpoint, plVector3 normal); */
164
165        /* Continuous Collision Detection API */
166       
167        // needed for source/blender/blenkernel/intern/collision.c
168        double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float q2[3], float q3[3], float *pa, float *pb, float normal[3]);
169
170#ifdef __cplusplus
171}
172#endif
173
174
175#endif //BULLET_C_API_H
176
Note: See TracBrowser for help on using the repository browser.