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

Method initMaterial

Engine/source/environment/waterObject.cpp:1128–1170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126}
1127
1128bool WaterObject::initMaterial( S32 idx )
1129{
1130 // We must return false for any case which it is NOT safe for the caller
1131 // to use the indexed material.
1132
1133 if ( idx < 0 || idx >= NumMatTypes )
1134 return false;
1135
1136 BaseMatInstance *mat = mMatInstances[idx];
1137 WaterMatParams &matParams = mMatParamHandles[idx];
1138
1139 // Is it already initialized?
1140
1141 if ( mat && mat->isValid() )
1142 return true;
1143
1144 // Do we need to allocate anything?
1145
1146 if ( mSurfMatName[idx].isNotEmpty() )
1147 {
1148 if ( mat )
1149 SAFE_DELETE( mat );
1150
1151 CustomMaterial *custMat;
1152 if ( Sim::findObject( mSurfMatName[idx], custMat ) && custMat->mShaderData )
1153 mat = custMat->createMatInstance();
1154 else
1155 mat = MATMGR->createMatInstance( mSurfMatName[idx] );
1156
1157 const GFXVertexFormat *flags = getGFXVertexFormat<GFXVertexPCT>();
1158
1159 if ( mat && mat->init( MATMGR->getDefaultFeatures(), flags ) )
1160 {
1161 mMatInstances[idx] = mat;
1162 matParams.init( mat );
1163 return true;
1164 }
1165
1166 SAFE_DELETE( mat );
1167 }
1168
1169 return false;
1170}
1171
1172void WaterObject::initTextures()
1173{

Callers

nothing calls this directly

Calls 5

findObjectFunction · 0.50
isValidMethod · 0.45
isNotEmptyMethod · 0.45
createMatInstanceMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected