9 #include <argos3/core/utility/logging/argos_log.h>
10 #include <argos3/core/utility/math/vector3.h>
11 #include <argos3/core/utility/string_utilities.h>
12 #include <argos3/core/simulator/simulator.h>
13 #include <argos3/core/simulator/space/space.h>
14 #include <argos3/core/simulator/entity/entity.h>
30 for(
size_t i = 0; i < vecEngines.size(); ++i)
31 vecEngines[i]->CheckIntersectionWithRay(t_data, c_ray);
35 return !t_data.empty();
50 for(
size_t i = 0; i < tData.size(); ++i) {
51 if(s_item.
TOnRay > tData[i].TOnRay)
71 for(
size_t i = 0; i < tData.size(); ++i) {
72 if(s_item.
TOnRay > tData[i].TOnRay &&
73 &c_entity != tData[i].IntersectedEntity) {
85 Real CPhysicsEngine::m_fSimulationClockTick = 0.1f;
86 Real CPhysicsEngine::m_fInverseSimulationClockTick = 1.0f / CPhysicsEngine::m_fSimulationClockTick;
115 CVector2 cFirstPoint, cLastPoint, cCurPoint;
116 std::string strConnectWith;
120 tVertexIt = tVertexIt.begin(&tNode);
121 if(tVertexIt == tVertexIt.end()) {
125 cLastPoint = cFirstPoint;
128 while(tVertexIt != tVertexIt.end()) {
133 psFace->BaseSegment.SetEnd(cCurPoint);
134 SideFaces.push_back(psFace);
136 cLastPoint = cCurPoint;
140 if(SideFaces.size() < 3) {
143 if(cLastPoint != cFirstPoint) {
146 psFace->BaseSegment.SetEnd(cFirstPoint);
147 SideFaces.push_back(psFace);
160 if(TopFace)
delete TopFace;
161 if(BottomFace)
delete BottomFace;
162 while(!SideFaces.empty()) {
163 delete SideFaces.back();
164 SideFaces.pop_back();
172 return TopFace || BottomFace || (!SideFaces.empty());
180 m_fPhysicsClockTick(m_fSimulationClockTick) {}
192 LOG <<
"[INFO] The physics engine \""
194 <<
"\" will perform "
196 <<
" iterations per tick (dt = "
235 if(fCriterion < 0.0f) {
247 m_vecTransferData.push_back(&c_entity);
254 for(
size_t i = 0; i < m_vecTransferData.size(); ++i) {
258 m_vecTransferData.clear();
265 return m_fSimulationClockTick;
272 return m_fInverseSimulationClockTick;
279 LOG <<
"[INFO] Using simulation clock tick = " << f_simulation_clock_tick << std::endl;
280 m_fSimulationClockTick = f_simulation_clock_tick;
281 m_fInverseSimulationClockTick = 1.0f / f_simulation_clock_tick;
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
TConfigurationNode & GetNode(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns the first of its child nodes with the wanted name.
bool GetClosestEmbodiedEntityIntersectedByRay(SEmbodiedEntityIntersectionItem &s_item, const CRay3 &c_ray)
Returns the closest intersection with an embodied entity to the ray start.
void GetNodeAttributeOrDefault(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer, const T &t_default)
Returns the value of a node's attribute, or the passed default value.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
bool NodeExists(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns true if one of its child nodes has the wanted name.
bool GetEmbodiedEntitiesIntersectedByRay(TEmbodiedEntityIntersectionData &t_data, const CRay3 &c_ray)
Checks whether the given ray intersects any entity.
std::vector< SEmbodiedEntityIntersectionItem > TEmbodiedEntityIntersectionData
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
This entity is a link to a body in the physics engine.
CEmbodiedEntity * IntersectedEntity
static Real GetSimulationClockTick()
Returns the simulation clock tick.
virtual bool IsPointContained(const CVector3 &c_point)
Returns true if the given point is contained in this physics engine.
SVolume & GetVolume()
Returns the boundary faces for the volume associated to this engine.
virtual void ScheduleEntityForTransfer(CEmbodiedEntity &c_entity)
Schedules an entity of transfer.
std::vector< CPhysicsEngine * > TVector
static Real GetInverseSimulationClockTick()
Returns the inverse of GetSimulationClockTick().
const std::string & GetId() const
Returns the id of this physics engine.
virtual void Init(TConfigurationNode &t_tree)
Initializes the resource.
Real GetPhysicsClockTick() const
Returns the length of the physics engine tick.
static void SetSimulationClockTick(Real f_simulation_clock_tick)
Sets the simulation clock tick.
virtual void TransferEntities()
Executes the transfer of entities to other engines.
bool IsEntityTransferActive() const
Returns true if entity transfer is active for this engine.
virtual bool RemoveEntity(CEntity &c_entity)=0
Removes an entity from the physics engine.
A boundary face for top/bottom parts of the volume.
A boundary face for side parts of the volume.
std::vector< SVerticalFace * > SideFaces
void Init(TConfigurationNode &t_node)
SHorizontalFace * TopFace
SHorizontalFace * BottomFace
CSpace & GetSpace() const
Returns a reference to the simulated space.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
CPhysicsEngine::TVector & GetPhysicsEngines()
Returns the list of currently existing physics engines.
virtual void AddEntityToPhysicsEngine(CEmbodiedEntity &c_entity)
The exception that wraps all errors in ARGoS.
void SetStart(const CVector2 &c_start)
Real GetY() const
Returns the y coordinate of this vector.
Real GetX() const
Returns the x coordinate of this vector.
Real GetX() const
Returns the x coordinate of this vector.
Real GetY() const
Returns the y coordinate of this vector.
Real GetZ() const
Returns the z coordinate of this vector.