RavEngine
Loading...
Searching...
No Matches
ScElementSim.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 SC_ELEMENT_SIM_H
30#define SC_ELEMENT_SIM_H
31
32#include "foundation/PxUserAllocated.h"
33#include "PxFiltering.h"
34#include "PxvConfig.h"
35#include "ScActorSim.h"
36#include "ScInteraction.h"
37#include "BpAABBManager.h"
38#include "ScObjectIDTracker.h"
39
40namespace physx
41{
42namespace Sc
43{
44 class ElementSimInteraction;
45
46 /*
47 A ElementSim is a part of a ActorSim. It contributes to the activation framework by adding its
48 interactions to the actor. */
50 {
51 PX_NOCOPY(ElementSim)
52
53 public:
55 {
56 public:
57 PX_FORCE_INLINE ElementInteractionIterator(const ElementSim& e, PxU32 nbInteractions, Interaction** interactions) :
58 mInteractions(interactions), mInteractionsLast(interactions + nbInteractions), mElement(&e) {}
59 ElementSimInteraction* getNext();
60
61 private:
62 Interaction** mInteractions;
63 Interaction** mInteractionsLast;
64 const ElementSim* mElement;
65 };
66
68 {
69 public:
70 PX_FORCE_INLINE ElementInteractionReverseIterator(const ElementSim& e, PxU32 nbInteractions, Interaction** interactions) :
71 mInteractions(interactions), mInteractionsLast(interactions + nbInteractions), mElement(&e) {}
72 ElementSimInteraction* getNext();
73
74 private:
75 Interaction** mInteractions;
76 Interaction** mInteractionsLast;
77 const ElementSim* mElement;
78 };
79
80 ElementSim(ActorSim& actor);
81 protected:
83 public:
84
85 // Get an iterator to the interactions connected to the element
86 PX_FORCE_INLINE ElementInteractionIterator getElemInteractions() const { return ElementInteractionIterator(*this, mActor.getActorInteractionCount(), mActor.getActorInteractions()); }
87 PX_FORCE_INLINE ElementInteractionReverseIterator getElemInteractionsReverse() const { return ElementInteractionReverseIterator(*this, mActor.getActorInteractionCount(), mActor.getActorInteractions()); }
88
89 PX_FORCE_INLINE ActorSim& getActor() const { return mActor; }
90
91 PX_FORCE_INLINE Scene& getScene() const { return mActor.getScene(); }
92
93 PX_FORCE_INLINE PxU32 getElementID() const { return mElementID; }
94 PX_FORCE_INLINE bool isInBroadPhase() const { return mInBroadPhase; }
95
96 //PX_FORCE_INLINE Bp::ElementType::Enum getElementType() const { return mType; }
97
98 void addToAABBMgr(PxReal contactDistance, Bp::FilterGroup::Enum group, Bp::ElementType::Enum type);
99 bool removeFromAABBMgr();
100
101 void setElementInteractionsDirty(InteractionDirtyFlag::Enum flag, PxU8 interactionFlag);
102
103 PX_FORCE_INLINE void initID()
104 {
105 Scene& scene = getScene();
106 mElementID = scene.getElementIDPool().createID();
107 scene.getBoundsArray().initEntry(mElementID);
108 }
109
110 PX_FORCE_INLINE void releaseID()
111 {
112 getScene().getElementIDPool().releaseID(mElementID);
113 }
114 protected:
115 ActorSim& mActor;
116
117 PxU32 mElementID : 31;
118 PxU32 mInBroadPhase : 1;
119 //Bp::ElementType::Enum mType;
120 public:
121 PxU32 mShapeArrayIndex;
122 };
123
124 PX_FORCE_INLINE void setFilterObjectAttributeType(PxFilterObjectAttributes& attr, PxFilterObjectType::Enum type)
125 {
126 PX_ASSERT((attr & (PxFilterObjectType::eMAX_TYPE_COUNT-1)) == 0);
127 attr |= type;
128 }
129} // namespace Sc
130}
131
132#endif
Definition PxUserAllocated.h:43
Definition ScActorSim.h:83
Definition ScElementSimInteraction.h:40
Definition ScElementSim.h:50
Definition ScInteraction.h:50
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxU32 PxFilterObjectAttributes
Structure which gets passed into the collision filtering shader and/or callback providing additional ...
Definition PxFiltering.h:515
Enum
Definition PxFiltering.h:445
@ eMAX_TYPE_COUNT
internal use only!
Definition PxFiltering.h:491