[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / Bullet3OpenCL / RigidBody / b3GpuRigidBodyPipeline.h
1 /*
2 Copyright (c) 2013 Advanced Micro Devices, Inc.  
3
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose, 
7 including commercial applications, and to alter it and redistribute it freely, 
8 subject to the following restrictions:
9
10 1. 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.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
13 */
14 //Originally written by Erwin Coumans
15
16 #ifndef B3_GPU_RIGIDBODY_PIPELINE_H
17 #define B3_GPU_RIGIDBODY_PIPELINE_H
18
19 #include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
20 #include "Bullet3Collision/NarrowPhaseCollision/b3Config.h"
21
22 #include "Bullet3Common/b3AlignedObjectArray.h"
23 #include "Bullet3Collision/NarrowPhaseCollision/b3RaycastInfo.h"
24
25 class b3GpuRigidBodyPipeline
26 {
27 protected:
28         struct b3GpuRigidBodyPipelineInternalData* m_data;
29
30         int allocateCollidable();
31
32 public:
33         b3GpuRigidBodyPipeline(cl_context ctx, cl_device_id device, cl_command_queue q, class b3GpuNarrowPhase* narrowphase, class b3GpuBroadphaseInterface* broadphaseSap, struct b3DynamicBvhBroadphase* broadphaseDbvt, const b3Config& config);
34         virtual ~b3GpuRigidBodyPipeline();
35
36         void stepSimulation(float deltaTime);
37         void integrate(float timeStep);
38         void setupGpuAabbsFull();
39
40         int registerConvexPolyhedron(class b3ConvexUtility* convex);
41
42         //int           registerConvexPolyhedron(const float* vertices, int strideInBytes, int numVertices, const float* scaling);
43         //int           registerSphereShape(float radius);
44         //int           registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
45
46         //int           registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
47         //int           registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
48
49         int registerPhysicsInstance(float mass, const float* position, const float* orientation, int collisionShapeIndex, int userData, bool writeInstanceToGpu);
50         //if you passed "writeInstanceToGpu" false in the registerPhysicsInstance method (for performance) you need to call writeAllInstancesToGpu after all instances are registered
51         void writeAllInstancesToGpu();
52         void copyConstraintsToHost();
53         void setGravity(const float* grav);
54         void reset();
55
56         int createPoint2PointConstraint(int bodyA, int bodyB, const float* pivotInA, const float* pivotInB, float breakingThreshold);
57         int createFixedConstraint(int bodyA, int bodyB, const float* pivotInA, const float* pivotInB, const float* relTargetAB, float breakingThreshold);
58         void removeConstraintByUid(int uid);
59
60         void addConstraint(class b3TypedConstraint* constraint);
61         void removeConstraint(b3TypedConstraint* constraint);
62
63         void castRays(const b3AlignedObjectArray<b3RayInfo>& rays, b3AlignedObjectArray<b3RayHit>& hitResults);
64
65         cl_mem getBodyBuffer();
66
67         int getNumBodies() const;
68 };
69
70 #endif  //B3_GPU_RIGIDBODY_PIPELINE_H