AGX Dynamics  2.38.0.2
ElementaryContactPoint.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 #pragma once
18 
20 
21 namespace agx
22 {
25 
42  {
43  public:
48  struct InputData
49  {
50  Real h;
55  InputData& operator = ( const InputData& ) = delete;
56  };
57 
58  public:
75  static Real calculateNormalEpsilonAsCompliance( const agxCollide::ContactPoint& contactPoint, const InputData& inputData );
76 
77  public:
86  Real calculateNormalImpactSpeed( const agxCollide::ContactPoint& contactPoint, const InputData& inputData ) const;
87 
97  Real calculateImpactSpeed( Real restitution, Vec3f direction, const InputData& inputData ) const;
98 
102  Vec3 getCmOffset1() const;
103 
107  Vec3 getCmOffset2() const;
108 
112  Vec3 getContactPointPosition() const;
113 
114  public:
119  virtual void initialize( agxCollide::ContactPoint& contactPoint, const InputData& inputData ) final;
120 
128  virtual void configure( agxCollide::ContactPoint& contactPoint, const InputData& inputData ) = 0;
129 
134  virtual void renderDebug() const;
135 
152  virtual void onPostSolve( agxCollide::ContactPoint& contactPoint, const Real* solution, Real h ) const = 0;
153 
157  virtual UInt getViolation( Real* g, UInt row ) override;
158 
163  virtual UInt getBounds( RangeReal* bounds, UInt row, Real h ) const override;
164 
168  virtual UInt getVelocity( Real* v, UInt row ) const override;
169 
173  virtual Bool isImpacting() const override;
174 
175  protected:
182  ElementaryContactPoint( UInt numRows );
183 
184  virtual ~ElementaryContactPoint();
185 
186  protected:
195  };
196 
198  {
199  return m_cmOffset1;
200  }
201 
203  {
204  return m_cmOffset2;
205  }
206 
208  {
209  return m_contactPointPosition;
210  }
211 
213 
221  {
222  public:
236  ElementaryContactPoint* get( size_t localIndex );
237 
243  size_t begin();
244 
248  void end();
249 
253  void reset();
254 
258  const ElementaryContactPointRefVector& getCache() const;
259 
260  public:
267  virtual ElementaryContactPoint* createInstance() = 0;
268 
269  protected:
274  void increaseCache( size_t size );
275 
276  protected:
279 
280  private:
282  size_t m_currentStartIndex;
283  size_t m_maxLocalIndex;
284  };
285 }
agx::ElementaryContactPoint::InputData::contactMaterial
const ContactMaterial & contactMaterial
Contact material in the geometry contact.
Definition: ElementaryContactPoint.h:53
agx::UInt
uint64_t UInt
Definition: Integer.h:27
agx::ElementaryContactPoint::getCmOffset1
Vec3 getCmOffset1() const
Definition: ElementaryContactPoint.h:197
agx::end
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Definition: LinearProbingHashSet.h:593
agx::ElementaryConstraint
Elementary constraint base class with interface and global constraint functionality.
Definition: ElementaryConstraint.h:53
agx::Real
double Real
Definition: Real.h:42
agx::ElementaryContactPoint::m_normalForceRange
RangeReal m_normalForceRange
Definition: ElementaryContactPoint.h:192
agx::Vector< ElementaryContactPointRef >
agx::ElementaryContactPoint::m_cmOffset2
Vec3 m_cmOffset2
Definition: ElementaryContactPoint.h:189
agx::ElementaryContactPoint::InputData::h
Real h
Time step size.
Definition: ElementaryContactPoint.h:50
agx::ElementaryContactPoint::m_velocity
RealValarray m_velocity
Definition: ElementaryContactPoint.h:194
agxCollide::ContactPoint
A contact point in a contact data.
Definition: Contacts.h:55
agx::ElementaryContactPointFactory
Interface factory for custom contact point constraint implementations.
Definition: ElementaryContactPoint.h:220
agx::ElementaryContactPoint::m_relativeSurfaceVelocity
Vec3 m_relativeSurfaceVelocity
Definition: ElementaryContactPoint.h:190
agxSDK::MergeSplitUtils::calculateImpactSpeed
agx::Real calculateImpactSpeed(const agx::Vec3 &point, const agx::Vec3f &normal, const agx::Vec3 &cmPos, const agx::Vec3 &linVel, const agx::Vec3 &angVel)
Calculates impact speed of one body given contact point and normal.
Definition: MergeSplitUtils.h:89
ConstraintImplementation.h
agx::ElementaryContactPoint::m_cmOffset1
Vec3 m_cmOffset1
Definition: ElementaryContactPoint.h:188
agx::ElementaryContactPoint::getCmOffset2
Vec3 getCmOffset2() const
Definition: ElementaryContactPoint.h:202
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::ConstraintImplementation::SolverBodyView
Definition: ConstraintImplementation.h:286
agx::begin
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Definition: LinearProbingHashSet.h:587
agx::ElementaryContactPoint::m_contactPointPosition
Vec3 m_contactPointPosition
Definition: ElementaryContactPoint.h:187
agx::ElementaryContactPoint
Base class of custom implementations of contact point constraints.
Definition: ElementaryContactPoint.h:41
agx::ElementaryContactPoint::m_normalViolation
Real m_normalViolation
Definition: ElementaryContactPoint.h:191
agx::ContactMaterial
This class store the combine material properties between two agx::Material's.
Definition: Material.h:515
agx::RealValarray
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Definition: agx_valarray_types.h:27
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agx::Bool
bool Bool
Definition: Integer.h:40
agx::ElementaryContactPoint::getContactPointPosition
Vec3 getContactPointPosition() const
Definition: ElementaryContactPoint.h:207
agx::ElementaryContactPoint::InputData::impactCondition
Real impactCondition
Minimum speed >= 0 that can generate an impact.
Definition: ElementaryContactPoint.h:51
agx::ElementaryContactPoint::m_frictionEnabled
Bool m_frictionEnabled
Definition: ElementaryContactPoint.h:193
agx::Range< Real >
agx::Vec3T< Real32 >
agx::ElementaryContactPoint::InputData::bodies
const ConstraintImplementation::SolverBodyView bodies
Bodies in the geometry contact.
Definition: ElementaryContactPoint.h:52
agx::ElementaryContactPoint::InputData
Input data of the geometry contact, which is constant for all contact points.
Definition: ElementaryContactPoint.h:48