| 394 | /////////////////////////////////////////////////////////////////////////////// |
| 395 | |
| 396 | void NpShape::setMaterials(PxMaterial*const* materials, PxU16 materialCount) |
| 397 | { |
| 398 | NP_WRITE_CHECK(getOwnerScene()); |
| 399 | PX_CHECK_AND_RETURN(isWritable(), "PxShape::setMaterials: shared shapes attached to actors are not writable."); |
| 400 | |
| 401 | #if PX_CHECKED |
| 402 | if (!NpShape::checkMaterialSetup(mShape.getGeometry(), "PxShape::setMaterials()", materials, materialCount)) |
| 403 | return; |
| 404 | #endif |
| 405 | |
| 406 | PxU32 oldMaterialCount = mShape.getNbMaterials(); |
| 407 | PX_ALLOCA(oldMaterials, PxMaterial*, oldMaterialCount); |
| 408 | PxU32 tmp = mShape.getMaterials(oldMaterials, oldMaterialCount); |
| 409 | PX_ASSERT(tmp == oldMaterialCount); |
| 410 | PX_UNUSED(tmp); |
| 411 | |
| 412 | if (mShape.setMaterials(materials, materialCount)) |
| 413 | { |
| 414 | for(PxU32 i=0; i < materialCount; i++) |
| 415 | static_cast<NpMaterial*>(materials[i])->incRefCount(); |
| 416 | |
| 417 | for(PxU32 i=0; i < oldMaterialCount; i++) |
| 418 | static_cast<NpMaterial*>(oldMaterials[i])->decRefCount(); |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | PxU16 NpShape::getNbMaterials() const |
| 423 | { |
no test coverage detected