AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FrictionModel.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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_FRICTIONMODEL_H
18 #define AGX_FRICTIONMODEL_H
19 
20 #include <agx/Referenced.h>
21 #include <agx/Range.h>
22 #include <agx/Vec3.h>
23 #include <agxStream/Serializable.h>
25 
26 #if defined(_MSC_VER)
27 #pragma warning( push )
28 #pragma warning( disable : 4589 ) // Disable: 4589: Constructor of abstract class 'agx::FrictionModel' ignores initializer for virtual base class 'agxStream::Serializable'
29 #endif
30 
31 
32 // Forward declarations
33 namespace agxCollide
34 {
35  class Geometry;
36  class GeometryContact;
37 }
38 
39 namespace agx
40 {
46  {
47  public:
48  // NOTE: Used to index in arrays.
49  // Think carefully before changing order and/or adding before DIRECT_AND_ITERATIVE.
50  enum SolveType
51  {
55  SPLIT,
57  DIRECT_AND_ITERATIVE
58  };
59 
61  {
62  NONE = 0,
63  INITIALIZE = (1<<0),
64  SCALE_BOUNDS = (1<<1),
65  ITERATIVE_PROJECTION = (1<<2)
66  };
67 
68  public:
77  void setSolveType( SolveType solveType );
78 
82  SolveType getSolveType() const;
83 
87  int getCallbackMask() const;
88 
99  virtual void calculateTangentPlane( const agxCollide::Geometry* geometry1, const agxCollide::Geometry* geometry2, const agx::Vec3& point, const agx::Vec3& normal, const agx::Real depth, agx::Vec3& ret_u, agx::Vec3& ret_v ) const;
100 
109  virtual void initialize( const Physics::GeometryContactPtr geometryContact, size_t pointIndex, agx::Real dt, agx::RangeReal& ret_boundU, agx::RangeReal& ret_boundV ) const = 0;
110 
116  bool needsNlmcpCallbacks() const;
117 
119 
120  protected:
126  FrictionModel( int callbackMask, SolveType preferredSolveType );
127 
131  virtual ~FrictionModel();
132 
137  void restore( agxStream::InputArchive& in ) override;
138 
143  void store( agxStream::OutputArchive& out ) const override;
144 
145  private:
146  SolveType m_solveType;
147  int m_callbackMask;
148  };
149 
150 
151 
153 
163  {
164  public:
169 
178  virtual void initialize( const Physics::GeometryContactPtr geometryContact, size_t pointIndex, agx::Real dt, agx::RangeReal& ret_boundU, agx::RangeReal& ret_boundV ) const override;
179 
183  virtual agx::Real calculateNormalForce( const agxCollide::Geometry* geometry1, const agxCollide::Geometry* geometry2, const agx::Vec3& point, const agx::Vec3& normal, const agx::Real depth, const agx::Real dt, const size_t numPoints ) const;
184 
186 
187  protected:
188  virtual ~BoxFrictionModel() {}
189  };
190 
191 
193 
203  {
204  public:
209 
213  virtual void initialize( const Physics::GeometryContactPtr geometryContact, size_t pointIndex, Real dt, RangeReal& ret_boundU, RangeReal& ret_boundV ) const override;
214 
216 
217  protected:
218  ScaleBoxFrictionModel( int callbackMask, SolveType preferredSolveType ) : FrictionModel( callbackMask, preferredSolveType ) {}
220  };
221 
222 
224 
237  {
238  public:
248 
250 
251  protected:
253  };
254 
256  {
257  return m_solveType;
258  }
259 
261  {
262  return m_callbackMask;
263  }
264 
266  {
267  return (m_callbackMask & SCALE_BOUNDS) != 0 && (m_solveType == DIRECT || m_solveType == DIRECT_AND_ITERATIVE);
268  }
269 }
270 
271 #if defined(_MSC_VER)
272 #pragma warning( pop )
273 #endif
274 
275 #endif
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
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...
Base class for all friction models with interface and some utility/necessary methods implemented...
Definition: FrictionModel.h:45
Normal and friction equation calculated only in the DIRECT solver.
Definition: FrictionModel.h:53
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
int getCallbackMask() const
ScaleBoxFrictionModel(int callbackMask, SolveType preferredSolveType)
#define AGX_FORCE_INLINE
Definition: Object.h:62
bool needsNlmcpCallbacks() const
Base class providing referencing counted objects.
Definition: Referenced.h:113
The geometry representation used by the collision detection engine.
Definition: Geometry.h:88
Scale box friction.
A geometry contact hold contact information between two geometries.
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
First Normal equation is calculated in the DIRECT solver, then in a second pass the normal and the fr...
Definition: FrictionModel.h:55
#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:206
Iterative Projected Cone Friction (IPC friction) model.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Normal and friction equation calculated only in the ITERATIVE solver.
Definition: FrictionModel.h:54
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:220
SolveType getSolveType() const
double Real
Definition: Real.h:42