RavEngine
Loading...
Searching...
No Matches
ScShapeCore.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_SHAPE_CORE_H
30#define SC_SHAPE_CORE_H
31
32#include "foundation/PxUtilities.h"
33#include "PxvGeometry.h"
34#include "PxFiltering.h"
35#include "PxShape.h"
36
37namespace physx
38{
39class PxShape;
40
41namespace Sc
42{
43 class ShapeSim;
44
46 {
47 //= ATTENTION! =====================================================================================
48 // Changing the data layout of this class breaks the binary serialization format. See comments for
49 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
50 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
51 // accordingly.
52 //==================================================================================================
53 public:
54// PX_SERIALIZATION
55 ShapeCore(const PxEMPTY);
56 void exportExtraData(PxSerializationContext& stream);
57 void importExtraData(PxDeserializationContext& context);
58 void resolveReferences(PxDeserializationContext& context);
59 static void getBinaryMetaData(PxOutputStream& stream);
60 void resolveMaterialReference(PxU32 materialTableIndex, PxU16 materialIndex);
61//~PX_SERIALIZATION
62 ShapeCore(const PxGeometry& geometry, PxShapeFlags shapeFlags,
63 const PxU16* materialIndices, PxU16 materialCount, bool isExclusive,
64 PxShapeCoreFlag::Enum softOrClothFlags = PxShapeCoreFlag::Enum(0));
65
66 ~ShapeCore();
67
68 PX_FORCE_INLINE PxGeometryType::Enum getGeometryType() const { return mCore.mGeometry.getType(); }
69 PxShape* getPxShape();
70 const PxShape* getPxShape() const;
71
72 PX_FORCE_INLINE const GeometryUnion& getGeometryUnion() const { return mCore.mGeometry; }
73 PX_FORCE_INLINE const PxGeometry& getGeometry() const { return mCore.mGeometry.getGeometry(); }
74 void setGeometry(const PxGeometry& geom);
75
76 PxU16 getNbMaterialIndices() const;
77 const PxU16* getMaterialIndices() const;
78 void setMaterialIndices(const PxU16* materialIndices, PxU16 materialIndexCount);
79
80 PX_FORCE_INLINE const PxTransform& getShape2Actor() const { return mCore.getTransform(); }
81 PX_FORCE_INLINE void setShape2Actor(const PxTransform& s2b) { mCore.setTransform(s2b); }
82
83 PX_FORCE_INLINE const PxFilterData& getSimulationFilterData() const { return mSimulationFilterData; }
84 PX_FORCE_INLINE void setSimulationFilterData(const PxFilterData& data) { mSimulationFilterData = data; }
85
86 PX_FORCE_INLINE PxReal getContactOffset() const { return mCore.mContactOffset; }
87 void setContactOffset(PxReal offset);
88
89 PX_FORCE_INLINE PxReal getRestOffset() const { return mCore.mRestOffset; }
90 PX_FORCE_INLINE void setRestOffset(PxReal offset) { mCore.mRestOffset = offset; }
91
92 PX_FORCE_INLINE PxReal getDensityForFluid() const { return mCore.getDensityForFluid(); }
93 PX_FORCE_INLINE void setDensityForFluid(PxReal densityForFluid) { mCore.setDensityForFluid(densityForFluid); }
94
95 PX_FORCE_INLINE PxReal getTorsionalPatchRadius() const { return mCore.mTorsionalRadius; }
96 PX_FORCE_INLINE void setTorsionalPatchRadius(PxReal tpr) { mCore.mTorsionalRadius = tpr; }
97
98 PX_FORCE_INLINE PxReal getMinTorsionalPatchRadius() const {return mCore.mMinTorsionalPatchRadius; }
99 PX_FORCE_INLINE void setMinTorsionalPatchRadius(PxReal radius) { mCore.mMinTorsionalPatchRadius = radius; }
100
101 PX_FORCE_INLINE PxShapeFlags getFlags() const { return PxShapeFlags(mCore.mShapeFlags); }
102 PX_FORCE_INLINE void setFlags(PxShapeFlags f) { mCore.mShapeFlags = f; }
103
104 PX_FORCE_INLINE const PxsShapeCore& getCore() const { return mCore; }
105 static PX_FORCE_INLINE size_t getCoreOffset() { return PX_OFFSET_OF(ShapeCore, mCore); }
106 static PX_FORCE_INLINE ShapeCore& getCore(PxsShapeCore& core)
107 {
108 return *reinterpret_cast<ShapeCore*>(reinterpret_cast<PxU8*>(&core) - getCoreOffset());
109 }
110
111 PX_FORCE_INLINE ShapeSim* getSim() const
112 {
113 return reinterpret_cast<ShapeSim*>(size_t(mSimAndIsExclusive) & ~1);
114 }
115 PX_FORCE_INLINE void setSim(ShapeSim* sim)
116 {
117 PX_ASSERT((NULL == mSimAndIsExclusive) || (1 == size_t(mSimAndIsExclusive)));
118 PX_ASSERT(0 == (size_t(sim) & 1));
119 mSimAndIsExclusive = mSimAndIsExclusive ? reinterpret_cast<ShapeSim*>(size_t(sim) | size_t(mSimAndIsExclusive)) : mSimAndIsExclusive;
120 }
121 PX_FORCE_INLINE void clearSim()
122 {
123 mSimAndIsExclusive = reinterpret_cast<ShapeSim*>(size_t(mSimAndIsExclusive) & 1);
124 }
125
126#if PX_WINDOWS_FAMILY // PT: to avoid "error: offset of on non-standard-layout type" on Linux
127 protected:
128#endif
129 PxFilterData mSimulationFilterData; // Simulation filter data
130 PxsShapeCore PX_ALIGN(16, mCore);
131 ShapeSim* mSimAndIsExclusive;
132#if PX_WINDOWS_FAMILY // PT: to avoid "error: offset of on non-standard-layout type" on Linux
133 public:
134#endif
135 const char* mName; // PT: moved here from NpShape to fill padding bytes
136 };
137
138} // namespace Sc
139
140
141}
142
143#endif
Definition base.h:1940
Definition PxvGeometry.h:153
Binary deserialization context class.
Definition PxSerialFramework.h:174
A geometry object.
Definition PxGeometry.h:79
Output stream class for I/O.
Definition PxIO.h:114
Binary serialization context class.
Definition PxSerialFramework.h:99
Abstract class for collision shapes.
Definition PxShape.h:146
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
Definition ScShapeCore.h:46
Definition ScShapeSim.h:55
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_ALIGN(alignment, decl)
Definition PxPreprocessor.h:402
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxFlags< PxShapeFlag::Enum, PxU8 > PxShapeFlags
collection of set bits defined in PxShapeFlag.
Definition PxShape.h:126
PxEMPTY
Definition Px.h:87
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365
Enum
Definition PxGeometry.h:52
Definition PxvGeometry.h:221