AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
Convex.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#pragma once
18
20#include <agxCollide/Shape.h>
21
23
25#include <agx/SPDMatrix3x3.h>
26#include <agxCollide/Trimesh.h>
27
28namespace 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
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
#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 convex class for geometric intersection tests.
Definition Convex.h:37
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:118
Convex * shallowCopy() const
Creates a new Convex which shares data with this one.
Convex * deepCopy() const
Creates a new Convex which copies data from this one.
virtual bool hasSupportFunction() const override
Inherited from Shape.
Definition Convex.h:112
virtual Shape * clone() const override
Create a clone.
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
#define AGX_FORCE_INLINE
Definition macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
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