Newton Dynamics  4.00
ndShapeSphere.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_SPHERE_H__
23 #define __ND_SHAPE_SPHERE_H__
24 
25 #include "ndShapeConvex.h"
26 
27 #define D_SPHERE_VERTEX_COUNT 18
28 
29 D_MSV_NEWTON_ALIGN_32
31 {
32  public:
33  D_CLASS_REFLECTION(ndShapeSphere);
34  D_COLLISION_API ndShapeSphere(ndFloat32 radius);
35  D_COLLISION_API ndShapeSphere(const ndLoadSaveBase::ndLoadDescriptor& desc);
36  D_COLLISION_API virtual ~ndShapeSphere();
37 
38  virtual ndShapeSphere* GetAsShapeSphere() { return this; }
39 
40  protected:
41  D_COLLISION_API void Init(ndFloat32 radius);
42  D_COLLISION_API virtual void MassProperties();
43 
44  D_COLLISION_API virtual ndShapeInfo GetShapeInfo() const;
45  D_COLLISION_API virtual void CalculateAabb(const ndMatrix& matrix, ndVector& p0, ndVector& p1) const;
46  D_COLLISION_API virtual void DebugShape(const ndMatrix& matrix, ndShapeDebugNotify& debugCallback) const;
47  D_COLLISION_API virtual ndVector SupportVertexSpecialProjectPoint(const ndVector& point, const ndVector& dir) const;
48  D_COLLISION_API virtual ndVector SupportVertex(const ndVector& dir, ndInt32* const vertexIndex) const;
49  D_COLLISION_API virtual ndVector SupportVertexSpecial(const ndVector& dir, ndFloat32 skinMargin, ndInt32* const vertexIndex) const;
50  D_COLLISION_API virtual ndFloat32 RayCast(ndRayCastNotify& callback, const ndVector& localP0, const ndVector& localP1, ndFloat32 maxT, const ndBody* const body, ndContactPoint& contactOut) const;
51  D_COLLISION_API virtual void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
52 
53  virtual ndInt32 CalculatePlaneIntersection(const ndVector& normal, const ndVector& point, ndVector* const contactsOut) const;
54 
55  void TesselateTriangle(ndInt32 level, const ndVector& p0, const ndVector& p1, const ndVector& p2, ndInt32& count, ndVector* const ouput) const;
56 
57  ndVector m_vertex[D_SPHERE_VERTEX_COUNT];
58  ndFloat32 m_radius;
59 
60  static ndInt32 m_shapeRefCount;
61  static ndVector m_unitSphere[];
62  static ndConvexSimplexEdge m_edgeArray[];
63 
64 } D_GCC_NEWTON_ALIGN_32;
65 
66 
67 #endif
68 
ndBody
Definition: ndBody.h:43
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
ndShapeSphere
Definition: ndShapeSphere.h:31
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndVector
Definition: ndVectorArmNeon.h:41