7 #ifndef DYNAMICS3D_ENGINE_H
8 #define DYNAMICS3D_ENGINE_H
11 class CDynamics3DEngine;
12 class CDynamics3DModel;
13 class CDynamics3DPlugin;
16 #include <argos3/core/simulator/entity/controllable_entity.h>
17 #include <argos3/core/simulator/physics_engine/physics_engine.h>
18 #include <argos3/core/utility/math/ray2.h>
19 #include <argos3/core/utility/math/rng.h>
22 #pragma clang diagnostic push
23 #pragma clang diagnostic ignored "-Wreorder"
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wreorder"
29 #include <argos3/plugins/simulator/physics_engines/dynamics3d/bullet/btBulletDynamicsCommon.h>
30 #include <argos3/plugins/simulator/physics_engines/dynamics3d/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h>
31 #include <argos3/plugins/simulator/physics_engines/dynamics3d/bullet/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h>
32 #include <argos3/plugins/simulator/physics_engines/dynamics3d/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h>
35 #pragma clang diagnostic pop
37 #pragma GCC diagnostic pop
70 const CRay3& c_ray)
const;
77 return m_tPhysicsPlugins;
89 return m_fDefaultFriction;
104 std::map<std::string, CDynamics3DModel*> m_tPhysicsModels;
105 std::map<std::string, CDynamics3DPlugin*> m_tPhysicsPlugins;
110 std::string m_strDebugFilename;
112 btScalar m_fDefaultFriction;
114 btDbvtBroadphase m_cBroadphase;
115 btDefaultCollisionConfiguration m_cConfiguration;
116 btCollisionDispatcher m_cDispatcher;
117 btMultiBodyConstraintSolver m_cSolver;
118 btMultiBodyDynamicsWorld m_cWorld;
124 template <
typename ACTION>
140 #define REGISTER_DYNAMICS3D_OPERATION(ACTION, OPERATION, ENTITY) \
141 REGISTER_ENTITY_OPERATION(ACTION, CDynamics3DEngine, OPERATION, SOperationOutcome, ENTITY);
143 #define REGISTER_STANDARD_DYNAMICS3D_OPERATION_ADD_ENTITY(SPACE_ENTITY, DYN3D_MODEL) \
144 class CDynamics3DOperationAdd ## SPACE_ENTITY : public CDynamics3DOperationAddEntity { \
146 CDynamics3DOperationAdd ## SPACE_ENTITY() {} \
147 virtual ~CDynamics3DOperationAdd ## SPACE_ENTITY() {} \
148 SOperationOutcome ApplyTo(CDynamics3DEngine& c_engine, \
149 SPACE_ENTITY& c_entity) { \
150 auto* pcPhysModel = new DYN3D_MODEL(c_engine, \
152 c_engine.AddPhysicsModel(c_entity.GetId(), \
155 GetComponent<CEmbodiedEntity>("body"). \
156 AddPhysicsModel(c_engine.GetId(), *pcPhysModel); \
157 return SOperationOutcome(true); \
160 REGISTER_DYNAMICS3D_OPERATION(CDynamics3DOperationAddEntity, \
161 CDynamics3DOperationAdd ## SPACE_ENTITY, \
164 #define REGISTER_STANDARD_DYNAMICS3D_OPERATION_REMOVE_ENTITY(SPACE_ENTITY) \
165 class CDynamics3DOperationRemove ## SPACE_ENTITY : public CDynamics3DOperationRemoveEntity { \
167 CDynamics3DOperationRemove ## SPACE_ENTITY() {} \
168 virtual ~CDynamics3DOperationRemove ## SPACE_ENTITY() {} \
169 SOperationOutcome ApplyTo(CDynamics3DEngine& c_engine, \
170 SPACE_ENTITY& c_entity) { \
171 c_engine.RemovePhysicsModel(c_entity.GetId()); \
173 GetComponent<CEmbodiedEntity>("body"). \
174 RemovePhysicsModel(c_engine.GetId()); \
175 return SOperationOutcome(true); \
178 REGISTER_DYNAMICS3D_OPERATION(CDynamics3DOperationRemoveEntity, \
179 CDynamics3DOperationRemove ## SPACE_ENTITY, \
182 #define REGISTER_STANDARD_DYNAMICS3D_OPERATIONS_ON_ENTITY(SPACE_ENTITY, DYN3D_ENTITY) \
183 REGISTER_STANDARD_DYNAMICS3D_OPERATION_ADD_ENTITY(SPACE_ENTITY, DYN3D_ENTITY) \
184 REGISTER_STANDARD_DYNAMICS3D_OPERATION_REMOVE_ENTITY(SPACE_ENTITY)
The namespace containing all the ARGoS related code.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
std::vector< SEmbodiedEntityIntersectionItem > TEmbodiedEntityIntersectionData
The basic operation to be stored in the vtable.
virtual size_t GetNumPhysicsModels()
btMultiBodyDynamicsWorld & GetWorld()
void AddPhysicsModel(const std::string &str_id, CDynamics3DModel &c_model)
void RemovePhysicsModel(const std::string &str_id)
virtual bool AddEntity(CEntity &c_entity)
Adds an entity to the physics engine.
btCollisionDispatcher & GetDispatcher()
const btCollisionDispatcher & GetDispatcher() const
virtual void CheckIntersectionWithRay(TEmbodiedEntityIntersectionData &t_data, const CRay3 &c_ray) const
Check which objects in this engine intersect the given ray.
virtual bool RemoveEntity(CEntity &c_entity)
Removes an entity from the physics engine.
virtual void Reset()
Resets the resource.
btScalar GetDefaultFriction() const
virtual void Destroy()
Undoes whatever was done by Init().
std::map< std::string, CDynamics3DPlugin * > & GetPhysicsPlugins()
void AddPhysicsPlugin(const std::string &str_id, CDynamics3DPlugin &c_plugin)
void RemovePhysicsPlugin(const std::string &str_id)
virtual void PostSpaceInit()
Executes extra initialization activities after the space has been initialized.
virtual ~CDynamics3DEngine()
virtual void Init(TConfigurationNode &t_tree)
Initializes the resource.
virtual ~CDynamics3DOperation()
virtual ~CDynamics3DOperationAddEntity()
virtual ~CDynamics3DOperationRemoveEntity()