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_BOX_GEOMETRY
15#define PX_PHYSICS_NX_BOX_GEOMETRY
16/** \addtogroup geomutils
17@{
18*/
19#include "geometry/PxGeometry.h"
20#include "foundation/PxVec3.h"
21
22#ifndef PX_DOXYGEN
23namespace physx
24{
25#endif
26
27/**
28\brief Class representing the geometry of a box.
29
30The geometry of a box can be fully specified by its half extents. This is the half of its width, height, and depth.
31\note The scaling of the box is expected to be baked into these values, there is no additional scaling parameter.
32*/
33class PxBoxGeometry : public PxGeometry
34{
35public:
36 /**
37 \brief Default constructor, initializes to a box with zero dimensions.
38 */
39 PX_INLINE PxBoxGeometry() : PxGeometry(PxGeometryType::eBOX), halfExtents(0,0,0) {}
40
41 /**
42 \brief Constructor to initialize half extents from scalar parameters.
43 \param hx Initial half extents' x component.
44 \param hy Initial half extents' y component.
45 \param hz Initial half extents' z component.
46 */
47 PX_INLINE PxBoxGeometry(PxReal hx, PxReal hy, PxReal hz) : PxGeometry(PxGeometryType::eBOX), halfExtents(hx, hy, hz) {}
48
49 /**
50 \brief Constructor to initialize half extents from vector parameter.
51 \param halfExtents_ Initial half extents.
52 */
53 PX_INLINE PxBoxGeometry(PxVec3 halfExtents_) : PxGeometry(PxGeometryType::eBOX), halfExtents(halfExtents_) {}
54
55 /**
56 \brief Returns true if the geometry is valid.
57
58 \return True if the current settings are valid
59
60 \note A valid box has a positive extent in each direction (halfExtents.x > 0, halfExtents.y > 0, halfExtents.z > 0).
61 It is illegal to call PxRigidActor::createShape and PxPhysics::createShape with a box that has zero extent in any direction.
62
63 @see PxRigidActor::createShape, PxPhysics::createShape
64 */
65 PX_INLINE bool isValid() const;
66
67public:
68 /**
69 \brief Half of the width, height, and depth of the box.
70 */
71 PxVec3 halfExtents;
72};
73
74
75PX_INLINE bool PxBoxGeometry::isValid() const
76{
77 if (mType != PxGeometryType::eBOX)
78 return false;
79 if (!halfExtents.isFinite())
80 return false;
81 if (halfExtents.x <= 0.0f || halfExtents.y <= 0.0f || halfExtents.z <= 0.0f)
82 return false;
83
84 return true;
85}
86
87#ifndef PX_DOXYGEN
88} // namespace physx
89#endif
90
91/** @} */
92#endif
93