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

Method render

Engine/source/forest/ts/tsForestItemData.cpp:222–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222bool 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}

Callers

nothing calls this directly

Calls 11

getSceneStateMethod · 0.80
setDetailFromDistanceMethod · 0.80
setMaterialHintMethod · 0.80
getScaleMethod · 0.45
lenMethod · 0.45
getPositionMethod · 0.45
getTransformMethod · 0.45
scaleMethod · 0.45
setWorldMatrixMethod · 0.45
animateMethod · 0.45

Tested by

no test coverage detected