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_SCENE |
15 | #define PX_PHYSICS_NX_SCENE |
16 | /** \addtogroup physics |
17 | @{ |
18 | */ |
19 | |
20 | #include "PxVisualizationParameter.h" |
21 | #include "PxSceneDesc.h" |
22 | #include "PxSimulationStatistics.h" |
23 | #include "PxQueryReport.h" |
24 | #include "PxQueryFiltering.h" |
25 | #include "PxClient.h" |
26 | |
27 | #if PX_USE_PARTICLE_SYSTEM_API |
28 | #include "particles/PxParticleSystem.h" |
29 | #include "particles/PxParticleFluid.h" |
30 | #endif |
31 | |
32 | #ifndef PX_DOXYGEN |
33 | namespace physx |
34 | { |
35 | #endif |
36 | |
37 | class PxRigidStatic; |
38 | class PxRigidDynamic; |
39 | class PxConstraint; |
40 | class PxMaterial; |
41 | class PxSimulationEventCallback; |
42 | class PxPhysics; |
43 | class PxBatchQueryDesc; |
44 | class PxBatchQuery; |
45 | class PxAggregate; |
46 | class PxRenderBuffer; |
47 | class PxVolumeCache; |
48 | |
49 | class PxSphereGeometry; |
50 | class PxBoxGeometry; |
51 | class PxCapsuleGeometry; |
52 | |
53 | typedef PxU8 PxDominanceGroup; |
54 | |
55 | class PxBaseTask; |
56 | class PxTaskManager; |
57 | |
58 | /** |
59 | \brief Data struct for use with Active Transform Notification. |
60 | Used with PxScene::getActiveTransforms(). |
61 | |
62 | @see PxScene |
63 | */ |
64 | struct PxActiveTransform |
65 | { |
66 | PxActor* actor; //!< Affected actor |
67 | void* userData; //!< User data of the actor |
68 | PxTransform actor2World; //!< Actor-to-world transform of the actor |
69 | }; |
70 | |
71 | /** |
72 | \brief Expresses the dominance relationship of a contact. |
73 | For the time being only three settings are permitted: |
74 | |
75 | (1.0f, 1.0f), (0.0f, 1.0f), and (1.0f, 0.0f). |
76 | |
77 | @see getDominanceGroup() PxDominanceGroup PxScene::setDominanceGroupPair() |
78 | */ |
79 | struct PxDominanceGroupPair |
80 | { |
81 | PxDominanceGroupPair(PxReal a, PxReal b) |
82 | : dominance0(a), dominance1(b) {} |
83 | PxReal dominance0; |
84 | PxReal dominance1; |
85 | }; |
86 | |
87 | /** \deprecated Deprecated definition for backwards compatibility with PhysX 3.2 */ |
88 | typedef PX_DEPRECATED PxDominanceGroupPair PxConstraintDominance; |
89 | |
90 | |
91 | /** |
92 | \brief Identifies each type of actor for retrieving actors from a scene. |
93 | |
94 | \note #PxArticulationLink objects are not supported. Use the #PxArticulation object to retrieve all its links. |
95 | |
96 | @see PxScene::getActors(), PxScene::getNbActors() |
97 | */ |
98 | struct PxActorTypeFlag |
99 | { |
100 | enum Enum |
101 | { |
102 | /** |
103 | \brief A static rigid body |
104 | @see PxRigidStatic |
105 | */ |
106 | eRIGID_STATIC = (1 << 0), |
107 | |
108 | /** |
109 | \brief A dynamic rigid body |
110 | @see PxRigidDynamic |
111 | */ |
112 | eRIGID_DYNAMIC = (1 << 1), |
113 | |
114 | #if PX_USE_PARTICLE_SYSTEM_API |
115 | /** |
116 | \brief A particle system |
117 | @see PxParticleSystem |
118 | */ |
119 | ePARTICLE_SYSTEM = (1 << 2), |
120 | |
121 | /** |
122 | \brief A particle fluid |
123 | @see PxParticleFluid |
124 | */ |
125 | ePARTICLE_FLUID = (1 << 3), |
126 | #endif |
127 | |
128 | #if PX_USE_CLOTH_API |
129 | /** |
130 | \brief A cloth |
131 | @see PxCloth |
132 | */ |
133 | eCLOTH = (1 << 5) |
134 | #endif |
135 | }; |
136 | }; |
137 | |
138 | /** |
139 | \brief Collection of set bits defined in PxActorTypeFlag. |
140 | |
141 | @see PxActorTypeFlag |
142 | */ |
143 | typedef PxFlags<PxActorTypeFlag::Enum,PxU16> PxActorTypeFlags; |
144 | PX_FLAGS_OPERATORS(PxActorTypeFlag::Enum,PxU16) |
145 | |
146 | /** \deprecated Deprecated definition for backwards compatibility with PhysX 3.2 */ |
147 | typedef PxActorTypeFlag PxActorTypeSelectionFlag; |
148 | |
149 | /** \deprecated Deprecated definition for backwards compatibility with PhysX 3.2 */ |
150 | typedef PxActorTypeFlags PxActorTypeSelectionFlags; |
151 | |
152 | /** |
153 | \brief single hit cache for scene queries. |
154 | |
155 | If a cache object is supplied to a scene query, the cached actor/shape pair is checked for intersection first. |
156 | \note Filters are not executed for the cached shape. |
157 | \note If intersection is found, the hit is treated as blocking. |
158 | \note Typically actor and shape from the last PxHitCallback.block query result is used as a cached actor/shape pair. |
159 | \note Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. |
160 | \note Cache is only used if no touch buffer was provided, for single nearest blocking hit queries and queries using eANY_HIT flag. |
161 | \note if non-zero touch buffer was provided, cache will be ignored |
162 | |
163 | \note It is the user's responsibility to ensure that the shape and actor are valid, so care must be taken |
164 | when deleting shapes to invalidate cached references. |
165 | |
166 | The faceIndex field is an additional hint for a mesh or height field which is not currently used. |
167 | |
168 | @see PxScene.raycast |
169 | */ |
170 | struct PxQueryCache |
171 | { |
172 | /** |
173 | \brief constructor sets to default |
174 | */ |
175 | PX_INLINE PxQueryCache() : shape(NULL), actor(NULL), faceIndex(0xffffffff) {} |
176 | |
177 | /** |
178 | \brief constructor to set properties |
179 | */ |
180 | PX_INLINE PxQueryCache(PxShape* s, PxU32 findex) : shape(s), actor(NULL), faceIndex(findex) {} |
181 | |
182 | PxShape* shape; //!< Shape to test for intersection first |
183 | PxRigidActor* actor; //!< Actor to which the shape belongs |
184 | PxU32 faceIndex; //!< Triangle index to test first - NOT CURRENTLY SUPPORTED |
185 | }; |
186 | |
187 | /** \deprecated Deprecated definition for backwards compatibility with PhysX 3.2 */ |
188 | #define PxSceneQueryCache PxQueryCache // PX_DEPRECATED |
189 | |
190 | /** |
191 | \brief A scene is a collection of bodies, particle systems and constraints which can interact. |
192 | |
193 | The scene simulates the behavior of these objects over time. Several scenes may exist |
194 | at the same time, but each body, particle system or constraint is specific to a scene |
195 | -- they may not be shared. |
196 | |
197 | @see PxSceneDesc PxPhysics.createScene() release() |
198 | */ |
199 | class PxScene |
200 | { |
201 | protected: |
202 | |
203 | /************************************************************************************************/ |
204 | |
205 | /** @name Basics |
206 | */ |
207 | //@{ |
208 | |
209 | PxScene(): userData(0) {} |
210 | virtual ~PxScene() {} |
211 | |
212 | public: |
213 | |
214 | /** |
215 | \brief Deletes the scene. |
216 | |
217 | Removes any actors, particle systems, and constraint shaders from this scene |
218 | (if the user hasn't already done so). |
219 | |
220 | Be sure to not keep a reference to this object after calling release. |
221 | Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls). |
222 | |
223 | @see PxPhysics.createScene() |
224 | */ |
225 | virtual void release() = 0; |
226 | |
227 | /** |
228 | \brief Sets a scene flag. You can only set one flag at a time. |
229 | |
230 | \note Not all flags are mutable and changing some will result in an error. Please check #PxSceneFlag to see which flags can be changed. |
231 | |
232 | @see PxSceneFlag |
233 | */ |
234 | virtual void setFlag(PxSceneFlag::Enum flag, bool value) = 0; |
235 | |
236 | /** |
237 | \brief Get the scene flags. |
238 | |
239 | \return The scene flags. See #PxSceneFlag |
240 | |
241 | @see PxSceneFlag |
242 | */ |
243 | virtual PxSceneFlags getFlags() const = 0; |
244 | |
245 | |
246 | /** |
247 | \brief Set new scene limits. |
248 | |
249 | \note Increase the maximum capacity of various data structures in the scene. The new capacities will be |
250 | at least as large as required to deal with the objects currently in the scene. Further, these values |
251 | are for preallocation and do not represent hard limits. |
252 | |
253 | \param[in] limits Scene limits. |
254 | @see PxSceneLimits |
255 | */ |
256 | virtual void setLimits(const PxSceneLimits& limits) = 0; |
257 | |
258 | /** |
259 | \brief Get current scene limits. |
260 | \return Current scene limits. |
261 | @see PxSceneLimits |
262 | */ |
263 | virtual PxSceneLimits getLimits() const = 0; |
264 | |
265 | |
266 | /** |
267 | \brief Call this method to retrieve the Physics SDK. |
268 | |
269 | \return The physics SDK this scene is associated with. |
270 | |
271 | @see PxPhysics |
272 | */ |
273 | virtual PxPhysics& getPhysics() = 0; |
274 | |
275 | /** |
276 | \brief Retrieves the scene's internal timestamp, increased each time a simulation step is completed. |
277 | |
278 | \return scene timestamp |
279 | */ |
280 | virtual PxU32 getTimestamp() const = 0; |
281 | |
282 | |
283 | //@} |
284 | /************************************************************************************************/ |
285 | |
286 | /** @name Add/Remove Contained Objects |
287 | */ |
288 | //@{ |
289 | /** |
290 | \brief Adds an articulation to this scene. |
291 | |
292 | \note If the articulation is already assigned to a scene (see #PxArticulation::getScene), the call is ignored and an error is issued. |
293 | |
294 | \param[in] articulation Articulation to add to scene. See #PxArticulation |
295 | |
296 | @see PxArticulation |
297 | */ |
298 | virtual void addArticulation(PxArticulation& articulation) = 0; |
299 | |
300 | /** |
301 | \brief Removes an articulation from this scene. |
302 | |
303 | \note If the articulation is not part of this scene (see #PxArticulation::getScene), the call is ignored and an error is issued. |
304 | |
305 | \note If the articulation is in an aggregate it will be removed from the aggregate. |
306 | |
307 | \param[in] articulation Articulation to remove from scene. See #PxArticulation |
308 | \param[in] wakeOnLostTouch Specifies whether touching objects from the previous frame should get woken up in the next frame. Only applies to PxArticulation and PxRigidActor types. |
309 | |
310 | @see PxArticulation, PxAggregate |
311 | */ |
312 | virtual void removeArticulation(PxArticulation& articulation, bool wakeOnLostTouch = true) = 0; |
313 | |
314 | /** |
315 | \brief Adds an actor to this scene. |
316 | |
317 | \note If the actor is already assigned to a scene (see #PxActor::getScene), the call is ignored and an error is issued. |
318 | \note If the actor has an invalid constraint, in checked builds the call is ignored and an error is issued. |
319 | |
320 | \note You can not add individual articulation links (see #PxArticulationLink) to the scene. Use #addArticulation() instead. |
321 | |
322 | \note If the actor is a PxRigidActor then each assigned PxConstraint object will get added to the scene automatically if |
323 | it connects to another actor that is part of the scene already. |
324 | |
325 | \param[in] actor Actor to add to scene. |
326 | |
327 | @see PxActor, PxConstraint::isValid() |
328 | */ |
329 | virtual void addActor(PxActor& actor) = 0; |
330 | |
331 | /** |
332 | \brief Adds actors to this scene. |
333 | |
334 | \note If one of the actors is already assigned to a scene (see #PxActor::getScene), the call is ignored and an error is issued. |
335 | |
336 | \note You can not add individual articulation links (see #PxArticulationLink) to the scene. Use #addArticulation() instead. |
337 | |
338 | \note If an actor in the array contains an invalid constraint, in checked builds the call is ignored and an error is issued. |
339 | \note If an actor in the array is a PxRigidActor then each assigned PxConstraint object will get added to the scene automatically if |
340 | it connects to another actor that is part of the scene already. |
341 | |
342 | \note this method is optimized for high performance, and does not support buffering. It may not be called during simulation. |
343 | |
344 | \param[in] actors Array of actors to add to scene. |
345 | \param[in] nbActors Number of actors in the array. |
346 | |
347 | @see PxActor, PxConstraint::isValid() |
348 | */ |
349 | virtual void addActors(PxActor*const* actors, PxU32 nbActors) = 0; |
350 | |
351 | |
352 | /** |
353 | \brief Removes an actor from this scene. |
354 | |
355 | \note If the actor is not part of this scene (see #PxActor::getScene), the call is ignored and an error is issued. |
356 | |
357 | \note You can not remove individual articulation links (see #PxArticulationLink) from the scene. Use #removeArticulation() instead. |
358 | |
359 | \note If the actor is a PxRigidActor then all assigned PxConstraint objects will get removed from the scene automatically. |
360 | |
361 | \note If the actor is in an aggregate it will be removed from the aggregate. |
362 | |
363 | \param[in] actor Actor to remove from scene. |
364 | \param[in] wakeOnLostTouch Specifies whether touching objects from the previous frame should get woken up in the next frame. Only applies to PxArticulation and PxRigidActor types. |
365 | |
366 | @see PxActor, PxAggregate |
367 | */ |
368 | virtual void removeActor(PxActor& actor, bool wakeOnLostTouch = true) = 0; |
369 | |
370 | /** |
371 | \brief Removes actors from this scene. |
372 | |
373 | \note If some actor is not part of this scene (see #PxActor::getScene), the actor remove is ignored and an error is issued. |
374 | |
375 | \note You can not remove individual articulation links (see #PxArticulationLink) from the scene. Use #removeArticulation() instead. |
376 | |
377 | \note If the actor is a PxRigidActor then all assigned PxConstraint objects will get removed from the scene automatically. |
378 | |
379 | \param[in] actors Array of actors to add to scene. |
380 | \param[in] nbActors Number of actors in the array. |
381 | \param[in] wakeOnLostTouch Specifies whether touching objects from the previous frame should get woken up in the next frame. Only applies to PxArticulation and PxRigidActor types. |
382 | |
383 | @see PxActor |
384 | */ |
385 | virtual void removeActors(PxActor*const* actors, PxU32 nbActors, bool wakeOnLostTouch = true) = 0; |
386 | |
387 | /** |
388 | \brief Adds an aggregate to this scene. |
389 | |
390 | \note If the aggregate is already assigned to a scene (see #PxAggregate::getScene), the call is ignored and an error is issued. |
391 | \note If the aggregate contains an actor with an invalid constraint, in checked builds the call is ignored and an error is issued. |
392 | |
393 | \note If the aggregate already contains actors, those actors are added to the scene as well. |
394 | |
395 | \param[in] aggregate Aggregate to add to scene. |
396 | |
397 | @see PxAggregate, PxConstraint::isValid() |
398 | */ |
399 | virtual void addAggregate(PxAggregate& aggregate) = 0; |
400 | |
401 | /** |
402 | \brief Removes an aggregate from this scene. |
403 | |
404 | \note If the aggregate is not part of this scene (see #PxAggregate::getScene), the call is ignored and an error is issued. |
405 | |
406 | \note If the aggregate contains actors, those actors are removed from the scene as well. |
407 | |
408 | \param[in] aggregate Aggregate to remove from scene. |
409 | \param[in] wakeOnLostTouch Specifies whether touching objects from the previous frame should get woken up in the next frame. Only applies to PxArticulation and PxRigidActor types. |
410 | |
411 | @see PxAggregate |
412 | */ |
413 | virtual void removeAggregate(PxAggregate& aggregate, bool wakeOnLostTouch = true) = 0; |
414 | |
415 | /** |
416 | \brief Adds objects in the collection to this scene. |
417 | |
418 | This function adds the following types of objects to this scene: PxActor, PxAggregate, PxArticulation. |
419 | This method is typically used after deserializing the collection in order to populate the scene with deserialized objects. |
420 | |
421 | \note If the collection contains an actor with an invalid constraint, in checked builds the call is ignored and an error is issued. |
422 | |
423 | \param[in] collection Objects to add to this scene. See #PxCollection |
424 | |
425 | @see PxCollection, PxConstraint::isValid() |
426 | */ |
427 | virtual void addCollection(const PxCollection& collection) = 0; |
428 | //@} |
429 | /************************************************************************************************/ |
430 | |
431 | /** @name Contained Object Retrieval |
432 | */ |
433 | //@{ |
434 | |
435 | /** |
436 | \brief Retrieve the number of actors of certain types in the scene. |
437 | |
438 | \param[in] types Combination of actor types. |
439 | \return the number of actors. |
440 | |
441 | @see getActors() |
442 | */ |
443 | virtual PxU32 getNbActors(PxActorTypeFlags types) const = 0; |
444 | |
445 | /** |
446 | \brief Retrieve an array of all the actors of certain types in the scene. |
447 | |
448 | \param[in] types Combination of actor types to retrieve. |
449 | \param[out] userBuffer The buffer to receive actor pointers. |
450 | \param[in] bufferSize Size of provided user buffer. |
451 | \param[in] startIndex Index of first actor pointer to be retrieved |
452 | \return Number of actors written to the buffer. |
453 | |
454 | @see getNbActors() |
455 | */ |
456 | virtual PxU32 getActors(PxActorTypeFlags types, PxActor** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0; |
457 | |
458 | /** |
459 | \brief Queries the PxScene for a list of the PxActors whose transforms have been |
460 | updated during the previous simulation step |
461 | |
462 | Note: PxSceneFlag::eENABLE_ACTIVETRANSFORMS must be set. |
463 | Multiclient behavior: Active transforms now return only the list of active actors owned by the specified client. |
464 | |
465 | \note Do not use this method while the simulation is running. Calls to this method while the simulation is running will be ignored and NULL will be returned. |
466 | |
467 | \param[out] nbTransformsOut The number of transforms returned. |
468 | \param[in] client The client whose actors the caller is interested in. |
469 | |
470 | \return A pointer to the list of PxActiveTransforms generated during the last call to fetchResults(). |
471 | |
472 | @see PxActiveTransform |
473 | */ |
474 | |
475 | virtual const PxActiveTransform* |
476 | getActiveTransforms(PxU32& nbTransformsOut, PxClientID client = PX_DEFAULT_CLIENT) = 0; |
477 | |
478 | /** |
479 | \brief Returns the number of articulations in the scene. |
480 | |
481 | \return the number of articulations in this scene. |
482 | |
483 | @see getArticulations() |
484 | */ |
485 | virtual PxU32 getNbArticulations() const = 0; |
486 | |
487 | /** |
488 | \brief Retrieve all the articulations in the scene. |
489 | |
490 | \param[out] userBuffer The buffer to receive articulations pointers. |
491 | \param[in] bufferSize Size of provided user buffer. |
492 | \param[in] startIndex Index of first articulations pointer to be retrieved |
493 | \return Number of articulations written to the buffer. |
494 | |
495 | @see getNbArticulations() |
496 | */ |
497 | virtual PxU32 getArticulations(PxArticulation** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0; |
498 | |
499 | /** |
500 | \brief Returns the number of constraint shaders in the scene. |
501 | |
502 | \return the number of constraint shaders in this scene. |
503 | |
504 | @see getConstraints() |
505 | */ |
506 | virtual PxU32 getNbConstraints() const = 0; |
507 | |
508 | /** |
509 | \brief Retrieve all the constraint shaders in the scene. |
510 | |
511 | \param[out] userBuffer The buffer to receive constraint shader pointers. |
512 | \param[in] bufferSize Size of provided user buffer. |
513 | \param[in] startIndex Index of first constraint pointer to be retrieved |
514 | \return Number of constraint shaders written to the buffer. |
515 | |
516 | @see getNbConstraints() |
517 | */ |
518 | virtual PxU32 getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0; |
519 | |
520 | |
521 | /** |
522 | \brief Returns the number of aggregates in the scene. |
523 | |
524 | \return the number of aggregates in this scene. |
525 | |
526 | @see getAggregates() |
527 | */ |
528 | virtual PxU32 getNbAggregates() const = 0; |
529 | |
530 | /** |
531 | \brief Retrieve all the aggregates in the scene. |
532 | |
533 | \param[out] userBuffer The buffer to receive aggregates pointers. |
534 | \param[in] bufferSize Size of provided user buffer. |
535 | \param[in] startIndex Index of first aggregate pointer to be retrieved |
536 | \return Number of aggregates written to the buffer. |
537 | |
538 | @see getNbAggregates() |
539 | */ |
540 | virtual PxU32 getAggregates(PxAggregate** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0; |
541 | |
542 | //@} |
543 | /************************************************************************************************/ |
544 | |
545 | /** @name Dominance |
546 | */ |
547 | //@{ |
548 | |
549 | /** |
550 | \brief Specifies the dominance behavior of contacts between two actors with two certain dominance groups. |
551 | |
552 | It is possible to assign each actor to a dominance groups using #PxActor::setDominanceGroup(). |
553 | |
554 | With dominance groups one can have all contacts created between actors act in one direction only. This is useful, for example, if you |
555 | want an object to push debris out of its way and be unaffected,while still responding physically to forces and collisions |
556 | with non-debris objects. |
557 | |
558 | Whenever a contact between two actors (a0, a1) needs to be solved, the groups (g0, g1) of both |
559 | actors are retrieved. Then the PxDominanceGroupPair setting for this group pair is retrieved with getDominanceGroupPair(g0, g1). |
560 | |
561 | In the contact, PxDominanceGroupPair::dominance0 becomes the dominance setting for a0, and |
562 | PxDominanceGroupPair::dominance1 becomes the dominance setting for a1. A dominanceN setting of 1.0f, the default, |
563 | will permit aN to be pushed or pulled by a(1-N) through the contact. A dominanceN setting of 0.0f, will however |
564 | prevent aN to be pushed by a(1-N) via the contact. Thus, a PxDominanceGroupPair of (1.0f, 0.0f) makes |
565 | the interaction one-way. |
566 | |
567 | |
568 | The matrix sampled by getDominanceGroupPair(g1, g2) is initialised by default such that: |
569 | |
570 | if g1 == g2, then (1.0f, 1.0f) is returned |
571 | if g1 < g2, then (0.0f, 1.0f) is returned |
572 | if g1 > g2, then (1.0f, 0.0f) is returned |
573 | |
574 | In other words, we permit actors in higher groups to be pushed around by actors in lower groups by default. |
575 | |
576 | These settings should cover most applications, and in fact not overriding these settings may likely result in higher performance. |
577 | |
578 | It is not possible to make the matrix asymetric, or to change the diagonal. In other words: |
579 | |
580 | * it is not possible to change (g1, g2) if (g1==g2) |
581 | * if you set |
582 | |
583 | (g1, g2) to X, then (g2, g1) will implicitly and automatically be set to ~X, where: |
584 | |
585 | ~(1.0f, 1.0f) is (1.0f, 1.0f) |
586 | ~(0.0f, 1.0f) is (1.0f, 0.0f) |
587 | ~(1.0f, 0.0f) is (0.0f, 1.0f) |
588 | |
589 | These two restrictions are to make sure that contacts between two actors will always evaluate to the same dominance |
590 | setting, regardless of the order of the actors. |
591 | |
592 | Dominance settings are currently specified as floats 0.0f or 1.0f because in the future we may permit arbitrary |
593 | fractional settings to express 'partly-one-way' interactions. |
594 | |
595 | <b>Sleeping:</b> Does <b>NOT</b> wake actors up automatically. |
596 | |
597 | @see getDominanceGroupPair() PxDominanceGroup PxDominanceGroupPair PxActor::setDominanceGroup() PxActor::getDominanceGroup() |
598 | */ |
599 | virtual void setDominanceGroupPair( |
600 | PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair& dominance) = 0; |
601 | |
602 | /** |
603 | \brief Samples the dominance matrix. |
604 | |
605 | @see setDominanceGroupPair() PxDominanceGroup PxDominanceGroupPair PxActor::setDominanceGroup() PxActor::getDominanceGroup() |
606 | */ |
607 | virtual PxDominanceGroupPair getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const = 0; |
608 | |
609 | //@} |
610 | /************************************************************************************************/ |
611 | |
612 | /** @name Dispatcher |
613 | */ |
614 | //@{ |
615 | |
616 | /** |
617 | \brief Return the cpu dispatcher that was set in PxScene::PxCpuDispatcher when creating the scene with PxPhysics::createScene |
618 | |
619 | @see PxSceneDesc::PxCpuDispatcher, PxPhysics::createScene |
620 | */ |
621 | virtual PxCpuDispatcher* getCpuDispatcher() const = 0; |
622 | |
623 | /** |
624 | \brief Return the gpu dispatcher that was set in PxScene::PxGpuDispatcher when creating the scene with PxPhysics::createScene |
625 | |
626 | <b>Platform specific:</b> Applies to PC GPU only. |
627 | |
628 | @see PxSceneDesc::PxGpuDispatcher, PxPhysics::createScene |
629 | */ |
630 | virtual PxGpuDispatcher* getGpuDispatcher() const = 0; |
631 | |
632 | /** |
633 | \brief Return the spu dispatcher that was set in PxScene::PxSpuDispatcher when creating the scene with PxPhysics::createScene |
634 | |
635 | <b>Platform specific:</b> Applies to PS3 only. |
636 | |
637 | @see PxSceneDesc::PxSpuDispatcher, PxPhysics::createScene |
638 | */ |
639 | virtual PxSpuDispatcher* getSpuDispatcher() const = 0; |
640 | |
641 | //@} |
642 | /************************************************************************************************/ |
643 | /** @name Multiclient |
644 | */ |
645 | //@{ |
646 | /** |
647 | \brief Reserves a new client ID. |
648 | |
649 | PX_DEFAULT_CLIENT is always available as the default clientID. |
650 | Additional clients are returned by this function. Clients cannot be released once created. |
651 | An error is reported when more than a supported number of clients (currently 128) are created. |
652 | |
653 | @see PxClientBehaviorFlag PxClientID setClientBehaviorFlags() PxActor::setClientBehaviorFlags() |
654 | */ |
655 | virtual PxClientID createClient() = 0; |
656 | |
657 | /** |
658 | \brief Sets behavior bits for a client. |
659 | |
660 | The behavior bits are a property of a client that determine when it receives callbacks. |
661 | |
662 | It is permissible to change the behavior for PX_DEFAULT_CLIENT with this call. |
663 | Initially all created clients, as well as PX_DEFAULT_CLIENT have all bits set to 0. |
664 | |
665 | Note that in addition to setting a client to listen to a particular foreign actor event type, |
666 | the user must also configure actors to send that particular event type to foreign clients |
667 | using PxActor::setClientBehaviorFlags(). |
668 | |
669 | @see PxClientBehaviorFlag PxClientID createClient() getClientBehaviorFlags() PxActor::setClientBehaviorFlags() |
670 | */ |
671 | virtual void setClientBehaviorFlags(PxClientID client, PxClientBehaviorFlags clientBehaviorFlags) = 0; |
672 | |
673 | /** |
674 | \brief Retrieves behavior bits for a client. |
675 | |
676 | @see PxClientBehaviorFlag PxClientID setClientBehaviorFlags() createClient() |
677 | */ |
678 | virtual PxClientBehaviorFlags getClientBehaviorFlags(PxClientID client) const = 0; |
679 | //@} |
680 | |
681 | |
682 | #if PX_USE_CLOTH_API |
683 | |
684 | /************************************************************************************************/ |
685 | |
686 | /** @name Cloth |
687 | */ |
688 | //@{ |
689 | /** |
690 | \brief Sets the minimum separation distance for cloth inter-collision. |
691 | |
692 | Particles closer than this distance that belong to different PxCloth objects |
693 | will be separated. |
694 | |
695 | \param[in] distance The minimum particle separation distance (default: 0.0). |
696 | |
697 | \note The PxCloth objects that interact can be controlled through the filter |
698 | shader, @see PxSimulationFilterShader. Cloth objects with the PxClothFlag::eGPU |
699 | set can only interact with other GPU simulated cloth objects. |
700 | */ |
701 | virtual void setClothInterCollisionDistance(PxF32 distance) = 0; |
702 | |
703 | /** |
704 | \brief Retrieves distance used for cloth inter-collision. |
705 | \return The distance used for cloth inter-collision. |
706 | */ |
707 | virtual PxF32 getClothInterCollisionDistance() const = 0; |
708 | |
709 | /** |
710 | \brief Sets the cloth inter-collision stiffness. |
711 | |
712 | Inter-collision stiffness controls how much two particles repel each other |
713 | when they are closer than the inter-collision distance. |
714 | |
715 | \param [in] stiffness Fraction of distance residual to resolve per iteration (default: 1.0). |
716 | */ |
717 | virtual void setClothInterCollisionStiffness(PxF32 stiffness) = 0; |
718 | /** |
719 | \brief Retrieves the stiffness coefficient used for cloth inter-collision. |
720 | \return The the stiffness coefficient used for cloth inter-collision. |
721 | */ |
722 | virtual PxF32 getClothInterCollisionStiffness() const = 0; |
723 | |
724 | /** |
725 | \brief Sets the number of inter-collision separation iterations to perform. |
726 | |
727 | The accuracy of cloth inter-collision may be improved by increasing the number |
728 | of separation passes that are performed. |
729 | |
730 | \param[in] nbIterations The number of iterations to perform (default: 1). |
731 | */ |
732 | virtual void setClothInterCollisionNbIterations(PxU32 nbIterations) = 0; |
733 | /** |
734 | \brief Retrieves the number of iterations used for cloth inter-collision. |
735 | \return The number of iterations used for cloth inter-collision. |
736 | */ |
737 | virtual PxU32 getClothInterCollisionNbIterations() const = 0; |
738 | //@} |
739 | |
740 | #endif // PX_USE_CLOTH_API |
741 | |
742 | /************************************************************************************************/ |
743 | |
744 | /** @name Callbacks |
745 | */ |
746 | //@{ |
747 | |
748 | /** |
749 | \brief Sets a user notify object which receives special simulation events when they occur. |
750 | |
751 | Multiclient behavior: unlike the PxSimulationEventCallback that can be specified in the PxSceneDesc, this method |
752 | lets the user associate additional callbacks with clients other than PX_DEFAULT_CLIENT. This way |
753 | each client can register its own callback class. Each callback function has a somewhat different |
754 | way of determining which clients' callbacks will be called in a certain event. Refer to the documentation |
755 | of particular callback functions inside PxSimulationEventCallback for this information. |
756 | |
757 | \note Do not set the callback while the simulation is running. Calls to this method while the simulation is running will be ignored. |
758 | |
759 | \param[in] callback User notification callback. See #PxSimulationEventCallback. |
760 | \param[in] client The client to be associated with this callback. |
761 | |
762 | @see PxSimulationEventCallback getSimulationEventCallback |
763 | */ |
764 | virtual void setSimulationEventCallback(PxSimulationEventCallback* callback, PxClientID client = PX_DEFAULT_CLIENT) = 0; |
765 | |
766 | /** |
767 | \brief Retrieves the simulationEventCallback pointer set with setSimulationEventCallback(). |
768 | |
769 | \param[in] client The client whose callback object is to be returned. |
770 | \return The current user notify pointer. See #PxSimulationEventCallback. |
771 | |
772 | @see PxSimulationEventCallback setSimulationEventCallback() |
773 | */ |
774 | virtual PxSimulationEventCallback* |
775 | getSimulationEventCallback(PxClientID client = PX_DEFAULT_CLIENT) const = 0; |
776 | |
777 | /** |
778 | \brief Sets a user callback object, which receives callbacks on all contacts generated for specified actors. |
779 | |
780 | \note Do not set the callback while the simulation is running. Calls to this method while the simulation is running will be ignored. |
781 | |
782 | \param[in] callback Asynchronous user contact modification callback. See #PxContactModifyCallback. |
783 | */ |
784 | virtual void setContactModifyCallback(PxContactModifyCallback* callback) = 0; |
785 | |
786 | /** |
787 | \brief Sets a user callback object, which receives callbacks on all CCD contacts generated for specified actors. |
788 | |
789 | \note Do not set the callback while the simulation is running. Calls to this method while the simulation is running will be ignored. |
790 | |
791 | \param[in] callback Asynchronous user contact modification callback. See #PxCCDContactModifyCallback. |
792 | */ |
793 | virtual void setCCDContactModifyCallback(PxCCDContactModifyCallback* callback) = 0; |
794 | |
795 | /** |
796 | \brief Retrieves the PxContactModifyCallback pointer set with setContactModifyCallback(). |
797 | |
798 | \return The current user contact modify callback pointer. See #PxContactModifyCallback. |
799 | |
800 | @see PxContactModifyCallback setContactModifyCallback() |
801 | */ |
802 | virtual PxContactModifyCallback* |
803 | getContactModifyCallback() const = 0; |
804 | |
805 | /** |
806 | \brief Retrieves the PxCCDContactModifyCallback pointer set with setContactModifyCallback(). |
807 | |
808 | \return The current user contact modify callback pointer. See #PxContactModifyCallback. |
809 | |
810 | @see PxContactModifyCallback setContactModifyCallback() |
811 | */ |
812 | virtual PxCCDContactModifyCallback* |
813 | getCCDContactModifyCallback() const = 0; |
814 | |
815 | /** |
816 | \brief Sets a broad-phase user callback object. |
817 | |
818 | Multiclient behavior: unlike the PxBroadPhaseCallback that can be specified in the PxSceneDesc, this method |
819 | lets the user associate additional callbacks with clients other than PX_DEFAULT_CLIENT. This way |
820 | each client can register its own callback class. Each callback function has a somewhat different |
821 | way of determining which clients' callbacks will be called in a certain event. Refer to the documentation |
822 | of particular callback functions inside PxBroadPhaseCallback for this information. |
823 | |
824 | \note Do not set the callback while the simulation is running. Calls to this method while the simulation is running will be ignored. |
825 | |
826 | \param[in] callback Asynchronous broad-phase callback. See #PxBroadPhaseCallback. |
827 | \param[in] client The client to be associated with this callback. |
828 | */ |
829 | virtual void setBroadPhaseCallback(PxBroadPhaseCallback* callback, PxClientID client = PX_DEFAULT_CLIENT) = 0; |
830 | |
831 | /** |
832 | \brief Retrieves the PxBroadPhaseCallback pointer set with setBroadPhaseCallback(). |
833 | |
834 | \param[in] client The client whose callback object is to be returned. |
835 | |
836 | \return The current broad-phase callback pointer. See #PxBroadPhaseCallback. |
837 | |
838 | @see PxBroadPhaseCallback setBroadPhaseCallback() |
839 | */ |
840 | virtual PxBroadPhaseCallback* getBroadPhaseCallback(PxClientID client = PX_DEFAULT_CLIENT) const = 0; |
841 | |
842 | //@} |
843 | /************************************************************************************************/ |
844 | |
845 | /** @name Collision Filtering |
846 | */ |
847 | //@{ |
848 | |
849 | /** |
850 | \brief Gets the shared global filter data in use for this scene. |
851 | |
852 | \note The reference points to a copy of the original filter data specified in PxSceneDesc.filterShaderData. |
853 | |
854 | \return Shared filter data for filter shader. |
855 | |
856 | @see getFilterShaderDataSize() PxSceneDesc.filterShaderData PxSimulationFilterShader |
857 | */ |
858 | virtual const void* getFilterShaderData() const = 0; |
859 | |
860 | /** |
861 | \brief Gets the size of the shared global filter data (#PxSceneDesc.filterShaderData) |
862 | |
863 | \return Size of shared filter data [bytes]. |
864 | |
865 | @see getFilterShaderData() PxSceneDesc.filterShaderDataSize PxSimulationFilterShader |
866 | */ |
867 | virtual PxU32 getFilterShaderDataSize() const = 0; |
868 | |
869 | /** |
870 | \brief Gets the custom collision filter shader in use for this scene. |
871 | |
872 | \return Filter shader class that defines the collision pair filtering. |
873 | |
874 | @see PxSceneDesc.filterShader PxSimulationFilterShader |
875 | */ |
876 | virtual PxSimulationFilterShader |
877 | getFilterShader() const = 0; |
878 | |
879 | /** |
880 | \brief Gets the custom collision filter callback in use for this scene. |
881 | |
882 | \return Filter callback class that defines the collision pair filtering. |
883 | |
884 | @see PxSceneDesc.filterCallback PxSimulationFilterCallback |
885 | */ |
886 | virtual PxSimulationFilterCallback* |
887 | getFilterCallback() const = 0; |
888 | |
889 | /** |
890 | \brief Marks the object to reset interactions and re-run collision filters in the next simulation step. |
891 | |
892 | This call forces the object to remove all existing collision interactions, to search anew for existing contact |
893 | pairs and to run the collision filters again for found collision pairs. |
894 | |
895 | \note The operation is supported for PxParticleBase and PxRigidActor objects only. |
896 | |
897 | \note All persistent state of existing interactions will be lost and can not be retrieved even if the same collison pair |
898 | is found again in the next step. This will mean, for example, that you will not get notified about persistent contact |
899 | for such an interaction (see #PxPairFlag::eNOTIFY_TOUCH_PERSISTS), the contact pair will be interpreted as newly found instead. |
900 | |
901 | \note Lost touch contact reports will be sent for every collision pair which includes this shape, if they have |
902 | been requested through #PxPairFlag::eNOTIFY_TOUCH_LOST or #PxPairFlag::eNOTIFY_THRESHOLD_FORCE_LOST. |
903 | |
904 | \note This is an expensive operation, don't use it if you don't have to. |
905 | |
906 | \note Can be used to retrieve collision pairs that were killed by the collision filters (see #PxFilterFlag::eKILL) |
907 | |
908 | \note It is invalid to use this method if the actor has not been added to a scene already. |
909 | |
910 | \note It is invalid to use this method if PxActorFlag::eDISABLE_SIMULATION is set. |
911 | |
912 | <b>Sleeping:</b> Does wake up the actor. |
913 | |
914 | \param[in] actor The actor for which to re-evaluate interactions. |
915 | |
916 | @see PxSimulationFilterShader PxSimulationFilterCallback |
917 | */ |
918 | virtual void resetFiltering(PxActor& actor) = 0; |
919 | |
920 | /** |
921 | \brief Marks the object to reset interactions and re-run collision filters for specified shapes in the next simulation step. |
922 | |
923 | This is a specialization of the resetFiltering(PxActor& actor) method and allows to reset interactions for specific shapes of |
924 | a PxRigidActor. |
925 | |
926 | <b>Sleeping:</b> Does wake up the actor. |
927 | |
928 | \param[in] actor The actor for which to re-evaluate interactions. |
929 | \param[in] shapes The shapes for which to re-evaluate interactions. |
930 | \param[in] shapeCount Number of shapes in the list. |
931 | |
932 | @see PxSimulationFilterShader PxSimulationFilterCallback |
933 | */ |
934 | virtual void resetFiltering(PxRigidActor& actor, PxShape*const* shapes, PxU32 shapeCount) = 0; |
935 | |
936 | //@} |
937 | /************************************************************************************************/ |
938 | |
939 | /** @name Simulation |
940 | */ |
941 | //@{ |
942 | /** |
943 | \brief Advances the simulation by an elapsedTime time. |
944 | |
945 | \note Large elapsedTime values can lead to instabilities. In such cases elapsedTime |
946 | should be subdivided into smaller time intervals and simulate() should be called |
947 | multiple times for each interval. |
948 | |
949 | Calls to simulate() should pair with calls to fetchResults(): |
950 | Each fetchResults() invocation corresponds to exactly one simulate() |
951 | invocation; calling simulate() twice without an intervening fetchResults() |
952 | or fetchResults() twice without an intervening simulate() causes an error |
953 | condition. |
954 | |
955 | scene->simulate(); |
956 | ...do some processing until physics is computed... |
957 | scene->fetchResults(); |
958 | ...now results of run may be retrieved. |
959 | |
960 | |
961 | \param[in] elapsedTime Amount of time to advance simulation by. The parameter has to be larger than 0, else the resulting behavior will be undefined. <b>Range:</b> (0, PX_MAX_F32) |
962 | \param[in] completionTask if non-NULL, this task will have its refcount incremented in simulate(), then |
963 | decremented when the scene is ready to have fetchResults called. So the task will not run until the |
964 | application also calls removeReference(). |
965 | \param[in] scratchMemBlock a memory region for physx to use for temporary data during simulation. This block may be reused by the application |
966 | after fetchResults returns. Must be aligned on a 16-byte boundary |
967 | \param[in] scratchMemBlockSize the size of the scratch memory block. Must be a multiple of 16K. |
968 | \param[in] controlSimulation if true, the scene controls its PxTaskManager simulation state. Leave |
969 | true unless the application is calling the PxTaskManager start/stopSimulation() methods itself. |
970 | |
971 | @see fetchResults() checkResults() |
972 | */ |
973 | virtual void simulate(PxReal elapsedTime, physx::PxBaseTask* completionTask = NULL, |
974 | void* scratchMemBlock = 0, PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0; |
975 | |
976 | |
977 | /** |
978 | \brief Advances the simulation by an elapsedTime time. |
979 | |
980 | \note Not implemented in this release! |
981 | */ |
982 | virtual void solve(PxReal elapsedTime, physx::PxBaseTask* completionTask = 0, void* scratchMemBlock = 0, |
983 | PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0; |
984 | |
985 | /** |
986 | \brief Performs collision detection for the scene over elapsedTime |
987 | |
988 | \note Not implemented in this release! |
989 | */ |
990 | virtual void collide(PxReal elapsedTime, physx::PxBaseTask* completionTask = 0, void* scratchMemBlock = 0, |
991 | PxU32 scratchMemBlockSize = 0) = 0; |
992 | |
993 | /** |
994 | \brief This checks to see if the simulation run has completed. |
995 | |
996 | This does not cause the data available for reading to be updated with the results of the simulation, it is simply a status check. |
997 | The bool will allow it to either return immediately or block waiting for the condition to be met so that it can return true |
998 | |
999 | \param[in] block When set to true will block until the condition is met. |
1000 | \return True if the results are available. |
1001 | |
1002 | @see simulate() fetchResults() |
1003 | */ |
1004 | virtual bool checkResults(bool block = false) = 0; |
1005 | |
1006 | /** |
1007 | This is the big brother to checkResults() it basically does the following: |
1008 | |
1009 | \code |
1010 | if ( checkResults(block) ) |
1011 | { |
1012 | fire appropriate callbacks |
1013 | swap buffers |
1014 | return true |
1015 | } |
1016 | else |
1017 | return false |
1018 | |
1019 | \endcode |
1020 | |
1021 | \param[in] block When set to true will block until the condition is met. |
1022 | \param[out] errorState Used to retrieve hardware error codes. A non zero value indicates an error. |
1023 | \return True if the results have been fetched. |
1024 | |
1025 | @see simulate() checkResults() |
1026 | */ |
1027 | virtual bool fetchResults(bool block = false, PxU32* errorState = 0) = 0; |
1028 | |
1029 | /** |
1030 | \deprecated |
1031 | \brief This method has been deprecated and will be removed in a future update. @see flushSimulation() |
1032 | */ |
1033 | PX_DEPRECATED virtual void flush(bool sendPendingReports = false) = 0; |
1034 | |
1035 | /** |
1036 | \brief Clear internal buffers and free memory. |
1037 | |
1038 | This method can be used to clear buffers and free internal memory without having to destroy the scene. Can be useful if |
1039 | the physics data gets streamed in and a checkpoint with a clean state should be created. |
1040 | |
1041 | \note It is not allowed to call this method while the simulation is running. The call will fail. |
1042 | |
1043 | \param[in] sendPendingReports When set to true pending reports will be sent out before the buffers get cleaned up (for instance lost touch contact/trigger reports due to deleted objects). |
1044 | */ |
1045 | virtual void flushSimulation(bool sendPendingReports = false) = 0; |
1046 | |
1047 | /** |
1048 | \brief Sets a constant gravity for the entire scene. |
1049 | |
1050 | <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically. |
1051 | |
1052 | \param[in] vec A new gravity vector(e.g. PxVec3(0.0f,-9.8f,0.0f) ) <b>Range:</b> force vector |
1053 | |
1054 | @see PxSceneDesc.gravity getGravity() |
1055 | */ |
1056 | virtual void setGravity(const PxVec3& vec) = 0; |
1057 | |
1058 | /** |
1059 | \brief Retrieves the current gravity setting. |
1060 | |
1061 | \return The current gravity for the scene. |
1062 | |
1063 | @see setGravity() PxSceneDesc.gravity |
1064 | */ |
1065 | virtual PxVec3 getGravity() const = 0; |
1066 | |
1067 | /** |
1068 | \brief Set the bounce threshold velocity. Collision speeds below this threshold will not cause a bounce. |
1069 | |
1070 | @see PxSceneDesc::bounceThresholdVelocity, getBounceThresholdVelocity |
1071 | */ |
1072 | virtual void setBounceThresholdVelocity(const PxReal t) = 0; |
1073 | |
1074 | /** |
1075 | \brief Return the bounce threshold velocity. |
1076 | |
1077 | @see PxSceneDesc.bounceThresholdVelocity, setBounceThresholdVelocity |
1078 | */ |
1079 | virtual PxReal getBounceThresholdVelocity() const = 0; |
1080 | |
1081 | |
1082 | /** |
1083 | \brief Sets the maximum number of CCD passes |
1084 | |
1085 | \param[in] ccdMaxPasses Maximum number of CCD passes |
1086 | |
1087 | @see PxSceneDesc.ccdMaxPasses getCCDMaxPasses() |
1088 | |
1089 | */ |
1090 | virtual void setCCDMaxPasses(PxU32 ccdMaxPasses) = 0; |
1091 | |
1092 | /** |
1093 | \brief Gets the maximum number of CCD passes. |
1094 | |
1095 | \return The maximum number of CCD passes. |
1096 | |
1097 | @see PxSceneDesc::ccdMaxPasses setCCDMaxPasses() |
1098 | |
1099 | */ |
1100 | virtual PxU32 getCCDMaxPasses() const = 0; |
1101 | |
1102 | /** |
1103 | \brief Return the value of PxSceneDesc::contactCorrelationDistance that was set when creating the scene with PxPhysics::createScene |
1104 | |
1105 | @see PxSceneDesc::contactCorrelationDistance, PxPhysics::createScene |
1106 | */ |
1107 | virtual PxReal getContactCorrelationDistance() const = 0; |
1108 | |
1109 | /** |
1110 | \brief Return the value of frictionOffsetThreshold that was set in PxSceneDesc when creating the scene with PxPhysics::createScene |
1111 | |
1112 | @see PxSceneDesc::frictionOffsetThreshold, PxPhysics::createScene |
1113 | */ |
1114 | virtual PxReal getFrictionOffsetThreshold() const = 0; |
1115 | |
1116 | /** |
1117 | \deprecated |
1118 | \brief Return the value of PxSceneDesc::meshContactMargin that was set when creating the scene with PxPhysics::createScene |
1119 | |
1120 | @see PxSceneDesc::meshContactMargin, PxPhysics::createScene |
1121 | */ |
1122 | PX_DEPRECATED virtual PxReal getMeshContactMargin() const = 0; |
1123 | |
1124 | /** |
1125 | \brief Set the friction model. |
1126 | @see PxFrictionType, PxSceneDesc::frictionType |
1127 | */ |
1128 | virtual void setFrictionType(PxFrictionType::Enum frictionType) = 0; |
1129 | |
1130 | /** |
1131 | \brief Return the friction model. |
1132 | @see PxFrictionType, PxSceneDesc::frictionType |
1133 | */ |
1134 | virtual PxFrictionType::Enum getFrictionType() const = 0; |
1135 | |
1136 | //@} |
1137 | /************************************************************************************************/ |
1138 | |
1139 | /** @name Visualization and Statistics |
1140 | */ |
1141 | //@{ |
1142 | /** |
1143 | \brief Function that lets you set debug visualization parameters. |
1144 | |
1145 | Returns false if the value passed is out of range for usage specified by the enum. |
1146 | |
1147 | \param[in] param Parameter to set. See #PxVisualizationParameter |
1148 | \param[in] value The value to set, see #PxVisualizationParameter for allowable values. Setting to zero disables visualization for the specified property, setting to a positive value usually enables visualization and defines the scale factor. |
1149 | \return False if the parameter is out of range. |
1150 | |
1151 | @see getVisualizationParameter PxVisualizationParameter getRenderBuffer() |
1152 | */ |
1153 | virtual bool setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value) = 0; |
1154 | |
1155 | /** |
1156 | \brief Function that lets you query debug visualization parameters. |
1157 | |
1158 | \param[in] paramEnum The Parameter to retrieve. |
1159 | \return The value of the parameter. |
1160 | |
1161 | @see setVisualizationParameter PxVisualizationParameter |
1162 | */ |
1163 | virtual PxReal getVisualizationParameter(PxVisualizationParameter::Enum ) const = 0; |
1164 | |
1165 | |
1166 | /** |
1167 | \brief Defines a box in world space to which visualization geometry will be (conservatively) culled |
1168 | |
1169 | \param[in] box the box to which the geometry will be culled. |
1170 | @see setVisualizationParameter getVisualizationCullingBox getRenderBuffer() |
1171 | */ |
1172 | virtual void setVisualizationCullingBox(const PxBounds3& box) = 0; |
1173 | |
1174 | /** |
1175 | \brief Retrieves the visualization culling box. |
1176 | |
1177 | \return the box to which the geometry will be culled. |
1178 | @see setVisualizationParameter setVisualizationCullingBox |
1179 | */ |
1180 | virtual const PxBounds3& getVisualizationCullingBox() const = 0; |
1181 | |
1182 | /** |
1183 | \brief Retrieves the render buffer. |
1184 | |
1185 | This will contain the results of any active visualization for this scene. |
1186 | |
1187 | \note Do not use this method while the simulation is running. Calls to this method while result in undefined behaviour. |
1188 | |
1189 | \return The render buffer. |
1190 | |
1191 | @see PxRenderBuffer |
1192 | */ |
1193 | virtual const PxRenderBuffer& getRenderBuffer() = 0; |
1194 | |
1195 | /** |
1196 | \brief Call this method to retrieve statistics for the current simulation step. |
1197 | |
1198 | \note Do not use this method while the simulation is running. Calls to this method while the simulation is running will be ignored. |
1199 | |
1200 | \param[out] stats Used to retrieve statistics for the current simulation step. |
1201 | |
1202 | @see PxSimulationStatistics |
1203 | */ |
1204 | virtual void getSimulationStatistics(PxSimulationStatistics& stats) const = 0; |
1205 | |
1206 | |
1207 | //@} |
1208 | /************************************************************************************************/ |
1209 | |
1210 | /** @name Scene Query |
1211 | */ |
1212 | //@{ |
1213 | |
1214 | /** |
1215 | \brief Return the value of PxSceneDesc::staticStructure that was set when creating the scene with PxPhysics::createScene |
1216 | |
1217 | @see PxSceneDesc::staticStructure, PxPhysics::createScene |
1218 | */ |
1219 | virtual PxPruningStructure::Enum getStaticStructure() const = 0; |
1220 | |
1221 | /** |
1222 | \brief Return the value of PxSceneDesc::dynamicStructure that was set when creating the scene with PxPhysics::createScene |
1223 | |
1224 | @see PxSceneDesc::dynamicStructure, PxPhysics::createScene |
1225 | */ |
1226 | virtual PxPruningStructure::Enum getDynamicStructure() const = 0; |
1227 | |
1228 | /** |
1229 | \brief Flushes any changes in the simulation to the scene query representation. |
1230 | |
1231 | This method updates the state of the scene query representation to match changes in the scene state. |
1232 | |
1233 | By default, these changes are buffered until the next query is submitted. Calling this function will not change |
1234 | the results from scene queries, but can be used to ensure that a query will not perform update work in the course of |
1235 | its execution. |
1236 | |
1237 | A thread performing updates will hold a write lock on the query structure, and thus stall other querying threads. In multithread |
1238 | scenarios it can be useful to explicitly schedule the period where this lock may be held for a significant period, so that |
1239 | subsequent queries issued from multiple threads will not block. |
1240 | */ |
1241 | virtual void flushQueryUpdates() = 0; |
1242 | |
1243 | /** |
1244 | \brief Creates a BatchQuery object. |
1245 | |
1246 | Scene queries like raycasts, overlap tests and sweeps are batched in this object and are then executed at once. See #PxBatchQuery. |
1247 | |
1248 | \param[in] desc The descriptor of scene query. Scene Queries need to register a callback. See #PxBatchQueryDesc. |
1249 | |
1250 | @see PxBatchQuery PxBatchQueryDesc |
1251 | */ |
1252 | virtual PxBatchQuery* createBatchQuery(const PxBatchQueryDesc& desc) = 0; |
1253 | |
1254 | /** |
1255 | \brief Creates a volume cache. See the Guide, "Scene Queries" section, "Volume Caching" subsection for more information. |
1256 | |
1257 | @see PxVolumeCache PxVolumeCache.release() |
1258 | */ |
1259 | virtual PxVolumeCache* createVolumeCache(PxU32 maxStaticShapes = 32, PxU32 maxDynamicShapes = 8) = 0; |
1260 | |
1261 | /** |
1262 | \brief Sets the rebuild rate of the dynamic tree pruning structures. |
1263 | |
1264 | \param[in] dynamicTreeRebuildRateHint Rebuild rate of the dynamic tree pruning structures. |
1265 | |
1266 | @see PxSceneDesc.dynamicTreeRebuildRateHint getDynamicTreeRebuildRateHint() forceDynamicTreeRebuild() |
1267 | */ |
1268 | virtual void setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint) = 0; |
1269 | |
1270 | /** |
1271 | \brief Retrieves the rebuild rate of the dynamic tree pruning structures. |
1272 | |
1273 | \return The rebuild rate of the dynamic tree pruning structures. |
1274 | |
1275 | @see PxSceneDesc.dynamicTreeRebuildRateHint setDynamicTreeRebuildRateHint() forceDynamicTreeRebuild() |
1276 | */ |
1277 | virtual PxU32 getDynamicTreeRebuildRateHint() const = 0; |
1278 | |
1279 | /** |
1280 | \brief Forces dynamic trees to be immediately rebuilt. |
1281 | |
1282 | \param[in] rebuildStaticStructure True to rebuild the dynamic tree containing static objects |
1283 | \param[in] rebuildDynamicStructure True to rebuild the dynamic tree containing dynamic objects |
1284 | |
1285 | @see PxSceneDesc.dynamicTreeRebuildRateHint setDynamicTreeRebuildRateHint() getDynamicTreeRebuildRateHint() |
1286 | */ |
1287 | virtual void forceDynamicTreeRebuild(bool rebuildStaticStructure, bool rebuildDynamicStructure) = 0; |
1288 | |
1289 | /** |
1290 | \brief Performs a raycast against objects in the scene, returns results in a PxRaycastBuffer object |
1291 | or via a custom user callback implementation inheriting from PxRaycastCallback. |
1292 | |
1293 | \note Touching hits are not ordered. |
1294 | \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in user guide article SceneQuery. User can ignore such objects by employing one of the provided filter mechanisms. |
1295 | |
1296 | \param[in] origin Origin of the ray. |
1297 | \param[in] unitDir Normalized direction of the ray. |
1298 | \param[in] distance Length of the ray. Has to be in the [0, inf) range. |
1299 | \param[out] hitCall Raycast hit buffer or callback object used to report raycast hits. |
1300 | \param[in] hitFlags Specifies which properties per hit should be computed and returned via the hit callback. |
1301 | \param[in] filterData Filtering data passed to the filer shader. See #PxQueryFilterData #PxBatchQueryPreFilterShader, #PxBatchQueryPostFilterShader |
1302 | \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking. |
1303 | \param[in] cache Cached hit shape (optional). Ray is tested against cached shape first. If no hit is found the ray gets queried against the scene. |
1304 | 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. |
1305 | Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. |
1306 | |
1307 | \return True if any touching or blocking hits were found or any hit was found in case PxQueryFlag::eANY_HIT was specified. |
1308 | |
1309 | @see PxRaycastCallback PxRaycastBuffer PxQueryFilterData PxQueryFilterCallback PxQueryCache PxRaycastHit PxQueryFlag PxQueryFlag::eANY_HIT |
1310 | */ |
1311 | virtual bool raycast( |
1312 | const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, |
1313 | PxRaycastCallback& hitCall, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT), |
1314 | const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL, |
1315 | const PxQueryCache* cache = NULL) const = 0; |
1316 | |
1317 | /** |
1318 | \brief Performs a sweep test against objects in the scene, returns results in a PxSweepBuffer object |
1319 | or via a custom user callback implementation inheriting from PxSweepCallback. |
1320 | |
1321 | \note Touching hits are not ordered. |
1322 | \note If a shape from the scene is already overlapping with the query shape in its starting position, |
1323 | the hit is returned unless eASSUME_NO_INITIAL_OVERLAP was specified. |
1324 | |
1325 | \param[in] geometry Geometry of object to sweep (supported types are: box, sphere, capsule, convex). |
1326 | \param[in] pose Pose of the sweep object. |
1327 | \param[in] unitDir Normalized direction of the sweep. |
1328 | \param[in] distance Sweep distance. Needs to be in [0, inf) range and >0 if eASSUME_NO_INITIAL_OVERLAP was specified. Will be clamped to PX_MAX_SWEEP_DISTANCE. |
1329 | \param[out] hitCall Sweep hit buffer or callback object used to report sweep hits. |
1330 | \param[in] hitFlags Specifies which properties per hit should be computed and returned via the hit callback. |
1331 | \param[in] filterData Filtering data and simple logic. |
1332 | \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to be blocking. |
1333 | \param[in] cache Cached hit shape (optional). Sweep is performed against cached shape first. If no hit is found the sweep gets queried against the scene. |
1334 | 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. |
1335 | Note: Using past touching hits as cache will produce incorrect behavior since the cached hit will always be treated as blocking. |
1336 | \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. |
1337 | Note: ePRECISE_SWEEP doesn't support inflation. Therefore the sweep will be performed with zero inflation. |
1338 | |
1339 | \return True if any touching or blocking hits were found or any hit was found in case PxQueryFlag::eANY_HIT was specified. |
1340 | |
1341 | |
1342 | @see PxSweepCallback PxSweepBuffer PxQueryFilterData PxQueryFilterCallback PxSweepHit PxQueryCache |
1343 | */ |
1344 | virtual bool sweep(const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, |
1345 | PxSweepCallback& hitCall, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT), |
1346 | const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL, |
1347 | const PxQueryCache* cache = NULL, const PxReal inflation = 0.f) const = 0; |
1348 | |
1349 | |
1350 | /** |
1351 | \brief Performs an overlap test of a given geometry against objects in the scene, returns results in a PxOverlapBuffer object |
1352 | or via a custom user callback implementation inheriting from PxOverlapCallback. |
1353 | |
1354 | \note Filtering: returning eBLOCK from user filter for overlap queries will cause a warning (see #PxQueryHitType). |
1355 | |
1356 | \param[in] geometry Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex). |
1357 | \param[in] pose Pose of the object. |
1358 | \param[out] hitCall Overlap hit buffer or callback object used to report overlap hits. |
1359 | \param[in] filterData Filtering data and simple logic. See #PxQueryFilterData #PxQueryFilterCallback |
1360 | \param[in] filterCall Custom filtering logic (optional). Only used if the corresponding #PxQueryFlag flags are set. If NULL, all hits are assumed to overlap. |
1361 | |
1362 | \return True if any touching or blocking hits were found or any hit was found in case PxQueryFlag::eANY_HIT was specified. |
1363 | |
1364 | \note eBLOCK should not be returned from user filters for overlap(). Doing so will result in undefined behavior, and a warning will be issued. |
1365 | \note If the PxQueryFlag::eNO_BLOCK flag is set, the eBLOCK will instead be automatically converted to an eTOUCH and the warning suppressed. |
1366 | |
1367 | @see PxOverlapCallback PxOverlapBuffer PxHitFlags PxQueryFilterData PxQueryFilterCallback |
1368 | */ |
1369 | virtual bool overlap(const PxGeometry& geometry, const PxTransform& pose, PxOverlapCallback& hitCall, |
1370 | const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL |
1371 | ) const = 0; |
1372 | |
1373 | // |
1374 | // DEPRECATED LEGACY FUNCTIONS, please use the new raycast(), overlap() and sweep() APIs instead |
1375 | // |
1376 | /** \deprecated */ |
1377 | PX_DEPRECATED PX_INLINE bool raycastAny( |
1378 | const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, |
1379 | PxSceneQueryHit& hit, const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), |
1380 | PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL, |
1381 | PxClientID queryClient = PX_DEFAULT_CLIENT) const |
1382 | { |
1383 | PxSceneQueryFilterData fdAny = filterData; |
1384 | fdAny.flags |= PxQueryFlag::eANY_HIT; |
1385 | fdAny.clientId = queryClient; |
1386 | PxRaycastBuffer buf; |
1387 | raycast(origin, unitDir, distance, buf, PxHitFlags(), fdAny, filterCall, cache); |
1388 | hit = buf.block; |
1389 | return buf.hasBlock; |
1390 | } |
1391 | |
1392 | /** \deprecated */ |
1393 | PX_DEPRECATED PX_INLINE bool raycastSingle( |
1394 | const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, |
1395 | PxSceneQueryFlags outputFlags, PxRaycastHit& hit, |
1396 | const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), |
1397 | PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL, |
1398 | PxClientID queryClient = PX_DEFAULT_CLIENT) |
1399 | { |
1400 | PxRaycastBuffer buf; |
1401 | PxQueryFilterData fd1 = filterData; fd1.clientId = queryClient; |
1402 | raycast(origin, unitDir, distance, buf, outputFlags, fd1, filterCall, cache); |
1403 | hit = buf.block; |
1404 | return buf.hasBlock; |
1405 | } |
1406 | |
1407 | /** \deprecated */ |
1408 | PX_DEPRECATED PX_INLINE PxI32 raycastMultiple( |
1409 | const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, |
1410 | PxSceneQueryFlags outputFlags, |
1411 | PxRaycastHit* hitBuffer, PxU32 hitBufferSize, bool& blockingHit, |
1412 | const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), |
1413 | PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL, |
1414 | PxClientID queryClient = PX_DEFAULT_CLIENT) |
1415 | { |
1416 | PxRaycastBuffer buf(hitBuffer, hitBufferSize); |
1417 | PxQueryFilterData fd1 = filterData; fd1.clientId = queryClient; |
1418 | raycast(origin, unitDir, distance, buf, outputFlags, fd1, filterCall, cache); |
1419 | blockingHit = buf.hasBlock; |
1420 | if (blockingHit) |
1421 | { |
1422 | if (buf.nbTouches < hitBufferSize) |
1423 | { |
1424 | hitBuffer[buf.nbTouches] = buf.block; |
1425 | return PxI32(buf.nbTouches+1); |
1426 | } |
1427 | else // overflow, drop the last touch |
1428 | { |
1429 | hitBuffer[hitBufferSize-1] = buf.block; |
1430 | return -1; |
1431 | } |
1432 | } else |
1433 | // no block |
1434 | return (PxI32)buf.nbTouches; |
1435 | } |
1436 | |
1437 | /** \deprecated */ |
1438 | PX_DEPRECATED PX_INLINE bool sweepAny( |
1439 | const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, |
1440 | PxSceneQueryFlags queryFlags, |
1441 | PxSceneQueryHit& hit, |
1442 | const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), |
1443 | PxSceneQueryFilterCallback* filterCall = NULL, |
1444 | const PxSceneQueryCache* cache = NULL, |
1445 | PxClientID queryClient = PX_DEFAULT_CLIENT, |
1446 | const PxReal inflation = 0.f) |
1447 | { |
1448 | PxSceneQueryFilterData fdAny = filterData; |
1449 | fdAny.flags |= PxQueryFlag::eANY_HIT; |
1450 | fdAny.clientId = queryClient; |
1451 | PxSweepBuffer buf; |
1452 | sweep(geometry, pose, unitDir, distance, |
1453 | buf, queryFlags, fdAny, filterCall, cache, inflation); |
1454 | hit = buf.block; |
1455 | return buf.hasBlock; |
1456 | } |
1457 | |
1458 | /** \deprecated */ |
1459 | PX_DEPRECATED PX_INLINE bool sweepSingle( |
1460 | const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, |
1461 | PxSceneQueryFlags outputFlags, |
1462 | PxSweepHit& hit, |
1463 | const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), |
1464 | PxSceneQueryFilterCallback* filterCall = NULL, |
1465 | const PxSceneQueryCache* cache = NULL, |
1466 | PxClientID queryClient = PX_DEFAULT_CLIENT, const PxReal inflation=0.f) |
1467 | { |
1468 | PxSweepBuffer buf; |
1469 | PxQueryFilterData fd1 = filterData; fd1.clientId = queryClient; |
1470 | sweep(geometry, pose, unitDir, distance, buf, |
1471 | outputFlags, fd1, filterCall, cache, inflation); |
1472 | hit = buf.block; |
1473 | return buf.hasBlock; |
1474 | } |
1475 | |
1476 | /** \deprecated */ |
1477 | PX_DEPRECATED PX_INLINE PxI32 sweepMultiple( |
1478 | const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, |
1479 | PxSceneQueryFlags outputFlags, PxSweepHit* hitBuffer, PxU32 hitBufferSize, bool& blockingHit, |
1480 | const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), |
1481 | PxSceneQueryFilterCallback* filterCall = NULL, const PxSceneQueryCache* cache = NULL, |
1482 | PxClientID queryClient = PX_DEFAULT_CLIENT, const PxReal inflation = 0.f) |
1483 | { |
1484 | PxQueryFilterData fd1 = filterData; fd1.clientId = queryClient; |
1485 | PxSweepBuffer buf(hitBuffer, hitBufferSize); |
1486 | sweep( |
1487 | geometry, pose, unitDir, distance, buf, outputFlags, fd1, filterCall, |
1488 | cache, inflation); |
1489 | blockingHit = buf.hasBlock; |
1490 | if (blockingHit) |
1491 | { |
1492 | if (buf.nbTouches < hitBufferSize) |
1493 | { |
1494 | hitBuffer[buf.nbTouches] = buf.block; |
1495 | return PxI32(buf.nbTouches+1); |
1496 | } |
1497 | else // overflow, drop the last touch |
1498 | { |
1499 | hitBuffer[hitBufferSize-1] = buf.block; |
1500 | return -1; |
1501 | } |
1502 | } else |
1503 | // no block |
1504 | return (PxI32)buf.nbTouches; |
1505 | } |
1506 | |
1507 | /** \deprecated */ |
1508 | PX_DEPRECATED PX_INLINE PxI32 overlapMultiple( |
1509 | const PxGeometry& geometry, const PxTransform& pose, |
1510 | PxOverlapHit* hitBuffer, PxU32 hitBufferSize, |
1511 | const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), |
1512 | PxSceneQueryFilterCallback* filterCall = NULL, |
1513 | PxClientID queryClient = PX_DEFAULT_CLIENT) |
1514 | { |
1515 | PxQueryFilterData fd1 = filterData; fd1.clientId = queryClient; |
1516 | fd1.flags |= PxQueryFlag::eNO_BLOCK; |
1517 | PxOverlapBuffer buf(hitBuffer, hitBufferSize); |
1518 | overlap(geometry, pose, buf, fd1, filterCall); |
1519 | if (buf.hasBlock) |
1520 | { |
1521 | if (buf.nbTouches < hitBufferSize) |
1522 | { |
1523 | hitBuffer[buf.nbTouches] = buf.block; |
1524 | return PxI32(buf.nbTouches+1); |
1525 | } |
1526 | else // overflow, drop the last touch |
1527 | { |
1528 | hitBuffer[hitBufferSize-1] = buf.block; |
1529 | return -1; |
1530 | } |
1531 | } else |
1532 | // no block |
1533 | return (PxI32)buf.nbTouches; |
1534 | } |
1535 | |
1536 | /** \deprecated */ |
1537 | PX_DEPRECATED PX_INLINE bool overlapAny( |
1538 | const PxGeometry& geometry, const PxTransform& pose, |
1539 | PxOverlapHit& hit, |
1540 | const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(), |
1541 | PxSceneQueryFilterCallback* filterCall = NULL, |
1542 | PxClientID queryClient = PX_DEFAULT_CLIENT) |
1543 | { |
1544 | PxSceneQueryFilterData fdAny = filterData; |
1545 | fdAny.flags |= (PxQueryFlag::eANY_HIT | PxQueryFlag::eNO_BLOCK); |
1546 | fdAny.clientId = queryClient; |
1547 | PxOverlapBuffer buf; |
1548 | overlap(geometry, pose, buf, fdAny, filterCall); |
1549 | hit = buf.block; |
1550 | return buf.hasBlock; |
1551 | } |
1552 | |
1553 | /** |
1554 | \brief Retrieves the scene's internal scene query timestamp, increased each time a change to the |
1555 | static scene query structure is performed. |
1556 | |
1557 | \return scene query static timestamp |
1558 | */ |
1559 | virtual PxU32 getSceneQueryStaticTimestamp() const = 0; |
1560 | //@} |
1561 | |
1562 | /************************************************************************************************/ |
1563 | /** @name Broad-phase |
1564 | */ |
1565 | //@{ |
1566 | |
1567 | /** |
1568 | \brief Returns broad-phase type. |
1569 | |
1570 | \return Broad-phase type |
1571 | */ |
1572 | virtual PxBroadPhaseType::Enum getBroadPhaseType() const = 0; |
1573 | |
1574 | /** |
1575 | \brief Gets broad-phase caps. |
1576 | |
1577 | \param[out] caps Broad-phase caps |
1578 | \return True if success |
1579 | */ |
1580 | virtual bool getBroadPhaseCaps(PxBroadPhaseCaps& caps) const = 0; |
1581 | |
1582 | /** |
1583 | \brief Returns number of regions currently registered in the broad-phase. |
1584 | |
1585 | \return Number of regions |
1586 | */ |
1587 | virtual PxU32 getNbBroadPhaseRegions() const = 0; |
1588 | |
1589 | /** |
1590 | \brief Gets broad-phase regions. |
1591 | |
1592 | \param[out] userBuffer Returned broad-phase regions |
1593 | \param[in] bufferSize Size of userBuffer |
1594 | \param[in] startIndex Index of first desired region, in [0 ; getNbRegions()[ |
1595 | \return Number of written out regions |
1596 | */ |
1597 | virtual PxU32 getBroadPhaseRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0; |
1598 | |
1599 | /** |
1600 | \brief Adds a new broad-phase region. |
1601 | |
1602 | Note that by default, objects already existing in the SDK that might touch this region will not be automatically |
1603 | added to the region. In other words the newly created region will be empty, and will only be populated with new |
1604 | objects when they are added to the simulation, or with already existing objects when they are updated. |
1605 | |
1606 | It is nonetheless possible to override this default behavior and let the SDK populate the new region automatically |
1607 | with already existing objects overlapping the incoming region. This has a cost though, and it should only be used |
1608 | when the game can not guarantee that all objects within the new region will be added to the simulation after the |
1609 | region itself. |
1610 | |
1611 | \param[in] region User-provided region data |
1612 | \param[in] populateRegion Automatically populate new region with already existing objects overlapping it |
1613 | \return Handle for newly created region, or 0xffffffff in case of failure. |
1614 | */ |
1615 | virtual PxU32 addBroadPhaseRegion(const PxBroadPhaseRegion& region, bool populateRegion=false) = 0; |
1616 | |
1617 | /** |
1618 | \brief Removes a new broad-phase region. |
1619 | |
1620 | If the region still contains objects, and if those objects do not overlap any region any more, they are not |
1621 | automatically removed from the simulation. Instead, the PxBroadPhaseCallback::onObjectOutOfBounds notification |
1622 | is used for each object. Users are responsible for removing the objects from the simulation if this is the |
1623 | desired behavior. |
1624 | |
1625 | If the handle is invalid, or if a valid handle is removed twice, an error message is sent to the error stream. |
1626 | |
1627 | \param[in] handle Region's handle, as returned by PxScene::addBroadPhaseRegion. |
1628 | \return True if success |
1629 | */ |
1630 | virtual bool removeBroadPhaseRegion(PxU32 handle) = 0; |
1631 | |
1632 | //@} |
1633 | |
1634 | /************************************************************************************************/ |
1635 | |
1636 | /** @name Threads and Memory |
1637 | */ |
1638 | //@{ |
1639 | |
1640 | /** |
1641 | \brief Get the task manager associated with this scene |
1642 | |
1643 | \return the task manager associated with the scene |
1644 | */ |
1645 | virtual physx::PxTaskManager* getTaskManager() const = 0; |
1646 | |
1647 | |
1648 | /** |
1649 | \brief Lock the scene for reading from the calling thread. |
1650 | |
1651 | When the PxSceneFlag::eREQUIRE_RW_LOCK flag is enabled lockRead() must be |
1652 | called before any read calls are made on the scene. |
1653 | |
1654 | Multiple threads may read at the same time, no threads may read while a thread is writing. |
1655 | If a call to lockRead() is made while another thread is holding a write lock |
1656 | then the calling thread will be blocked until the writing thread calls unlockWrite(). |
1657 | |
1658 | \note Lock upgrading is *not* supported, that means it is an error to |
1659 | call lockRead() followed by lockWrite(). |
1660 | |
1661 | \note Recursive locking is supported but each lockRead() call must be paired with an unlockRead(). |
1662 | |
1663 | \param file String representing the calling file, for debug purposes |
1664 | \param line The source file line number, for debug purposes |
1665 | */ |
1666 | virtual void lockRead(const char* file=NULL, PxU32 line=0) = 0; |
1667 | |
1668 | /** |
1669 | \brief Unlock the scene from reading. |
1670 | |
1671 | \note Each unlockRead() must be paired with a lockRead() from the same thread. |
1672 | */ |
1673 | virtual void unlockRead() = 0; |
1674 | |
1675 | /** |
1676 | \brief Lock the scene for writing from this thread. |
1677 | |
1678 | When the PxSceneFlag::eREQUIRE_RW_LOCK flag is enabled lockWrite() must be |
1679 | called before any write calls are made on the scene. |
1680 | |
1681 | Only one thread may write at a time and no threads may read while a thread is writing. |
1682 | If a call to lockWrite() is made and there are other threads reading then the |
1683 | calling thread will be blocked until the readers complete. |
1684 | |
1685 | Writers have priority. If a thread is blocked waiting to write then subsequent calls to |
1686 | lockRead() from other threads will be blocked until the writer completes. |
1687 | |
1688 | \note If multiple threads are waiting to write then the thread that is first |
1689 | granted access depends on OS scheduling. |
1690 | |
1691 | \note Recursive locking is supported but each lockWrite() call must be paired |
1692 | with an unlockWrite(). |
1693 | |
1694 | \note If a thread has already locked the scene for writing then it may call |
1695 | lockRead(). |
1696 | |
1697 | \param file String representing the calling file, for debug purposes |
1698 | \param line The source file line number, for debug purposes |
1699 | */ |
1700 | virtual void lockWrite(const char* file=NULL, PxU32 line=0) = 0; |
1701 | |
1702 | /** |
1703 | \brief Unlock the scene from writing. |
1704 | |
1705 | \note Each unlockWrite() must be paired with a lockWrite() from the same thread. |
1706 | */ |
1707 | virtual void unlockWrite() = 0; |
1708 | |
1709 | |
1710 | /** |
1711 | \brief set the cache blocks that can be used during simulate(). |
1712 | |
1713 | Each frame the simulation requires memory to store contact, friction, and contact cache data. This memory is used in blocks of 16K. |
1714 | Each frame the blocks used by the previous frame are freed, and may be retrieved by the application using PxScene::flushSimulation() |
1715 | |
1716 | This call will force allocation of cache blocks if the numBlocks parameter is greater than the currently allocated number |
1717 | of blocks, and less than the max16KContactDataBlocks parameter specified at scene creation time. |
1718 | |
1719 | \param[in] numBlocks The number of blocks to allocate. |
1720 | |
1721 | @see PxSceneDesc.nbContactDataBlocks PxSceneDesc.maxNbContactDataBlocks flushSimulation() getNbContactDataBlocksUsed getMaxNbContactDataBlocksUsed |
1722 | */ |
1723 | virtual void setNbContactDataBlocks(PxU32 numBlocks) = 0; |
1724 | |
1725 | |
1726 | /** |
1727 | \brief get the number of cache blocks currently used by the scene |
1728 | |
1729 | This function may not be called while the scene is simulating |
1730 | |
1731 | \return the number of cache blocks currently used by the scene |
1732 | |
1733 | @see PxSceneDesc.nbContactDataBlocks PxSceneDesc.maxNbContactDataBlocks flushSimulation() setNbContactDataBlocks() getMaxNbContactDataBlocksUsed() |
1734 | */ |
1735 | virtual PxU32 getNbContactDataBlocksUsed() const = 0; |
1736 | |
1737 | /** |
1738 | \brief get the maximum number of cache blocks used by the scene |
1739 | |
1740 | This function may not be called while the scene is simulating |
1741 | |
1742 | \return the maximum number of cache blocks everused by the scene |
1743 | |
1744 | @see PxSceneDesc.nbContactDataBlocks PxSceneDesc.maxNbContactDataBlocks flushSimulation() setNbContactDataBlocks() getNbContactDataBlocksUsed() |
1745 | */ |
1746 | virtual PxU32 getMaxNbContactDataBlocksUsed() const = 0; |
1747 | |
1748 | |
1749 | /** |
1750 | \brief Return the value of PxSceneDesc::contactReportStreamBufferSize that was set when creating the scene with PxPhysics::createScene |
1751 | |
1752 | @see PxSceneDesc::contactReportStreamBufferSize, PxPhysics::createScene |
1753 | */ |
1754 | virtual PxU32 getContactReportStreamBufferSize() const = 0; |
1755 | |
1756 | |
1757 | /** |
1758 | \brief Sets the number of actors required to spawn a separate rigid body solver thread. |
1759 | |
1760 | \param[in] solverBatchSize Number of actors required to spawn a separate rigid body solver thread. |
1761 | |
1762 | <b>Platform specific:</b> Not applicable on PS3. |
1763 | |
1764 | @see PxSceneDesc.solverBatchSize getSolverBatchSize() |
1765 | */ |
1766 | virtual void setSolverBatchSize(PxU32 solverBatchSize) = 0; |
1767 | |
1768 | /** |
1769 | \brief Retrieves the number of actors required to spawn a separate rigid body solver thread. |
1770 | |
1771 | \return Current number of actors required to spawn a separate rigid body solver thread. |
1772 | |
1773 | <b>Platform specific:</b> Not applicable on PS3. |
1774 | |
1775 | @see PxSceneDesc.solverBatchSize setSolverBatchSize() |
1776 | */ |
1777 | virtual PxU32 getSolverBatchSize() const = 0; |
1778 | |
1779 | |
1780 | //@} |
1781 | |
1782 | /** |
1783 | \brief Returns the wake counter reset value. |
1784 | |
1785 | \return Wake counter reset value |
1786 | |
1787 | @see PxSceneDesc.wakeCounterResetValue |
1788 | */ |
1789 | virtual PxReal getWakeCounterResetValue() const = 0; |
1790 | |
1791 | /** |
1792 | \brief Shift the scene origin by the specified vector. |
1793 | |
1794 | The poses of all objects in the scene and the corresponding data structures will get adjusted to reflect the new origin location |
1795 | (the shift vector will get subtracted from all object positions). |
1796 | |
1797 | \note It is the user's responsibility to keep track of the summed total origin shift and adjust all input/output to/from PhysX accordingly. |
1798 | |
1799 | \note Do not use this method while the simulation is running. Calls to this method while the simulation is running will be ignored. |
1800 | |
1801 | \note Make sure to propagate the origin shift to other dependent modules (for example, the character controller module etc.). |
1802 | |
1803 | \note This is an expensive operation and we recommend to use it only in the case where distance related precision issues may arise in areas far from the origin. |
1804 | |
1805 | \param[in] shift Translation vector to shift the origin by. |
1806 | */ |
1807 | virtual void shiftOrigin(const PxVec3& shift) = 0; |
1808 | |
1809 | void* userData; //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. |
1810 | }; |
1811 | |
1812 | #ifndef PX_DOXYGEN |
1813 | } // namespace physx |
1814 | #endif |
1815 | |
1816 | /** @} */ |
1817 | #endif |
1818 | |