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