AGX Dynamics  2.37.3.2
SleepThreshold.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_SleepThreshold_H
18 #define AGX_SleepThreshold_H
19 
20 #include <agx/agxPhysics_export.h>
21 #include <agxStream/Serializable.h>
22 
23 namespace agx
24 {
25 
29  {
30  public:
31 
38  inline SleepThreshold( float velocity=float(0.05),
39  float acceleration=float(0.2),
40  float angularVelocity=float(1E10),
41  float angularAcceleration=1E10
42  );
43 
45  inline float getVelocity() const;
46 
48  inline float getAngularVelocity() const;
49 
51  inline float getAcceleration() const;
52 
54  inline float getAngularAcceleration() const;
55 
56 
57  // Squared
59  inline float getVelocity2() const;
60 
62  inline float getAngularVelocity2() const;
63 
65  inline float getAcceleration2() const;
66 
68  inline float getAngularAcceleration2() const;
69 
70  // Setters
72  inline void setVelocity( float vel );
73 
75  inline void setAngularVelocity( float vel );
76 
78  inline void setAcceleration( float acc );
79 
81  inline void setAngularAcceleration( float acc );
82 
84 
85  protected:
86 
87 
88 
89  float m_velocityThreshold;
93 
94  // float m_velocityThreshold2;
95  // float m_accelerationThreshold2;
96  // float m_angularVelocityThreshold2;
97  // float m_angularAccelerationThreshold2;
98 
99  };
100 
102 
103 
105 
107 
109  {
110  public:
111 
112  AutoSleepThreshold( float velocity=float(0.05),
113  float acceleration=1E10,
114  float angularVelocity=float(0.05),
115  float angularAcceleration=1E10,
116  float time=float(0.8) );
117 
122  inline void setTime( float time );
123 
128  inline float getTime() const;
129 
131 
132  protected:
133  float m_time;
134  };
135 
137 
138 
139  // Implementation
140  inline SleepThreshold::SleepThreshold( float velocity, float acceleration, float angularVelocity, float angularAcceleration ) :
141  m_velocityThreshold(velocity), m_accelerationThreshold(acceleration), m_angularVelocityThreshold( angularVelocity ), m_angularAccelerationThreshold(angularAcceleration)
142  {
143  // m_velocityThreshold2 = m_velocityThreshold*m_velocityThreshold;
144  // m_accelerationThreshold2=m_accelerationThreshold*m_accelerationThreshold;
145  // m_angularVelocityThreshold2=m_angularVelocityThreshold*m_angularVelocityThreshold;
146  // m_angularAccelerationThreshold2=m_angularAccelerationThreshold*m_angularAccelerationThreshold;
147  }
148 
149  inline float SleepThreshold::getVelocity() const { return m_velocityThreshold; }
151 
152  inline void SleepThreshold::setVelocity( float vel ) { m_velocityThreshold = vel; }
153  inline void SleepThreshold::setAcceleration( float acc ) { m_accelerationThreshold = acc; }
155 
158 
161 
164 
166 
167  inline void AutoSleepThreshold::setTime( float time ) { m_time = time; }
168  inline float AutoSleepThreshold::getTime( ) const { return m_time; }
169 
170  inline std::ostream& operator <<(std::ostream& out, const SleepThreshold& t)
171  {
172  out << "Vt: " << t.getVelocity() << " AVt: " << t.getAngularVelocity() << " At: " << t.getAcceleration() << " AAt: " << t.getAngularAcceleration() << std::endl;
173  return out;
174  }
175 }
176 
177 #endif /* AGX_SleepThreshold_H */
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive...
float getAngularVelocity() const
agx::ref_ptr< SleepThreshold > SleepThresholdRef
float m_angularVelocityThreshold
#define AGXPHYSICS_EXPORT
agx::ref_ptr< MergeSplitThreshold > MergeSplitThresholdRef
float getTime() const
Get the time-window during which the body must be below velocity/acceleration threshold before it is ...
Base class providing referencing counted objects.
Definition: Referenced.h:119
float getVelocity() const
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
float getAcceleration2() const
float getVelocity2() const
float getAngularAcceleration() const
void setAngularVelocity(float vel)
Set the threshold of the angular velocity magnitude when a body should be put to sleep.
float getAngularAcceleration2() const
void setVelocity(float vel)
Set the threshold of the linear velocity magnitude when a body should be put to sleep.
void setAngularAcceleration(float acc)
Set the threshold of the angular acceleration magnitude when a body should be put to sleep...
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
std::ostream & operator<<(std::ostream &os, const agx::AddedMassInteraction::Matrix6x6 &m)
agx::ref_ptr< AutoSleepThreshold > AutoSleepThresholdRef
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
float getAcceleration() const
float getAngularVelocity2() const
SleepThreshold MergeSplitThreshold
void setTime(float time)
Set the time-window during which the body must be below velocity/acceleration threshold before it is ...
SleepThreshold(float velocity=float(0.05), float acceleration=float(0.2), float angularVelocity=float(1E10), float angularAcceleration=1E10)
float m_angularAccelerationThreshold
void setAcceleration(float acc)
set the threshold of the linear acceleration magnitude when a body should be put to sleep ...