RavEngine
Loading...
Searching...
No Matches
PxAggregate.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_AGGREGATE_H
30#define PX_AGGREGATE_H
31
36#include "PxPhysXConfig.h"
37#include "common/PxBase.h"
38
39#if !PX_DOXYGEN
40namespace physx
41{
42#endif
43
44class PxActor;
45class PxBVH;
46class PxScene;
47
49 {
50 enum Enum
51 {
53 eSTATIC = 1,
54 eKINEMATIC = 2
55 };
56 };
57
58 // PxAggregateFilterHint is used for more efficient filtering of aggregates outside of the broadphase.
59 // It is a combination of a PxAggregateType and a self-collision bit.
60 typedef PxU32 PxAggregateFilterHint;
61
62 PX_CUDA_CALLABLE PX_FORCE_INLINE PxAggregateFilterHint PxGetAggregateFilterHint(PxAggregateType::Enum type, bool enableSelfCollision)
63 {
64 const PxU32 selfCollisionBit = enableSelfCollision ? 1 : 0;
65 return PxAggregateFilterHint((PxU32(type)<<1)|selfCollisionBit);
66 }
67
68 PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 PxGetAggregateSelfCollisionBit(PxAggregateFilterHint hint)
69 {
70 return hint & 1;
71 }
72
73 PX_CUDA_CALLABLE PX_FORCE_INLINE PxAggregateType::Enum PxGetAggregateType(PxAggregateFilterHint hint)
74 {
75 return PxAggregateType::Enum(hint>>1);
76 }
77
97class PxAggregate : public PxBase
98{
99public:
100
109 virtual void release() = 0;
110
131 virtual bool addActor(PxActor& actor, const PxBVH* bvh = NULL) = 0;
132
144 virtual bool removeActor(PxActor& actor) = 0;
145
160 virtual bool addArticulation(PxArticulationReducedCoordinate& articulation) = 0;
161
174
184 virtual PxU32 getNbActors() const = 0;
185
197 PX_DEPRECATED virtual PxU32 getMaxNbActors() const = 0;
198
206 virtual PxU32 getMaxNbShapes() const = 0;
207
220 virtual PxU32 getActors(PxActor** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
221
229 virtual PxScene* getScene() = 0;
230
236 virtual bool getSelfCollision() const = 0;
237
238 virtual const char* getConcreteTypeName() const { return "PxAggregate"; }
239
240 void* userData;
241
242protected:
243 PX_INLINE PxAggregate(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
244 PX_INLINE PxAggregate(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
245 virtual ~PxAggregate() {}
246 virtual bool isKindOf(const char* name) const { return !::strcmp("PxAggregate", name) || PxBase::isKindOf(name); }
247};
248
249#if !PX_DOXYGEN
250} // namespace physx
251#endif
252
254#endif
PxActor is the base class for the main simulation objects in the physics SDK.
Definition PxActor.h:201
Class to aggregate actors into a single broad-phase entry.
Definition PxAggregate.h:98
virtual PxU32 getActors(PxActor **userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const =0
Retrieve all actors contained in the aggregate.
virtual PxU32 getMaxNbShapes() const =0
Retrieves max amount of shapes that can be contained in the aggregate.
virtual PxScene * getScene()=0
Retrieves the scene which this aggregate belongs to.
virtual bool removeArticulation(PxArticulationReducedCoordinate &articulation)=0
Removes an articulation from the aggregate object.
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxAggregate.h:246
void * userData
user can assign this to whatever, usually to create a 1:1 relationship with a user object.
Definition PxAggregate.h:240
virtual PX_DEPRECATED PxU32 getMaxNbActors() const =0
Retrieves max amount of actors that can be contained in the aggregate.
virtual void release()=0
Deletes the aggregate object.
virtual bool removeActor(PxActor &actor)=0
Removes an actor from the aggregate object.
virtual bool getSelfCollision() const =0
Retrieves aggregate's self-collision flag.
virtual PxU32 getNbActors() const =0
Returns the number of actors contained in the aggregate.
virtual bool addArticulation(PxArticulationReducedCoordinate &articulation)=0
Adds an articulation to the aggregate object.
virtual bool addActor(PxActor &actor, const PxBVH *bvh=NULL)=0
Adds an actor to the aggregate object.
virtual const char * getConcreteTypeName() const
Returns string name of dynamic type.
Definition PxAggregate.h:238
A tree structure of bodies connected by joints that is treated as a unit by the dynamics solver....
Definition PxArticulationReducedCoordinate.h:448
Class representing a bounding volume hierarchy.
Definition PxBVH.h:63
Base class for objects that can be members of a PxCollection.
Definition PxBase.h:73
virtual bool isKindOf(const char *superClass) const
Returns whether a given type name matches with the type of this instance.
Definition PxBase.h:179
A scene is a collection of bodies and constraints which can interact.
Definition PxScene.h:178
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_INLINE
Definition PxPreprocessor.h:320
#define PX_DEPRECATED
Definition PxPreprocessor.h:418
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition PxAggregate.h:49
Enum
Definition PxAggregate.h:51
@ eKINEMATIC
Aggregate will only contain kinematic actors.
Definition PxAggregate.h:54
@ eSTATIC
Aggregate will only contain static actors.
Definition PxAggregate.h:53
@ eGENERIC
Aggregate will contain various actors of unspecified types.
Definition PxAggregate.h:52