RavEngine
Loading...
Searching...
No Matches
NpAggregate.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 NP_AGGREGATE_H
30#define NP_AGGREGATE_H
31
32#include "PxAggregate.h"
33#include "NpBase.h"
34
35namespace physx
36{
37class NpScene;
38
39class NpAggregate : public PxAggregate, public NpBase
40{
41//= ATTENTION! =====================================================================================
42// Changing the data layout of this class breaks the binary serialization format. See comments for
43// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
44// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
45// accordingly.
46//==================================================================================================
47public:
48// PX_SERIALIZATION
49 NpAggregate(PxBaseFlags baseFlags) : PxAggregate(baseFlags), NpBase(PxEmpty) {}
50 void preExportDataReset();
51 virtual void exportExtraData(PxSerializationContext& context);
52 void importExtraData(PxDeserializationContext& context);
53 void resolveReferences(PxDeserializationContext& context);
54 virtual void requiresObjects(PxProcessPxBaseCallback& c);
55 static NpAggregate* createObject(PxU8*& address, PxDeserializationContext& context);
56 static void getBinaryMetaData(PxOutputStream& stream);
57//~PX_SERIALIZATION
58 NpAggregate(PxU32 maxActors, PxU32 maxShapes, PxAggregateFilterHint filterHint);
59 virtual ~NpAggregate();
60
61 // PxAggregate
62 virtual void release() PX_OVERRIDE;
63 virtual bool addActor(PxActor&, const PxBVH*) PX_OVERRIDE;
64 virtual bool removeActor(PxActor&) PX_OVERRIDE;
67 virtual PxU32 getNbActors() const PX_OVERRIDE;
68 virtual PxU32 getMaxNbActors() const PX_OVERRIDE;
69 virtual PxU32 getMaxNbShapes() const PX_OVERRIDE;
70 virtual PxU32 getActors(PxActor** userBuffer, PxU32 bufferSize, PxU32 startIndex) const PX_OVERRIDE;
71 virtual PxScene* getScene() PX_OVERRIDE;
72 virtual bool getSelfCollision() const PX_OVERRIDE;
73 //~PxAggregate
74
75 PX_FORCE_INLINE PxU32 getMaxNbShapesFast() const { return mMaxNbShapes; }
76 PX_FORCE_INLINE PxU32 getCurrentSizeFast() const { return mNbActors; }
77 PX_FORCE_INLINE PxActor* getActorFast(PxU32 i) const { return mActors[i]; }
78 PX_FORCE_INLINE PxU32 getAggregateID() const { return mAggregateID; }
79 PX_FORCE_INLINE void setAggregateID(PxU32 cid) { mAggregateID = cid; }
80
81 PX_FORCE_INLINE bool getSelfCollideFast() const { return PxGetAggregateSelfCollisionBit(mFilterHint)!=0; }
82 PX_FORCE_INLINE PxAggregateFilterHint getFilterHint() const { return mFilterHint; }
83
84 void addActorInternal(PxActor& actor, NpScene& s, const PxBVH* bvh);
85 void removeAndReinsert(PxActor& actor, bool reinsert);
86 bool removeActorAndReinsert(PxActor& actor, bool reinsert);
87 bool removeArticulationAndReinsert(PxArticulationReducedCoordinate& art, bool reinsert);
88
89 void scAddActor(NpActor&);
90 void scRemoveActor(NpActor& actor, bool reinsert);
91
92 void incShapeCount();
93 void decShapeCount();
94private:
95 PxU32 mAggregateID;
96 PxU32 mMaxNbActors;
97 PxU32 mMaxNbShapes;
98 PxAggregateFilterHint mFilterHint;
99 PxU32 mNbActors;
100 PxU32 mNbShapes;
101 PxActor** mActors;
102};
103
104}
105
106#endif
Definition base.h:1940
Definition NpActor.h:45
Definition NpAggregate.h:40
virtual bool removeActor(PxActor &) PX_OVERRIDE
Removes an actor from the aggregate object.
Definition NpAggregate.cpp:268
virtual PxScene * getScene() PX_OVERRIDE
Retrieves the scene which this aggregate belongs to.
Definition NpAggregate.cpp:410
virtual PxU32 getNbActors() const PX_OVERRIDE
Returns the number of actors contained in the aggregate.
Definition NpAggregate.cpp:386
virtual bool addArticulation(PxArticulationReducedCoordinate &) PX_OVERRIDE
Adds an articulation to the aggregate object.
Definition NpAggregate.cpp:304
virtual bool removeArticulation(PxArticulationReducedCoordinate &) PX_OVERRIDE
Removes an articulation from the aggregate object.
Definition NpAggregate.cpp:373
virtual bool getSelfCollision() const PX_OVERRIDE
Retrieves aggregate's self-collision flag.
Definition NpAggregate.cpp:415
virtual bool addActor(PxActor &, const PxBVH *) PX_OVERRIDE
Adds an actor to the aggregate object.
Definition NpAggregate.cpp:175
virtual PxU32 getMaxNbActors() const PX_OVERRIDE
Retrieves max amount of actors that can be contained in the aggregate.
Definition NpAggregate.cpp:392
virtual PxU32 getMaxNbShapes() const PX_OVERRIDE
Retrieves max amount of shapes that can be contained in the aggregate.
Definition NpAggregate.cpp:398
virtual PxU32 getActors(PxActor **userBuffer, PxU32 bufferSize, PxU32 startIndex) const PX_OVERRIDE
Retrieve all actors contained in the aggregate.
Definition NpAggregate.cpp:404
virtual void release() PX_OVERRIDE
Deletes the aggregate object.
Definition NpAggregate.cpp:113
Definition NpBase.h:167
Definition NpScene.h:130
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
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
Binary deserialization context class.
Definition PxSerialFramework.h:174
Output stream class for I/O.
Definition PxIO.h:114
Callback class used to process PxBase objects.
Definition PxSerialFramework.h:81
A scene is a collection of bodies and constraints which can interact.
Definition PxScene.h:178
Binary serialization context class.
Definition PxSerialFramework.h:99
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_OVERRIDE
Definition PxPreprocessor.h:375
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39