MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _updateMaterial

Method _updateMaterial

Engine/source/T3D/convexShape.cpp:1204–1259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1202}
1203
1204void 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
1261void ConvexShape::_updateGeometry( bool updateCollision )

Callers 1

setVisibleMethod · 0.45

Calls 10

_setMaterialMethod · 0.80
getMaterialAssetMethod · 0.80
sizeMethod · 0.45
getMaterialMethod · 0.45
getNameMethod · 0.45
getVertexFormatMethod · 0.45
createMatInstanceMethod · 0.45
initMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected