PhysicsDirect.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef PHYSICS_DIRECT_H
  2. #define PHYSICS_DIRECT_H
  3. //#include "SharedMemoryCommands.h"
  4. #include "PhysicsClient.h"
  5. #include "LinearMath/btVector3.h"
  6. ///todo: the PhysicsClient API was designed with shared memory in mind,
  7. ///now it become more general we need to move out the shared memory specifics away
  8. ///for example naming [disconnectSharedMemory -> disconnect] [ move setSharedMemoryKey to shared memory specific subclass ]
  9. ///PhysicsDirect executes the commands directly, without transporting them or having a separate server executing commands
  10. class PhysicsDirect : public PhysicsClient
  11. {
  12. protected:
  13. struct PhysicsDirectInternalData* m_data;
  14. bool processDebugLines(const struct SharedMemoryCommand& orgCommand);
  15. bool processCamera(const struct SharedMemoryCommand& orgCommand);
  16. bool processContactPointData(const struct SharedMemoryCommand& orgCommand);
  17. void processBodyJointInfo(int bodyUniqueId, const struct SharedMemoryStatus& serverCmd);
  18. public:
  19. PhysicsDirect();
  20. virtual ~PhysicsDirect();
  21. // return true if connection succesfull, can also check 'isConnected'
  22. //it is OK to pass a null pointer for the gui helper
  23. virtual bool connect();
  24. ////todo: rename to 'disconnect'
  25. virtual void disconnectSharedMemory();
  26. virtual bool isConnected() const;
  27. // return non-null if there is a status, nullptr otherwise
  28. virtual const SharedMemoryStatus* processServerStatus();
  29. virtual SharedMemoryCommand* getAvailableSharedMemoryCommand();
  30. virtual bool canSubmitCommand() const;
  31. virtual bool submitClientCommand(const struct SharedMemoryCommand& command);
  32. virtual int getNumBodies() const;
  33. virtual int getBodyUniqueId(int serialIndex) const;
  34. virtual bool getBodyInfo(int bodyUniqueId, struct b3BodyInfo& info) const;
  35. virtual int getNumJoints(int bodyIndex) const;
  36. virtual bool getJointInfo(int bodyIndex, int jointIndex, struct b3JointInfo& info) const;
  37. ///todo: move this out of the
  38. virtual void setSharedMemoryKey(int key);
  39. void uploadBulletFileToSharedMemory(const char* data, int len);
  40. virtual int getNumDebugLines() const;
  41. virtual const float* getDebugLinesFrom() const;
  42. virtual const float* getDebugLinesTo() const;
  43. virtual const float* getDebugLinesColor() const;
  44. virtual void getCachedCameraImage(b3CameraImageData* cameraData);
  45. virtual void getCachedContactPointInformation(struct b3ContactInformation* contactPointData);
  46. //those 2 APIs are for internal use for visualization
  47. virtual bool connect(struct GUIHelperInterface* guiHelper);
  48. virtual void renderScene();
  49. virtual void debugDraw(int debugDrawMode);
  50. };
  51. #endif //PHYSICS_DIRECT_H