| 1113 | } |
| 1114 | |
| 1115 | bool WaterObject::initMaterial( S32 idx ) |
| 1116 | { |
| 1117 | // We must return false for any case which it is NOT safe for the caller |
| 1118 | // to use the indexed material. |
| 1119 | |
| 1120 | if ( idx < 0 || idx > NumMatTypes ) |
| 1121 | return false; |
| 1122 | |
| 1123 | BaseMatInstance *mat = mMatInstances[idx]; |
| 1124 | WaterMatParams &matParams = mMatParamHandles[idx]; |
| 1125 | |
| 1126 | // Is it already initialized? |
| 1127 | |
| 1128 | if ( mat && mat->isValid() ) |
| 1129 | return true; |
| 1130 | |
| 1131 | // Do we need to allocate anything? |
| 1132 | |
| 1133 | if ( mSurfMatName[idx].isNotEmpty() ) |
| 1134 | { |
| 1135 | if ( mat ) |
| 1136 | SAFE_DELETE( mat ); |
| 1137 | |
| 1138 | CustomMaterial *custMat; |
| 1139 | if ( Sim::findObject( mSurfMatName[idx], custMat ) && custMat->mShaderData ) |
| 1140 | mat = custMat->createMatInstance(); |
| 1141 | else |
| 1142 | mat = MATMGR->createMatInstance( mSurfMatName[idx] ); |
| 1143 | |
| 1144 | const GFXVertexFormat *flags = getGFXVertexFormat<GFXVertexPCT>(); |
| 1145 | |
| 1146 | if ( mat && mat->init( MATMGR->getDefaultFeatures(), flags ) ) |
| 1147 | { |
| 1148 | mMatInstances[idx] = mat; |
| 1149 | matParams.init( mat ); |
| 1150 | return true; |
| 1151 | } |
| 1152 | |
| 1153 | SAFE_DELETE( mat ); |
| 1154 | } |
| 1155 | |
| 1156 | return false; |
| 1157 | } |
| 1158 | |
| 1159 | void WaterObject::initTextures() |
| 1160 | { |
nothing calls this directly
no test coverage detected