MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / resolveReferences

Method resolveReferences

physx/source/physx/src/NpShape.cpp:138–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138void NpShape::resolveReferences(PxDeserializationContext& context)
139{
140 // getMaterials() only works after material indices have been patched.
141 // in order to get to the new material indices, we need access to the new materials.
142 // this only leaves us with the option of acquiring the material through the context given an old material index (we do have the mapping)
143 {
144 PxU32 nbIndices = mShape.getScShape().getNbMaterialIndices();
145 const PxU16* indices = mShape.getScShape().getMaterialIndices();
146
147 for (PxU32 i=0; i < nbIndices; i++)
148 {
149 PxBase* base = context.resolveReference(PX_SERIAL_REF_KIND_MATERIAL_IDX, size_t(indices[i]));
150 PX_ASSERT(base && base->is<PxMaterial>());
151
152 NpMaterial& material = *static_cast<NpMaterial*>(base);
153 getScbShape().getScShape().resolveMaterialReference(i, PxU16(material.getHandle()));
154 }
155 }
156
157 context.translatePxBase(mActor);
158
159 getScbShape().getScShape().resolveReferences(context);
160
161
162 incMeshRefCount();
163
164 // Increment materials' refcounts in a second pass. Works better in case of failure above.
165 PxU32 nbMaterials = mShape.getNbMaterials();
166 for (PxU32 i=0; i < nbMaterials; i++)
167 {
168 NpMaterial* mat = static_cast<NpMaterial*>(mShape.getMaterial(i));
169 mat->incRefCount();
170 }
171}
172
173NpShape* NpShape::createObject(PxU8*& address, PxDeserializationContext& context)
174{

Callers 4

createObjectMethod · 0.45
createObjectMethod · 0.45
createObjectMethod · 0.45
createObjectMethod · 0.45

Calls 9

getNbMaterialIndicesMethod · 0.80
resolveReferenceMethod · 0.80
translatePxBaseMethod · 0.80
getMaterialIndicesMethod · 0.45
getHandleMethod · 0.45
getNbMaterialsMethod · 0.45
getMaterialMethod · 0.45
incRefCountMethod · 0.45

Tested by

no test coverage detected