AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
FrictionModel.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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_FRICTIONMODEL_H
18#define AGX_FRICTIONMODEL_H
19
20#include <agx/Referenced.h>
21#include <agx/Range.h>
22#include <agx/Vec3.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
33namespace agxCollide
34{
35 class Geometry;
36 class GeometryContact;
37}
38
39namespace agxSDK
40{
41 class Simulation;
42}
43
44namespace agx
45{
51 {
52 public:
53 // NOTE: Used to index in arrays.
54 // Think carefully before changing order and/or adding before DIRECT_AND_ITERATIVE.
56 {
60 SPLIT,
62 DIRECT_AND_ITERATIVE
63 };
64
66 {
67 NONE = 0,
68 INITIALIZE = 1 << 0,
69 SCALE_BOUNDS = 1 << 1,
70 ITERATIVE_PROJECTION = 1 << 2,
71 HAS_CUSTOM_CONTACT_IMPLEMENTATION = 1 << 3,
74 ACCURATE_CONE_NL_DIRECT = 1 << 4,
78 };
79
80 public:
89 void setSolveType( SolveType solveType );
90
94 SolveType getSolveType() const;
95
99 int getCallbackMask() const;
100
106
117 virtual void calculateTangentPlane( const agxCollide::Geometry* geometry1,
118 const agxCollide::Geometry* geometry2,
119 const agx::Vec3& point,
120 const agx::Vec3& normal,
121 const agx::Real depth,
122 agx::Vec3& ret_u,
123 agx::Vec3& ret_v ) const;
124
133 virtual void initialize( const Physics::GeometryContactPtr geometryContact,
134 size_t pointIndex,
135 agx::Real dt,
136 agx::RangeReal& ret_boundU,
137 agx::RangeReal& ret_boundV ) const = 0;
138
144 bool needsNlmcpCallbacks() const;
145
151 bool hasCustomContactImplementation() const;
152
158 virtual void matchForCustomContactImplementation( agxCollide::GeometryContact* geometryContact,
159 agxSDK::Simulation* simulation );
160
162
163 protected:
169 FrictionModel( int callbackMask, SolveType preferredSolveType );
170
177
181 virtual ~FrictionModel();
182
187 void restore( agxStream::InputArchive& in ) override;
188
193 void store( agxStream::OutputArchive& out ) const override;
194
195 private:
196 SolveType m_solveType;
197 int m_callbackMask;
198 };
199
200
201
203
213 {
214 public:
219
228 virtual void initialize( const Physics::GeometryContactPtr geometryContact, size_t pointIndex, agx::Real dt, agx::RangeReal& ret_boundU, agx::RangeReal& ret_boundV ) const override;
229
233 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;
234
236
237 protected:
238 virtual ~BoxFrictionModel() {}
239 };
240
241
243
253 {
254 public:
259
263 virtual void initialize( const Physics::GeometryContactPtr geometryContact, size_t pointIndex, Real dt, RangeReal& ret_boundU, RangeReal& ret_boundV ) const override;
264
266
267 protected:
268 ScaleBoxFrictionModel( int callbackMask, SolveType preferredSolveType ) : FrictionModel( callbackMask, preferredSolveType ) {}
270 };
271
272
274
335
337 {
338 return m_solveType;
339 }
340
342 {
343 return m_callbackMask;
344 }
345
347 {
348 return (m_callbackMask & SCALE_BOUNDS) != 0 && (m_solveType == DIRECT || m_solveType == DIRECT_AND_ITERATIVE);
349 }
350
352 {
353 return ( m_callbackMask & HAS_CUSTOM_CONTACT_IMPLEMENTATION ) != 0;
354 }
355
357 agxSDK::Simulation* /*simulation*/ )
358 {
359 }
360}
361
362#if defined(_MSC_VER)
363#pragma warning( pop )
364#endif
365
366#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
A contact between two geometries.
Definition Contacts.h:271
The geometry representation used by the collision detection engine.
Definition Geometry.h:92
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
Class for reading a binary stream of serialized data.
Class for writing serialized data in binary format to a stream.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
virtual void initialize(const Physics::GeometryContactPtr geometryContact, size_t pointIndex, agx::Real dt, agx::RangeReal &ret_boundU, agx::RangeReal &ret_boundV) const override
Initializes the bounds, i.e., max force for the tangential equations.
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
Calculates/estimates the normal force at the current point.
BoxFrictionModel(agx::FrictionModel::SolveType solveType=agx::FrictionModel::SPLIT)
Default constructor with default (preferred) solve type SPLIT.
Base class for all friction models with interface and some utility/necessary methods implemented.
bool hasCustomContactImplementation() const
void setEnableCallbackMask(FrictionCallbackType mask, bool enable)
Enable/disable the given callback mask.
bool getEnableCallbackMask(FrictionCallbackType mask) const
void restore(agxStream::InputArchive &in) override
Restore.
void setSolveType(SolveType solveType)
Solve type for a friction model can be either DIRECT (all equations to the direct solver),...
virtual void initialize(const Physics::GeometryContactPtr geometryContact, size_t pointIndex, agx::Real dt, agx::RangeReal &ret_boundU, agx::RangeReal &ret_boundV) const =0
Initializes bounds given contact point (pointIndex).
FrictionModel(int callbackMask, SolveType preferredSolveType)
Protected constructor given callback bask and preferred solve type.
@ HAS_CUSTOM_CONTACT_IMPLEMENTATION
Custom implementation of the contact constraints associated to this friction model with this state.
@ SCALE_BOUNDS
Scaled bounds, if direct, callbacks from CP-solver.
@ SPLIT
First Normal equation is calculated in the DIRECT solver, then in a second pass the normal and the fr...
@ DIRECT
Normal and friction equation calculated only in the DIRECT solver.
@ ITERATIVE
Normal and friction equation calculated only in the ITERATIVE solver.
@ DIRECT_AND_ITERATIVE
Normal and friction equation calculated both in the ITERATIVE and the DIRECT solver.
bool needsNlmcpCallbacks() const
virtual ~FrictionModel()
Destructor.
SolveType getSolveType() const
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agx::FrictionModel)
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
Calculates friction plane given normal.
virtual void matchForCustomContactImplementation(agxCollide::GeometryContact *geometryContact, agxSDK::Simulation *simulation)
int getCallbackMask() const
void store(agxStream::OutputArchive &out) const override
Store.
Iterative Projected Cone Friction (IPC friction) model.
IterativeProjectedConeFriction(agx::FrictionModel::SolveType solveType=agx::FrictionModel::SPLIT)
Default constructor.
void setEnableDirectExactConeProjection(bool enable)
Enable/disable exact cone projection when solve type is DIRECT.
A geometry contact hold contact information between two geometries.
Base class providing referencing counted objects.
Definition Referenced.h:120
Scale box friction.
virtual void initialize(const Physics::GeometryContactPtr geometryContact, size_t pointIndex, Real dt, RangeReal &ret_boundU, RangeReal &ret_boundV) const override
Initializes the bounds to 0.
ScaleBoxFrictionModel(int callbackMask, SolveType preferredSolveType)
ScaleBoxFrictionModel(agx::FrictionModel::SolveType solveType=agx::FrictionModel::SPLIT)
Default constructor with default (preferred) solve type SPLIT.
#define AGX_FORCE_INLINE
Definition macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition Constraint.h:31
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition Real.h:42