1//
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions
4// are met:
5// * Redistributions of source code must retain the above copyright
6// notice, this list of conditions and the following disclaimer.
7// * Redistributions in binary form must reproduce the above copyright
8// notice, this list of conditions and the following disclaimer in the
9// documentation and/or other materials provided with the distribution.
10// * Neither the name of NVIDIA CORPORATION nor the names of its
11// contributors may be used to endorse or promote products derived
12// from this software without specific prior written permission.
13//
14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29
30
31#ifndef PX_COLLISION_ACTOR_CORE
32#define PX_COLLISION_ACTOR_CORE
33
34#include "common/PxMetaData.h"
35#include "PxActor.h"
36#include "PsUserAllocated.h"
37#include "CmPhysXCommon.h"
38
39namespace physx
40{
41
42class PxActor;
43
44namespace Sc
45{
46
47 class Scene;
48 class ActorSim;
49
50 class ActorCore : public Ps::UserAllocated
51 {
52 //= ATTENTION! =====================================================================================
53 // Changing the data layout of this class breaks the binary serialization format. See comments for
54 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
55 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
56 // accordingly.
57 //==================================================================================================
58 public:
59// PX_SERIALIZATION
60 ActorCore(const PxEMPTY) : mSim(NULL), mActorFlags(PxEmpty)
61 {
62 }
63 static void getBinaryMetaData(PxOutputStream& stream);
64//~PX_SERIALIZATION
65 ActorCore(PxActorType::Enum actorType, PxU8 actorFlags,
66 PxClientID owner, PxDominanceGroup dominanceGroup);
67 /*virtual*/ ~ActorCore();
68
69 PX_FORCE_INLINE ActorSim* getSim() const { return mSim; }
70 PX_FORCE_INLINE void setSim(ActorSim* sim)
71 {
72 PX_ASSERT((sim==NULL) ^ (mSim==NULL));
73 mSim = sim;
74 }
75
76 PX_FORCE_INLINE PxActorFlags getActorFlags() const { return mActorFlags; }
77 void setActorFlags(PxActorFlags af);
78
79 PX_FORCE_INLINE PxDominanceGroup getDominanceGroup() const
80 {
81 return PxDominanceGroup(mDominanceGroup);
82 }
83 void setDominanceGroup(PxDominanceGroup g);
84
85 PX_FORCE_INLINE void setOwnerClient(PxClientID inId)
86 {
87 const PxU32 aggid = mAggregateIDOwnerClient & 0x00ffffff;
88 mAggregateIDOwnerClient = (PxU32(inId)<<24) | aggid;
89 }
90 PX_FORCE_INLINE PxClientID getOwnerClient() const
91 {
92 return mAggregateIDOwnerClient>>24;
93 }
94
95 PX_FORCE_INLINE PxActorType::Enum getActorCoreType() const { return PxActorType::Enum(mActorType); }
96
97 void reinsertShapes();
98
99 PX_FORCE_INLINE void setAggregateID(PxU32 id)
100 {
101 PX_ASSERT(id==0xffffffff || id<(1<<24));
102 const PxU32 ownerClient = mAggregateIDOwnerClient & 0xff000000;
103 mAggregateIDOwnerClient = (id & 0x00ffffff) | ownerClient;
104 }
105 PX_FORCE_INLINE PxU32 getAggregateID() const
106 {
107 const PxU32 id = mAggregateIDOwnerClient & 0x00ffffff;
108 return id == 0x00ffffff ? PX_INVALID_U32 : id;
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
120 PX_COMPILE_TIME_ASSERT(sizeof(Sc::ActorCore)==16);
121#else
122 PX_COMPILE_TIME_ASSERT(sizeof(Sc::ActorCore)==12);
123#endif
124
125} // namespace Sc
126
127}
128
129//////////////////////////////////////////////////////////////////////////
130
131#endif
132

source code of qtquick3dphysics/src/3rdparty/PhysX/source/simulationcontroller/include/ScActorCore.h