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_NX_SCENEQUERY |
32 | #define PX_PHYSICS_NX_SCENEQUERY |
33 | /** \addtogroup scenequery |
34 | @{ */ |
35 | |
36 | #include "PxPhysXConfig.h" |
37 | #include "PxShape.h" |
38 | #include "PxBatchQueryDesc.h" |
39 | #include "PxQueryFiltering.h" |
40 | |
41 | #if !PX_DOXYGEN |
42 | namespace physx |
43 | { |
44 | #endif |
45 | |
46 | class PxBoxGeometry; |
47 | class PxSphereGeometry; |
48 | struct PxQueryCache; |
49 | |
50 | /** |
51 | \brief Batched queries object. This is used to perform several queries at the same time. |
52 | |
53 | \deprecated The batched query feature has been deprecated in PhysX version 3.4 |
54 | |
55 | @see PxScene, PxScene.createBatchQuery |
56 | */ |
57 | class PX_DEPRECATED PxBatchQuery |
58 | { |
59 | public: |
60 | |
61 | /** |
62 | \brief Executes batched queries. |
63 | */ |
64 | virtual void execute() = 0; |
65 | |
66 | /** |
67 | \brief Gets the prefilter shader in use for this scene query. |
68 | |
69 | \return Prefilter shader. |
70 | |
71 | @see PxBatchQueryDesc.preFilterShade PxBatchQueryPreFilterShader |
72 | */ |
73 | virtual PxBatchQueryPreFilterShader getPreFilterShader() const = 0; |
74 | |
75 | /** |
76 | \brief Gets the postfilter shader in use for this scene query. |
77 | |
78 | \return Postfilter shader. |
79 | |
80 | @see PxBatchQueryDesc.preFilterShade PxBatchQueryPostFilterShader |
81 | */ |
82 | virtual PxBatchQueryPostFilterShader getPostFilterShader() const = 0; |
83 | |
84 | |
85 | /** |
86 | \brief Gets the shared global filter data in use for this scene query. |
87 | |
88 | \return Shared filter data for filter shader. |
89 | |
90 | @see getFilterShaderDataSize() PxBatchQueryDesc.filterShaderData PxBatchQueryPreFilterShader, PxBatchQueryPostFilterShader |
91 | */ |
92 | virtual const void* getFilterShaderData() const = 0; |
93 | |
94 | /** |
95 | \brief Gets the size of the shared global filter data (#PxSceneDesc.filterShaderData) |
96 | |
97 | \return Size of shared filter data [bytes]. |
98 | |
99 | @see getFilterShaderData() PxBatchQueryDesc.filterShaderDataSize PxBatchQueryPreFilterShader, PxBatchQueryPostFilterShader |
100 | */ |
101 | virtual PxU32 getFilterShaderDataSize() const = 0; |
102 | |
103 | /** |
104 | \brief Sets new user memory pointers. |
105 | |
106 | It is not possible to change the memory during query execute. |
107 | |
108 | @see PxBatchQueryDesc |
109 | */ |
110 | virtual void setUserMemory(const PxBatchQueryMemory&) = 0; |
111 | |
112 | /** |
113 | \brief Gets the user memory pointers. |
114 | |
115 | @see PxBatchQueryDesc |
116 | */ |
117 | virtual const PxBatchQueryMemory& getUserMemory() = 0; |
118 | |
119 | /** |
120 | \brief Releases PxBatchQuery from PxScene |
121 | |
122 | @see PxScene, PxScene.createBatchQuery |
123 | */ |
124 | virtual void release() = 0; |
125 | |
126 | /** |
127 | \brief Performs a raycast against objects in the scene, returns results in PxBatchQueryMemory::userRaycastResultBuffer |
128 | specified at PxBatchQuery creation time or via PxBatchQuery::setUserMemory call. |
129 | |
130 | \note Touching hits are not ordered. |
131 | \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms. |
132 | |
133 | \param[in] origin Origin of the ray. |
134 | \param[in] unitDir Normalized direction of the ray. |
135 | \param[in] distance Length of the ray. Needs to be larger than 0. |
136 | \param[in] maxTouchHits Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default. |
137 | \param[in] hitFlags Specifies which properties per hit should be computed and returned in hit array and blocking hit. |
138 | \param[in] filterData Filtering data passed to the filter shader. See #PxQueryFilterData #PxBatchQueryPreFilterShader, #PxBatchQueryPostFilterShader |
139 | \param[in] userData User can pass any value in this argument, usually to identify this particular query |
140 | \param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene. |
141 | Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. |
142 | Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. |
143 | |
144 | \note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock |
145 | and overlapping writes from different threads may result in undefined behavior). |
146 | |
147 | @see PxQueryFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader PxRaycastHit PxScene::raycast |
148 | */ |
149 | virtual void raycast( |
150 | const PxVec3& origin, const PxVec3& unitDir, PxReal distance = PX_MAX_F32, PxU16 maxTouchHits = 0, |
151 | PxHitFlags hitFlags = PxHitFlag::eDEFAULT, |
152 | const PxQueryFilterData& filterData = PxQueryFilterData(), |
153 | void* userData = NULL, const PxQueryCache* cache = NULL) = 0; |
154 | |
155 | |
156 | /** |
157 | \brief Performs an overlap test of a given geometry against objects in the scene, returns results in PxBatchQueryMemory::userOverlapResultBuffer |
158 | specified at PxBatchQuery creation time or via PxBatchQuery::setUserMemory call. |
159 | |
160 | \note Filtering: returning eBLOCK from user filter for overlap queries will cause a warning (see #PxQueryHitType). |
161 | |
162 | \param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex). |
163 | \param[in] pose Pose of the object. |
164 | \param[in] maxTouchHits Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default. |
165 | \param[in] filterData Filtering data and simple logic. See #PxQueryFilterData #PxBatchQueryPreFilterShader, #PxBatchQueryPostFilterShader |
166 | \param[in] userData User can pass any value in this argument, usually to identify this particular query |
167 | \param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene. |
168 | Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. |
169 | Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. |
170 | |
171 | \note eBLOCK should not be returned from user filters for overlap(). Doing so will result in undefined behavior, and a warning will be issued. |
172 | \note If the PxQueryFlag::eNO_BLOCK flag is set, the eBLOCK will instead be automatically converted to an eTOUCH and the warning suppressed. |
173 | \note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock |
174 | and overlapping writes from different threads may result in undefined behavior). |
175 | |
176 | @see PxQueryFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader |
177 | */ |
178 | virtual void overlap( |
179 | const PxGeometry& geometry, const PxTransform& pose, PxU16 maxTouchHits = 0, |
180 | const PxQueryFilterData& filterData = PxQueryFilterData(), void* userData=NULL, const PxQueryCache* cache = NULL) = 0; |
181 | |
182 | /** |
183 | \brief Performs a sweep test against objects in the scene, returns results in PxBatchQueryMemory::userSweepResultBuffer |
184 | specified at PxBatchQuery creation time or via PxBatchQuery::setUserMemory call. |
185 | |
186 | \note Touching hits are not ordered. |
187 | \note If a shape from the scene is already overlapping with the query shape in its starting position, |
188 | the hit is returned unless eASSUME_NO_INITIAL_OVERLAP was specified. |
189 | |
190 | \param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex). |
191 | \param[in] pose Pose of the sweep object. |
192 | \param[in] unitDir Normalized direction of the sweep. |
193 | \param[in] distance Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE. |
194 | \param[in] maxTouchHits Maximum number of hits to record in the touch buffer for this query. Default=0 reports a single blocking hit. If maxTouchHits is set to 0 all hits are treated as blocking by default. |
195 | \param[in] hitFlags Specifies which properties per hit should be computed and returned in hit array and blocking hit. |
196 | \param[in] filterData Filtering data and simple logic. See #PxQueryFilterData #PxBatchQueryPreFilterShader, #PxBatchQueryPostFilterShader |
197 | \param[in] userData User can pass any value in this argument, usually to identify this particular query |
198 | \param[in] cache Cached hit shape (optional). Query is tested against cached shape first. If no hit is found the ray gets queried against the scene. |
199 | Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit. |
200 | Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. |
201 | \param[in] inflation This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal. |
202 | Note: ePRECISE_SWEEP doesn't support inflation. Therefore the sweep will be performed with zero inflation. |
203 | |
204 | \note This query call writes to a list associated with the query object and is NOT thread safe (for performance reasons there is no lock |
205 | and overlapping writes from different threads may result in undefined behavior). |
206 | |
207 | @see PxHitFlags PxQueryFilterData PxBatchQueryPreFilterShader PxBatchQueryPostFilterShader PxSweepHit |
208 | */ |
209 | virtual void sweep( |
210 | const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, |
211 | PxU16 maxTouchHits = 0, PxHitFlags hitFlags = PxHitFlag::eDEFAULT, |
212 | const PxQueryFilterData& filterData = PxQueryFilterData(), void* userData=NULL, const PxQueryCache* cache = NULL, |
213 | const PxReal inflation = 0.f) = 0; |
214 | |
215 | protected: |
216 | virtual ~PxBatchQuery() {} |
217 | }; |
218 | |
219 | #if !PX_DOXYGEN |
220 | } // namespace physx |
221 | #endif |
222 | |
223 | /** @} */ |
224 | #endif |
225 | |