AGX Dynamics  2.37.2.0
Convex.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 
19 #include <agx/agxPhysics_export.h>
20 #include <agxCollide/Shape.h>
21 
22 #include <agxStream/Serializable.h>
23 
24 #include <agx/agx_vector_types.h>
25 #include <agx/SPDMatrix3x3.h>
26 #include <agxCollide/Trimesh.h>
27 
28 namespace agxCollide
29 {
30 
37  {
38  public:
57  Convex( const agx::Vec3Vector* vertices, const agx::UInt32Vector* indices,
58  const char* sourceName,
59  uint32_t optionsMask = Trimesh::REMOVE_DUPLICATE_VERTICES );
60 
65  virtual bool hasSupportFunction() const override;
66 
68  virtual agx::Vec3 getSupportPoint( const agx::Vec3& supportDirection ) const override;
69 
77  Convex* shallowCopy() const;
78 
87  Convex* deepCopy() const;
88 
89  virtual Shape *clone() const override;
90 
91 
93 
94  private:
95 
97  Convex();
98 
100  Convex( const Convex& convex );
101 
103  Convex& operator=(const Convex& convex);
104 
105  protected:
107  virtual ~Convex();
108 
109  };
110 
113  {
114  return true;
115  }
116 
117 
119  {
120  if ( m_collisionMeshData->m_vertices.empty() )
121  return agx::Vec3();
122  else {
123  agx::Real maxDist = -agx::RealMax;
124  size_t maxIndex = 0;
125  for (size_t i = 0; i < m_collisionMeshData->m_vertices.size(); ++i) {
126  const agx::Real dist = m_collisionMeshData->m_vertices[i] * supportDirection;
127  if (dist > maxDist) {
128  maxDist = dist;
129  maxIndex = i;
130  }
131  }
132  return m_collisionMeshData->m_vertices[maxIndex];
133  }
134  }
135 
136 
137 
138 }
139 
Removes exactly identical duplicates in the vertices, as well as (resulting or previously existing) t...
Definition: Trimesh.h:77
Base class for a shape.
Definition: Shape.h:53
This namespace consists of a set of classes for handling geometric intersection tests including boole...
#define AGXPHYSICS_EXPORT
virtual bool hasSupportFunction() const override
Inherited from Shape.
Definition: Convex.h:112
A convex class for geometric intersection tests.
Definition: Convex.h:36
#define AGX_FORCE_INLINE
Definition: Object.h:59
virtual agx::Vec3 getSupportPoint(const agx::Vec3 &supportDirection) const override
Definition: Convex.h:118
#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
AGXCORE_EXPORT const Real RealMax
double Real
Definition: Real.h:42
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:42
AGX_DECLARE_POINTER_TYPES(SpaceListener)