AGX Dynamics 2.42.3.0
Loading...
Searching...
No Matches
Convex.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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 <agxCollide/Trimesh.h>
26
27namespace agxCollide
28{
29
36 {
37 public:
56 Convex( const agx::Vec3Vector* vertices, const agx::UInt32Vector* indices,
57 const char* sourceName,
58 uint32_t optionsMask = Trimesh::REMOVE_DUPLICATE_VERTICES );
59
64 virtual bool hasSupportFunction() const override;
65
67 virtual agx::Vec3 getSupportPoint( const agx::Vec3& supportDirection ) const override;
68
77
86 Convex* deepCopy() const;
87
88 virtual Shape *clone() const override;
89
90
92
93 private:
94
96 Convex();
97
99 Convex( const Convex& convex );
100
102 Convex& operator=(const Convex& convex);
103
104 protected:
106 virtual ~Convex();
107
108 };
109
112 {
113 return true;
114 }
115
116
118 {
119 if ( m_collisionMeshData->m_vertices.empty() )
120 return agx::Vec3();
121 else {
122 agx::Real maxDist = -agx::RealMax;
123 size_t maxIndex = 0;
124 for (size_t i = 0; i < m_collisionMeshData->m_vertices.size(); ++i) {
125 const agx::Real dist = m_collisionMeshData->m_vertices[i] * supportDirection;
126 if (dist > maxDist) {
127 maxDist = dist;
128 maxIndex = i;
129 }
130 }
131 return m_collisionMeshData->m_vertices[maxIndex];
132 }
133 }
134
135
136
137}
138
#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...
Definition: Serializable.h:207
#define AGXPHYSICS_EXPORT
A convex class for geometric intersection tests.
Definition: Convex.h:36
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:117
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:111
virtual Shape * clone() const override
Create a clone.
CollisionMeshDataRef m_collisionMeshData
Definition: Mesh.h:633
Base class for a shape.
Definition: Shape.h:58
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:40
#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:41