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

Method _initMaterial

Engine/source/environment/meshRoad.cpp:1266–1331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1264}
1265
1266void MeshRoad::_initMaterial()
1267{
1268 if (mTopMaterialAsset.notNull())
1269 {
1270 if (!mMatInst[Top] || !String(mTopMaterialAsset->getMaterialDefinitionName()).equal(mMatInst[Top]->getMaterial()->getName(), String::NoCase))
1271 {
1272 SAFE_DELETE(mMatInst[Top]);
1273
1274 Material* tMat = nullptr;
1275 if (!Sim::findObject(mTopMaterialAsset->getMaterialDefinitionName(), tMat))
1276 Con::errorf("MeshRoad::_initMaterial - Material %s was not found.", mTopMaterialAsset->getMaterialDefinitionName());
1277
1278 mMaterial[Top] = tMat;
1279
1280 if (mMaterial[Top])
1281 mMatInst[Top] = mMaterial[Top]->createMatInstance();
1282 else
1283 mMatInst[Top] = MATMGR->createMatInstance("WarningMaterial");
1284
1285 mMatInst[Top]->init(MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPNTT>());
1286 }
1287 }
1288
1289 if (mBottomMaterialAsset.notNull())
1290 {
1291 if (!mMatInst[Bottom] || !String(mBottomMaterialAsset->getMaterialDefinitionName()).equal(mMatInst[Bottom]->getMaterial()->getName(), String::NoCase))
1292 {
1293
1294 SAFE_DELETE(mMatInst[Bottom]);
1295
1296 Material* tMat = nullptr;
1297 if (!Sim::findObject(mBottomMaterialAsset->getMaterialDefinitionName(), tMat))
1298 Con::errorf("MeshRoad::_initMaterial - Material %s was not found.", mBottomMaterialAsset->getMaterialDefinitionName());
1299
1300 mMaterial[Bottom] = tMat;
1301
1302 if (mMaterial[Bottom])
1303 mMatInst[Bottom] = mMaterial[Bottom]->createMatInstance();
1304 else
1305 mMatInst[Bottom] = MATMGR->createMatInstance("WarningMaterial");
1306
1307 mMatInst[Bottom]->init(MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPNTT>());
1308 }
1309 }
1310
1311 if (mSideMaterialAsset.notNull())
1312 {
1313 if (!mMatInst[Side] || !String(mSideMaterialAsset->getMaterialDefinitionName()).equal(mMatInst[Side]->getMaterial()->getName(), String::NoCase))
1314 {
1315 SAFE_DELETE(mMatInst[Side]);
1316
1317 Material* tMat = nullptr;
1318 if (!Sim::findObject(mSideMaterialAsset->getMaterialDefinitionName(), tMat))
1319 Con::errorf("MeshRoad::_initMaterial - Material %s was not found.", mSideMaterialAsset->getMaterialDefinitionName());
1320
1321 mMaterial[Side] = tMat;
1322
1323 if (mMaterial[Side])

Callers

nothing calls this directly

Calls 10

notNullMethod · 0.80
StringClass · 0.50
findObjectFunction · 0.50
errorfFunction · 0.50
equalMethod · 0.45
getNameMethod · 0.45
getMaterialMethod · 0.45
createMatInstanceMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected