Newton Dynamics  4.00
ndShapeChamferCylinder.h
1 /* Copyright (c) <2003-2022> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __ND_SHAPE_CHAMFER_CYLINDER_H__
23 #define __ND_SHAPE_CHAMFER_CYLINDER_H__
24 
25 #include "ndShapeConvex.h"
26 
27 #define DG_CHAMFERCYLINDER_SLICES 4
28 #define DG_CHAMFERCYLINDER_BRAKES 8
29 #define DG_MAX_CHAMFERCYLINDER_DIR_COUNT 8
30 
32 {
33  public:
34  D_CLASS_REFLECTION(ndShapeChamferCylinder);
35  D_COLLISION_API ndShapeChamferCylinder(ndFloat32 radius, ndFloat32 height);
36  D_COLLISION_API ndShapeChamferCylinder(const ndLoadSaveBase::ndLoadDescriptor& desc);
37  D_COLLISION_API virtual ~ndShapeChamferCylinder();
38 
39  virtual ndShapeChamferCylinder* GetAsShapeChamferCylinder() { return this; }
40 
41  protected:
42 
43  D_COLLISION_API void Init(ndFloat32 radius, ndFloat32 height);
44 
45  D_COLLISION_API virtual ndShapeInfo GetShapeInfo() const;
46  D_COLLISION_API virtual void CalculateAabb(const ndMatrix& matrix, ndVector& p0, ndVector& p1) const;
47  D_COLLISION_API virtual void DebugShape(const ndMatrix& matrix, ndShapeDebugNotify& debugCallback) const;
48  D_COLLISION_API virtual ndVector SupportVertexSpecialProjectPoint(const ndVector& point, const ndVector& dir) const;
49  D_COLLISION_API virtual ndVector SupportVertex(const ndVector& dir, ndInt32* const vertexIndex) const;
50  D_COLLISION_API virtual ndVector SupportVertexSpecial(const ndVector& dir, ndFloat32 skinMargin, ndInt32* const vertexIndex) const;
51  D_COLLISION_API virtual ndFloat32 RayCast(ndRayCastNotify& callback, const ndVector& localP0, const ndVector& localP1, ndFloat32 maxT, const ndBody* const body, ndContactPoint& contactOut) const;
52  D_COLLISION_API virtual void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
53 
54  virtual ndInt32 CalculatePlaneIntersection(const ndVector& normal, const ndVector& point, ndVector* const contactsOut) const;
55 
56  private:
57  ndFloat32 m_height;
58  ndFloat32 m_radius;
59 
60  ndVector m_vertex[DG_CHAMFERCYLINDER_BRAKES * (DG_CHAMFERCYLINDER_SLICES + 1)];
61  static ndInt32 m_shapeRefCount;
62  static ndConvexSimplexEdge m_edgeArray[];
63  static ndVector m_shapesDirs[];
64  static ndVector m_yzMask;
65 
66  friend class dgWorld;
67 };
68 
69 #endif
70 
ndBody
Definition: ndBody.h:43
ndShapeChamferCylinder
Definition: ndShapeChamferCylinder.h:32
ndRayCastNotify
Definition: ndRayCastNotify.h:31
ndShapeConvex::ndConvexSimplexEdge
Definition: ndShapeConvex.h:38
ndShapeConvex
Definition: ndShapeConvex.h:34
ndContactPoint
Definition: ndContact.h:39
ndMatrix
Definition: ndMatrix.h:42
ndShapeDebugNotify
Definition: ndShapeInstance.h:38
ndShapeInfo
Definition: ndShape.h:182
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndVector
Definition: ndVectorArmNeon.h:41