RavEngine
Loading...
Searching...
No Matches
ScActorCore.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_ACTOR_CORE_H
30#define SC_ACTOR_CORE_H
31
32#include "common/PxMetaData.h"
33#include "PxActor.h"
34#include "foundation/PxUserAllocated.h"
35
36namespace physx
37{
38
39class PxActor;
40
41namespace Sc
42{
43
44 class Scene;
45 class ActorSim;
46
48 {
49 //= ATTENTION! =====================================================================================
50 // Changing the data layout of this class breaks the binary serialization format. See comments for
51 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
52 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
53 // accordingly.
54 //==================================================================================================
55 public:
56// PX_SERIALIZATION
57 ActorCore(const PxEMPTY) : mSim(NULL), mActorFlags(PxEmpty)
58 {
59 }
60 static void getBinaryMetaData(PxOutputStream& stream);
61//~PX_SERIALIZATION
62 ActorCore(PxActorType::Enum actorType, PxU8 actorFlags,
63 PxClientID owner, PxDominanceGroup dominanceGroup);
64 /*virtual*/ ~ActorCore();
65
66 PX_FORCE_INLINE ActorSim* getSim() const { return mSim; }
67 PX_FORCE_INLINE void setSim(ActorSim* sim)
68 {
69 PX_ASSERT((sim==NULL) ^ (mSim==NULL));
70 mSim = sim;
71 }
72
73 PX_FORCE_INLINE PxActorFlags getActorFlags() const { return mActorFlags; }
74 void setActorFlags(PxActorFlags af);
75
76 PX_FORCE_INLINE PxDominanceGroup getDominanceGroup() const
77 {
78 return PxDominanceGroup(mDominanceGroup);
79 }
80 void setDominanceGroup(PxDominanceGroup g);
81
82 PX_FORCE_INLINE void setOwnerClient(PxClientID inId)
83 {
84 const PxU32 aggid = mAggregateIDOwnerClient & 0x00ffffff;
85 mAggregateIDOwnerClient = (PxU32(inId)<<24) | aggid;
86 }
87 PX_FORCE_INLINE PxClientID getOwnerClient() const
88 {
89 return mAggregateIDOwnerClient>>24;
90 }
91
92 PX_FORCE_INLINE PxActorType::Enum getActorCoreType() const { return PxActorType::Enum(mActorType); }
93
94 void reinsertShapes();
95
96 PX_FORCE_INLINE void setAggregateID(PxU32 id)
97 {
98 PX_ASSERT(id==0xffffffff || id<(1<<24));
99 const PxU32 ownerClient = mAggregateIDOwnerClient & 0xff000000;
100 mAggregateIDOwnerClient = (id & 0x00ffffff) | ownerClient;
101 }
102 PX_FORCE_INLINE PxU32 getAggregateID() const
103 {
104 const PxU32 id = mAggregateIDOwnerClient & 0x00ffffff;
105 return id == 0x00ffffff ? PX_INVALID_U32 : id;
106 }
107 //virtual PxActor* getPxActor() const = 0;
108 //virtual PxIntBool isFrozen() const { return IntTrue; };
109
110 private:
111 ActorSim* mSim; //
112 PxU32 mAggregateIDOwnerClient; // PxClientID (8bit) | aggregate ID (24bit)
113 // PT: TODO: the remaining members could be packed into just a 16bit mask
114 PxActorFlags mActorFlags; // PxActor's flags (PxU8) => only 4 bits used
115 PxU8 mActorType; // Actor type (8 bits, but 3 would be enough)
116 PxU8 mDominanceGroup; // Dominance group (8 bits, but 5 would be enough because "must be < 32")
117 };
118
119#if PX_P64_FAMILY
121#else
123#endif
124
125} // namespace Sc
126
127}
128
130
131#endif
Output stream class for I/O.
Definition PxIO.h:114
Definition PxUserAllocated.h:43
Definition ScActorCore.h:48
Definition ScActorSim.h:83
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxU8 PxClientID
An ID to identify different clients for multiclient support.
Definition PxClient.h:44
PxU8 PxDominanceGroup
Group index which allows to specify 1- or 2-way interaction.
Definition PxActor.h:56
PxEMPTY
Definition Px.h:87
Enum
Definition PxActor.h:121