b3GpuRigidBodyPipeline.h 3.2 KB

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