| 1202 | } |
| 1203 | |
| 1204 | void ConvexShape::_updateMaterial() |
| 1205 | { |
| 1206 | //update our custom surface materials |
| 1207 | for (U32 i = 0; i<mSurfaceTextures.size(); i++) |
| 1208 | { |
| 1209 | mSurfaceTextures[i]._setMaterial(mSurfaceTextures[i].getMaterial()); |
| 1210 | //If we already have the material inst and it hasn't changed, skip |
| 1211 | if (mSurfaceTextures[i].materialInst && |
| 1212 | mSurfaceTextures[i].getMaterialAsset()->getMaterialDefinitionName() == mSurfaceTextures[i].materialInst->getMaterial()->getName() && |
| 1213 | mSurfaceTextures[i].materialInst->getVertexFormat() == getGFXVertexFormat<VertexType>()) |
| 1214 | continue; |
| 1215 | |
| 1216 | SAFE_DELETE(mSurfaceTextures[i].materialInst); |
| 1217 | |
| 1218 | Material* material = mSurfaceTextures[i].getMaterialResource(); |
| 1219 | |
| 1220 | if (material == nullptr) |
| 1221 | continue; |
| 1222 | |
| 1223 | mSurfaceTextures[i].materialInst = material->createMatInstance(); |
| 1224 | |
| 1225 | FeatureSet features = MATMGR->getDefaultFeatures(); |
| 1226 | |
| 1227 | mSurfaceTextures[i].materialInst->init(features, getGFXVertexFormat<VertexType>()); |
| 1228 | |
| 1229 | if (!mSurfaceTextures[i].materialInst->isValid()) |
| 1230 | { |
| 1231 | SAFE_DELETE(mSurfaceTextures[i].materialInst); |
| 1232 | } |
| 1233 | } |
| 1234 | |
| 1235 | _setMaterial(getMaterial()); |
| 1236 | // If the material name matches then don't bother updating it. |
| 1237 | if (mMaterialInst && getMaterialAsset()->getMaterialDefinitionName() == mMaterialInst->getMaterial()->getName() && |
| 1238 | mMaterialInst->getVertexFormat() == getGFXVertexFormat<VertexType>()) |
| 1239 | return; |
| 1240 | |
| 1241 | SAFE_DELETE( mMaterialInst ); |
| 1242 | |
| 1243 | Material* material = getMaterialResource(); |
| 1244 | |
| 1245 | if (material == nullptr) |
| 1246 | return; |
| 1247 | |
| 1248 | mMaterialInst = material->createMatInstance(); |
| 1249 | |
| 1250 | FeatureSet features = MATMGR->getDefaultFeatures(); |
| 1251 | //features.addFeature( MFT_DiffuseVertColor ); |
| 1252 | |
| 1253 | mMaterialInst->init( features, getGFXVertexFormat<VertexType>() ); |
| 1254 | |
| 1255 | if ( !mMaterialInst->isValid() ) |
| 1256 | { |
| 1257 | SAFE_DELETE( mMaterialInst ); |
| 1258 | } |
| 1259 | } |
| 1260 | |
| 1261 | void ConvexShape::_updateGeometry( bool updateCollision ) |
no test coverage detected