AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
RigidBodyState.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGX_RIGIDBODYSTATE_H
18#define AGX_RIGIDBODYSTATE_H
19
20#include <agx/Math.h>
21#include <agx/BitSet_small.h>
22#include <agxData/Type.h>
23
25
26namespace agx
27{
28 class RigidBodyState : public BitSet_small<agx::UInt32>
29 {
30 public:
31 RigidBodyState();
32 agx::UInt32 motionControl() const;
33 bool handleAsParticle() const;
34 bool hasEffectiveMass() const;
35 bool hasEffectiveInertia() const;
36 bool enabled() const;
37 bool removed() const;
38 bool mergedRootBody() const;
39 bool powerline() const;
40 bool isKinematicForParticles() const;
41
42 void setKinematicForParticles(bool flag);
43
44 private:
45 friend class RigidBody;
46 friend class DynamicsSystem;
47 friend class MergedBody;
48 friend class MassPropertiesUpdate;
49
50 void setMotionControl(agx::UInt32 motionControl);
51 void setHandleAsParticle(bool flag);
52 void setHasEffectiveMass(bool flag);
53 void setHasEffectiveInertia(bool flag);
54 void setEnabled(bool flag);
55 void setRemoved(bool flag);
56 void setMergedRootBody(bool flag);
57 void setPowerline(bool flag);
58
59 enum Bit : agx::UInt32
60 {
61 PARTICLE_KINEMATIC_BIT = 29,
62 HYDRAULICS_BIT = 28,
63 MERGED_ROOT_BODY_BIT = 25,
64 //AVAILABLE = 24, // This bit mask is available for future use.
65 REMOVED_BIT = 20,
66 HAS_EFFECTIVE_INERTIA_BIT = 18,
67 HAS_EFFECTIVE_MASS_BIT = 17,
68 HANDLE_AS_PARTICLE_BIT = 16,
69 ENABLE_BIT = 12
70 };
71 };
72
73 /* Implementation */
74 AGX_FORCE_INLINE RigidBodyState::RigidBodyState() : BitSet_small<UInt32>()
75 {
76 this->set(ENABLE_BIT, true);
77 }
78
79 AGX_FORCE_INLINE agx::UInt32 RigidBodyState::motionControl() const
80 {
81 return (agx::UInt32)(m_state & 0x3);
82 }
83
84 AGX_FORCE_INLINE bool RigidBodyState::handleAsParticle() const
85 {
86 return this->test(HANDLE_AS_PARTICLE_BIT);
87 }
88
89 AGX_FORCE_INLINE bool RigidBodyState::hasEffectiveMass() const
90 {
91 return this->test(HAS_EFFECTIVE_MASS_BIT);
92 }
93
94 AGX_FORCE_INLINE bool RigidBodyState::hasEffectiveInertia() const
95 {
96 return this->test(HAS_EFFECTIVE_INERTIA_BIT);
97 }
98
99 AGX_FORCE_INLINE bool RigidBodyState::enabled() const
100 {
101 return this->test(ENABLE_BIT);
102 }
103
104 AGX_FORCE_INLINE bool RigidBodyState::removed() const
105 {
106 return this->test(REMOVED_BIT);
107 }
108
109 AGX_FORCE_INLINE bool RigidBodyState::mergedRootBody() const
110 {
111 return this->test(MERGED_ROOT_BODY_BIT);
112 }
113
114 AGX_FORCE_INLINE bool RigidBodyState::powerline() const
115 {
116 return this->test(HYDRAULICS_BIT);
117 }
118
119 AGX_FORCE_INLINE bool RigidBodyState::isKinematicForParticles() const
120 {
121 return this->test(PARTICLE_KINEMATIC_BIT);
122 }
123
124 AGX_FORCE_INLINE void RigidBodyState::setMotionControl(agx::UInt32 motionControl)
125 {
126 m_state = ( m_state & ~0x3 ) | ((agx::UInt32)motionControl);
127 }
128
129 AGX_FORCE_INLINE void RigidBodyState::setEnabled(bool flag)
130 {
131 this->set(ENABLE_BIT, flag);
132 }
133
134 AGX_FORCE_INLINE void RigidBodyState::setHandleAsParticle(bool flag)
135 {
136 this->set(HANDLE_AS_PARTICLE_BIT, flag);
137 }
138
139 AGX_FORCE_INLINE void RigidBodyState::setHasEffectiveMass(bool flag)
140 {
141 this->set(HAS_EFFECTIVE_MASS_BIT, flag);
142 }
143
144 AGX_FORCE_INLINE void RigidBodyState::setHasEffectiveInertia(bool flag)
145 {
146 this->set(HAS_EFFECTIVE_INERTIA_BIT, flag);
147 }
148
149 AGX_FORCE_INLINE void RigidBodyState::setRemoved(bool flag)
150 {
151 this->set(REMOVED_BIT, flag);
152 }
153
154 AGX_FORCE_INLINE void RigidBodyState::setMergedRootBody(bool flag)
155 {
156 this->set(MERGED_ROOT_BODY_BIT, flag);
157 }
158
159 AGX_FORCE_INLINE void RigidBodyState::setPowerline(bool flag)
160 {
161 this->set(HYDRAULICS_BIT, flag);
162 }
163
164 inline void RigidBodyState::setKinematicForParticles(bool flag)
165 {
166 this->set(PARTICLE_KINEMATIC_BIT, flag);
167 }
168
169 std::ostream& operator << ( std::ostream& output, const RigidBodyState& state );
170}
171
172AGX_TYPE_BINDING(agx::RigidBodyState, "RigidBodyState")
173
175
176#endif /* AGX_RIGIDBODYSTATE_H */
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
std::ostream & operator<<(std::ostream &o, const agx::Vec6 &v)
Definition: Vec6.h:230
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
#define AGX_FORCE_INLINE
Definition: macros.h:58
AGXPHYSICS_EXPORT void setMotionControl(agx::RigidBodyPtrVector &bodies, agx::RigidBody::MotionControl motionControl)
Utility function to set motion control for a vector of rigid bodies.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:32