| 221 | } |
| 222 | |
| 223 | void RenderDeferredMgr::addElement( RenderInst *inst ) |
| 224 | { |
| 225 | PROFILE_SCOPE( RenderDeferredMgr_addElement ) |
| 226 | |
| 227 | // Skip out if this bin is disabled. |
| 228 | if ( gClientSceneGraph->getCurrentRenderState() && |
| 229 | gClientSceneGraph->getCurrentRenderState()->disableAdvancedLightingBins() ) |
| 230 | return; |
| 231 | |
| 232 | // First what type of render instance is it? |
| 233 | const bool isDecalMeshInst = ((inst->type == RenderPassManager::RIT_Decal)||(inst->type == RenderPassManager::RIT_DecalRoad)); |
| 234 | |
| 235 | const bool isMeshInst = inst->type == RenderPassManager::RIT_Mesh; |
| 236 | |
| 237 | const bool isTerrainInst = inst->type == RenderPassManager::RIT_Terrain; |
| 238 | |
| 239 | const bool isProbeInst = inst->type == RenderPassManager::RIT_Probes; |
| 240 | |
| 241 | // Get the material if its a mesh. |
| 242 | BaseMatInstance* matInst = NULL; |
| 243 | if ( isMeshInst || isDecalMeshInst ) |
| 244 | matInst = static_cast<MeshRenderInst*>(inst)->matInst; |
| 245 | |
| 246 | if (matInst) |
| 247 | { |
| 248 | // If its a custom material and it refracts... skip it. |
| 249 | if (matInst->isCustomMaterial() && |
| 250 | static_cast<CustomMaterial*>(matInst->getMaterial())->mRefract) |
| 251 | return; |
| 252 | |
| 253 | // Make sure we got a deferred material. |
| 254 | matInst = getDeferredMaterial(matInst); |
| 255 | if (!matInst || !matInst->isValid()) |
| 256 | return; |
| 257 | } |
| 258 | |
| 259 | // We're gonna add it to the bin... get the right element list. |
| 260 | Vector< MainSortElem > *elementList; |
| 261 | if ( isMeshInst || isDecalMeshInst ) |
| 262 | elementList = &mElementList; |
| 263 | else if ( isTerrainInst ) |
| 264 | elementList = &mTerrainElementList; |
| 265 | else if (isProbeInst) |
| 266 | elementList = &mProbeElementList; |
| 267 | else |
| 268 | elementList = &mObjectElementList; |
| 269 | |
| 270 | elementList->increment(); |
| 271 | MainSortElem &elem = elementList->last(); |
| 272 | elem.inst = inst; |
| 273 | |
| 274 | // Store the original key... we might need it. |
| 275 | U32 originalKey = elem.key; |
| 276 | |
| 277 | // Sort front-to-back first to get the most fillrate savings. |
| 278 | const F32 invSortDistSq = F32_MAX - inst->sortDistSq; |
| 279 | elem.key = *((U32*)&invSortDistSq); |
| 280 |
nothing calls this directly
no test coverage detected