1/*
2 * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12
13
14#ifndef PX_PHYSICS_NX_SPHERE_GEOMETRY
15#define PX_PHYSICS_NX_SPHERE_GEOMETRY
16/** \addtogroup geomutils
17@{
18*/
19#include "geometry/PxGeometry.h"
20
21#ifndef PX_DOXYGEN
22namespace physx
23{
24#endif
25
26/**
27\brief A class representing the geometry of a sphere.
28
29Spheres are defined by their radius.
30\note The scaling of the sphere is expected to be baked into this value, there is no additional scaling parameter.
31*/
32class PxSphereGeometry : public PxGeometry
33{
34public:
35 PX_INLINE PxSphereGeometry() : PxGeometry(PxGeometryType::eSPHERE), radius(0) {}
36 PX_INLINE PxSphereGeometry(PxReal ir) : PxGeometry(PxGeometryType::eSPHERE), radius(ir) {}
37
38 /**
39 \brief Returns true if the geometry is valid.
40
41 \return True if the current settings are valid
42
43 \note A valid sphere has radius > 0.
44 It is illegal to call PxRigidActor::createShape and PxPhysics::createShape with a sphere that has zero radius.
45
46 @see PxRigidActor::createShape, PxPhysics::createShape
47 */
48 PX_INLINE bool isValid() const;
49
50public:
51
52 /**
53 \brief The radius of the sphere.
54 */
55 PxReal radius;
56};
57
58
59PX_INLINE bool PxSphereGeometry::isValid() const
60{
61 if (mType != PxGeometryType::eSPHERE)
62 return false;
63 if (!PxIsFinite(radius))
64 return false;
65 if (radius <= 0.0f)
66 return false;
67
68 return true;
69}
70
71#ifndef PX_DOXYGEN
72} // namespace physx
73#endif
74
75/** @} */
76#endif
77