RavEngine
Loading...
Searching...
No Matches
SqCompoundPruner.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 SQ_COMPOUND_PRUNER_H
30#define SQ_COMPOUND_PRUNER_H
31
32#include "SqCompoundPruningPool.h"
33#include "GuSqInternal.h"
34#include "GuPrunerMergeData.h"
35#include "GuIncrementalAABBTree.h"
36#include "GuPruningPool.h"
37#include "foundation/PxHashMap.h"
38#include "foundation/PxArray.h"
39
40namespace physx
41{
42namespace Sq
43{
45
46 typedef PxHashMap<PrunerCompoundId, Gu::PoolIndex> ActorIdPoolIndexMap;
47 typedef PxArray<PrunerCompoundId> PoolIndexActorIdMap;
48
50
52 {
53 public:
54 BVHCompoundPruner(PxU64 contextID);
55 virtual ~BVHCompoundPruner();
56
57 void release();
58
59 // BasePruner
60 DECLARE_BASE_PRUNER_API
61 //~BasePruner
62
63 // CompoundPruner
64 // compound level
65 virtual bool addCompound(Gu::PrunerHandle* results, const Gu::BVH& bvh, PrunerCompoundId compoundId, const PxTransform& transform, bool isDynamic, const Gu::PrunerPayload* data, const PxTransform* transforms);
66 virtual bool removeCompound(PrunerCompoundId compoundId, Gu::PrunerPayloadRemovalCallback* removalCallback);
67 virtual bool updateCompound(PrunerCompoundId compoundId, const PxTransform& transform);
68 // object level
69 virtual void updateObjectAfterManualBoundsUpdates(PrunerCompoundId compoundId, const Gu::PrunerHandle handle);
70 virtual void removeObject(PrunerCompoundId compoundId, const Gu::PrunerHandle handle, Gu::PrunerPayloadRemovalCallback* removalCallback);
71 virtual bool addObject(PrunerCompoundId compoundId, Gu::PrunerHandle& result, const PxBounds3& bounds, const Gu::PrunerPayload userData, const PxTransform& transform);
72 //queries
73 virtual bool raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, CompoundPrunerRaycastCallback&, PxCompoundPrunerQueryFlags flags) const;
74 virtual bool overlap(const Gu::ShapeData& queryVolume, CompoundPrunerOverlapCallback&, PxCompoundPrunerQueryFlags flags) const;
75 virtual bool sweep(const Gu::ShapeData& queryVolume, const PxVec3& unitDir, PxReal& inOutDistance, CompoundPrunerRaycastCallback&, PxCompoundPrunerQueryFlags flags) const;
76 virtual const Gu::PrunerPayload& getPayloadData(Gu::PrunerHandle handle, PrunerCompoundId compoundId, Gu::PrunerPayloadData* data) const;
77 virtual void preallocate(PxU32 nbEntries);
78 virtual bool setTransform(Gu::PrunerHandle handle, PrunerCompoundId compoundId, const PxTransform& transform);
79 virtual const PxTransform& getTransform(PrunerCompoundId compoundId) const;
80 virtual void visualizeEx(PxRenderOutput& out, PxU32 color, bool drawStatic, bool drawDynamic) const;
81 // ~CompoundPruner
82
83 private:
84 void updateMapping(const Gu::PoolIndex poolIndex, Gu::IncrementalAABBTreeNode* node);
85 void updateMainTreeNode(Gu::PoolIndex index);
86
87 void test();
88
90 UpdateMap mMainTreeUpdateMap;
91
92 CompoundTreePool mCompoundTreePool;
93 ActorIdPoolIndexMap mActorPoolMap;
94 PoolIndexActorIdMap mPoolActorMap;
95 Gu::NodeList mChangedLeaves;
96 mutable bool mDrawStatic;
97 mutable bool mDrawDynamic;
98 };
99}
100}
101
102#endif
Represents a BVH.
Definition GuBVH.h:93
Definition GuIncrementalAABBTree.h:68
Definition GuIncrementalAABBTree.h:131
Definition GuBounds.h:115
Class representing 3D range or axis aligned bounding box.
Definition PxBounds3.h:58
Definition PxRenderOutput.h:50
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
Definition SqCompoundPruner.h:52
virtual DECLARE_BASE_PRUNER_API bool addCompound(Gu::PrunerHandle *results, const Gu::BVH &bvh, PrunerCompoundId compoundId, const PxTransform &transform, bool isDynamic, const Gu::PrunerPayload *data, const PxTransform *transforms)
Adds compound to the pruner.
Definition SqCompoundPruner.cpp:70
virtual bool raycast(const PxVec3 &origin, const PxVec3 &unitDir, PxReal &inOutDistance, CompoundPrunerRaycastCallback &, PxCompoundPrunerQueryFlags flags) const
Definition SqCompoundPruner.cpp:344
virtual bool addObject(PrunerCompoundId compoundId, Gu::PrunerHandle &result, const PxBounds3 &bounds, const Gu::PrunerPayload userData, const PxTransform &transform)
Adds object to the pruner.
Definition SqCompoundPruner.cpp:641
virtual const Gu::PrunerPayload & getPayloadData(Gu::PrunerHandle handle, PrunerCompoundId compoundId, Gu::PrunerPayloadData *data) const
Retrieves the object's payload and data associated with the handle.
Definition SqCompoundPruner.cpp:568
virtual void preallocate(PxU32 nbEntries)
Preallocate space.
Definition SqCompoundPruner.cpp:578
virtual bool removeCompound(PrunerCompoundId compoundId, Gu::PrunerPayloadRemovalCallback *removalCallback)
Definition SqCompoundPruner.cpp:132
virtual bool updateCompound(PrunerCompoundId compoundId, const PxTransform &transform)
Definition SqCompoundPruner.cpp:181
virtual void updateObjectAfterManualBoundsUpdates(PrunerCompoundId compoundId, const Gu::PrunerHandle handle)
Definition SqCompoundPruner.cpp:606
virtual void removeObject(PrunerCompoundId compoundId, const Gu::PrunerHandle handle, Gu::PrunerPayloadRemovalCallback *removalCallback)
Definition SqCompoundPruner.cpp:621
Definition SqPruner.h:87
Definition SqCompoundPruningPool.h:75
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition GuPrunerPayload.h:55
Definition GuPrunerPayload.h:63
Definition GuPrunerPayload.h:43