| 220 | } |
| 221 | |
| 222 | bool TSForestItemData::render( TSRenderState *rdata, const ForestItem &item ) const |
| 223 | { |
| 224 | PROFILE_SCOPE( TSForestItemData_render ); |
| 225 | |
| 226 | // This shouldn't happen normally at runtime, but during |
| 227 | // development a file change notification on a bad file |
| 228 | // can cause us to get here without a shape. |
| 229 | TSShapeInstance *shapeInst = _getShapeInstance(); |
| 230 | if ( !shapeInst ) |
| 231 | return false; |
| 232 | |
| 233 | const F32 scale = item.getScale(); |
| 234 | |
| 235 | // Figure out the distance of this item to the camera. |
| 236 | const SceneRenderState *state = rdata->getSceneState(); |
| 237 | F32 dist = ( item.getPosition() - state->getDiffuseCameraPosition() ).len(); |
| 238 | |
| 239 | // TODO: Selecting the lod seems more expensive than |
| 240 | // it should be... we should look to optimize this. |
| 241 | if ( shapeInst->setDetailFromDistance( state, dist / scale ) < 0 ) |
| 242 | return false; |
| 243 | |
| 244 | // TSShapeInstance::render() uses the |
| 245 | // world matrix for the RenderInst. |
| 246 | MatrixF worldMat = item.getTransform(); |
| 247 | worldMat.scale( scale ); |
| 248 | GFX->setWorldMatrix( worldMat ); |
| 249 | rdata->setMaterialHint( (void*)&item ); |
| 250 | |
| 251 | // This isn't documented well, but these calls |
| 252 | // don't really render... rather they batch the |
| 253 | // shape to be rendered by the render instance |
| 254 | // manager later on. |
| 255 | shapeInst->animate(); |
| 256 | shapeInst->render( *rdata ); |
| 257 | return true; |
| 258 | } |
nothing calls this directly
no test coverage detected