MCPcopy Create free account
hub / github.com/carbonengine/trinity / SetLOD

Method SetLOD

trinity/Tr2SkinnedObject.cpp:775–806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

773}
774
775void Tr2SkinnedObject::SetLOD( const TriFrustum* frustum )
776{
777 if( !frustum )
778 {
779 return;
780 }
781
782 Vector4 boundingSphere;
783 if( GetBoundingSphere( boundingSphere ) && frustum->IsSphereVisible( &boundingSphere, true ) )
784 {
785 const float estimate = frustum->GetPixelSizeAccross( &boundingSphere );
786 if( estimate >= 0.0f && estimate < 1000000.0f ) // block off any remaining silliness
787 {
788 m_estimatedPixelDiameter = estimate;
789 }
790 }
791
792 Tr2SkinnedModel* model = m_lod.SetLOD( frustum, m_estimatedPixelDiameter );
793
794 // lod change?
795 if( model && model != m_visualModel ) // don't just compare lod numbers, actual model of a given lod might change as well (dynamic builders)
796 {
797 m_visualModel = model;
798
799 // this invalidates the rig-bindings, cause we switched to a new skeleton and therefore have to rebuild
800 m_skinningMatrixCount = 0;
801
802 // the skeleton is only posed during Update; make sure we don't render a frame with a model in the
803 // restpose, by posing it right now.
804 UpdateBones( m_lastUpdateTime, NULL );
805 }
806}
807
808AxisAlignedBoundingBox Tr2SkinnedObject::GetBoundingBoxInLocalSpace() const
809{

Callers

nothing calls this directly

Calls 3

GetBoundingSphereFunction · 0.85
IsSphereVisibleMethod · 0.80
GetPixelSizeAccrossMethod · 0.80

Tested by

no test coverage detected