AGX Dynamics  2.35.0.1
Convex.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 AGXCOLLIDE_CONVEX_H
18 #define AGXCOLLIDE_CONVEX_H
19 
20 #include <agx/agxPhysics_export.h>
21 #include <agxCollide/Shape.h>
22 
23 #include <agxStream/Serializable.h>
24 
25 #include <agx/agx_vector_types.h>
26 #include <agx/SPDMatrix3x3.h>
27 #include <agxCollide/Trimesh.h>
28 
29 namespace agxCollide
30 {
31 
38  {
39  public:
58  Convex( const agx::Vec3Vector* vertices, const agx::UInt32Vector* indices,
59  const char* sourceName,
60  uint32_t optionsMask = Trimesh::REMOVE_DUPLICATE_VERTICES );
61 
66  virtual bool hasSupportFunction() const override;
67 
69  virtual agx::Vec3 getSupportPoint( const agx::Vec3& supportDirection ) const override;
70 
78  Convex* shallowCopy() const;
79 
88  Convex* deepCopy() const;
89 
90  virtual Shape *clone() const override;
91 
92 
94 
95  private:
96 
98  Convex();
99 
101  Convex( const Convex& convex );
102 
104  Convex& operator=(const Convex& convex);
105 
106  protected:
108  virtual ~Convex();
109 
110  };
111 
114  {
115  return true;
116  }
117 
118 
120  {
121  if ( m_collisionMeshData->m_vertices.empty() )
122  return agx::Vec3();
123  else {
124  agx::Real maxDist = -agx::RealMax;
125  size_t maxIndex = 0;
126  for (size_t i = 0; i < m_collisionMeshData->m_vertices.size(); ++i) {
127  const agx::Real dist = m_collisionMeshData->m_vertices[i] * supportDirection;
128  if (dist > maxDist) {
129  maxDist = dist;
130  maxIndex = i;
131  }
132  }
133  return m_collisionMeshData->m_vertices[maxIndex];
134  }
135  }
136 
137 
138 
139 }
140 
141 #endif
142 
#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
#define AGXPHYSICS_EXPORT
A convex class for geometric intersection tests.
Definition: Convex.h:38
virtual ~Convex()
Hiding destructor.
Convex(const agx::Vec3Vector *vertices, const agx::UInt32Vector *indices, const char *sourceName, uint32_t optionsMask=Trimesh::REMOVE_DUPLICATE_VERTICES)
Constructs a new Convex object from a vector of vertices and indices each.
virtual agx::Vec3 getSupportPoint(const agx::Vec3 &supportDirection) const override
Definition: Convex.h:119
virtual Shape * clone() const override
Create a clone.
Convex * deepCopy() const
Creates a new Convex which copies data from this one.
virtual bool hasSupportFunction() const override
Inherited from Shape.
Definition: Convex.h:113
Convex * shallowCopy() const
Creates a new Convex which shares data with this one.
CollisionMeshDataRef m_collisionMeshData
Definition: Mesh.h:633
Base class for a shape.
Definition: Shape.h:54
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:43
@ REMOVE_DUPLICATE_VERTICES
Removes exactly identical duplicates in the vertices, as well as (resulting or previously existing) t...
Definition: Trimesh.h:77
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
AGX_DECLARE_POINTER_TYPES(SpaceListener)
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: agx/Vec3.h:36
AGXCORE_EXPORT const Real RealMax
double Real
Definition: Real.h:42