1//
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions
4// are met:
5// * Redistributions of source code must retain the above copyright
6// notice, this list of conditions and the following disclaimer.
7// * Redistributions in binary form must reproduce the above copyright
8// notice, this list of conditions and the following disclaimer in the
9// documentation and/or other materials provided with the distribution.
10// * Neither the name of NVIDIA CORPORATION nor the names of its
11// contributors may be used to endorse or promote products derived
12// from this software without specific prior written permission.
13//
14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29
30
31#ifndef PX_PHYSICS_BVH_STRUCTURE
32#define PX_PHYSICS_BVH_STRUCTURE
33/** \addtogroup geomutils
34@{
35*/
36
37#include "common/PxBase.h"
38#include "foundation/PxTransform.h"
39#include "foundation/PxBounds3.h"
40
41#if !PX_DOXYGEN
42namespace physx
43{
44#endif
45
46/**
47\brief Class representing the bounding volume hierarchy structure.
48
49PxBVHStructure can be provided to PxScene::addActor. In this case the scene query
50pruning structure inside PhysX SDK will store/update one bound per actor.
51The scene queries against such an actor will query actor bounds and then
52make a local space query against the provided BVH structure, which is in
53actor's local space.
54
55@see PxScene::addActor
56*/
57class PxBVHStructure: public PxBase
58{
59public:
60
61 /**
62 \brief Raycast test against a BVH structure.
63
64 \param[in] origin The origin of the ray.
65 \param[in] unitDir Normalized direction of the ray.
66 \param[in] maxDist Maximum ray length, has to be in the [0, inf) range
67 \param[in] maxHits Max number of returned hits = size of 'rayHits' buffer
68 \param[out] rayHits Raycast hits information, bounds indices
69 \return Number of hits
70 */
71 virtual PxU32 raycast(const PxVec3& origin,
72 const PxVec3& unitDir,
73 PxReal maxDist,
74 PxU32 maxHits,
75 PxU32* PX_RESTRICT rayHits) const = 0;
76
77 /**
78 \brief Sweep test against a BVH structure.
79
80 \param[in] aabb The axis aligned bounding box to sweep
81 \param[in] unitDir Normalized direction of the sweep.
82 \param[in] maxDist Maximum sweep length, has to be in the [0, inf) range
83 \param[in] maxHits Max number of returned hits = size of 'sweepHits' buffer
84 \param[out] sweepHits Sweep hits information, bounds indices
85 \return Number of hits
86 */
87 virtual PxU32 sweep(const PxBounds3& aabb,
88 const PxVec3& unitDir,
89 PxReal maxDist,
90 PxU32 maxHits,
91 PxU32* PX_RESTRICT sweepHits) const = 0;
92
93 /**
94 \brief AABB overlap test against a BVH structure.
95
96 \param[in] aabb The axis aligned bounding box
97 \param[in] maxHits Max number of returned hits = size of 'overlapHits' buffer
98 \param[out] overlapHits Overlap hits information, bounds indices
99 \return Number of hits
100 */
101 virtual PxU32 overlap(const PxBounds3& aabb,
102 PxU32 maxHits,
103 PxU32* PX_RESTRICT overlapHits) const = 0;
104
105 /**
106 \brief Retrieve the bounds in the BVH.
107
108 @see PxBounds3
109 */
110 virtual const PxBounds3* getBounds() const = 0;
111
112 /**
113 \brief Returns the number of bounds in the BVH.
114
115 You can use #getBounds() to retrieve the bounds.
116
117 \return Number of bounds in the BVH.
118
119 */
120 virtual PxU32 getNbBounds() const = 0;
121
122 virtual const char* getConcreteTypeName() const { return "PxBVHStructure"; }
123protected:
124 PX_INLINE PxBVHStructure(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
125 PX_INLINE PxBVHStructure(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
126 virtual ~PxBVHStructure() {}
127
128 virtual bool isKindOf(const char* name) const { return !::strcmp(s1: "PxBVHStructure", s2: name) || PxBase::isKindOf(superClass: name); }
129
130};
131
132
133#if !PX_DOXYGEN
134} // namespace physx
135#endif
136
137/** @} */
138#endif
139

source code of qtquick3dphysics/src/3rdparty/PhysX/include/geometry/PxBVHStructure.h