MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / fitToShape

Method fitToShape

Engine/source/gui/editor/guiShapeEdPreview.cpp:810–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808}
809
810void GuiShapeEdPreview::fitToShape()
811{
812 if ( !mModel )
813 return;
814
815 // Determine the shape bounding box given the current camera rotation
816 MatrixF camRotMatrix( smCamMatrix );
817 camRotMatrix.setPosition( Point3F::Zero );
818 camRotMatrix.inverse();
819
820 Box3F bounds;
821 computeSceneBounds( bounds );
822 mOrbitPos = bounds.getCenter();
823
824 camRotMatrix.mul( bounds );
825
826 // Estimate the camera distance to fill the view by comparing the radii
827 // of the box and the viewport
828 F32 len_x = bounds.len_x();
829 F32 len_z = bounds.len_z();
830 F32 shapeRadius = mSqrt( len_x*len_x + len_z*len_z ) / 2;
831 F32 viewRadius = 0.45f * getMin( getExtent().x, getExtent().y );
832
833 // Set camera parameters
834 if ( mDisplayType == DisplayTypePerspective )
835 {
836 mOrbitDist = ( shapeRadius / viewRadius ) * mSaveWorldToScreenScale.y;
837 }
838 else
839 {
840 mOrthoCamTrans.set( 0, 0, 0 );
841 mOrthoFOV = shapeRadius * viewRadius / 320;
842 }
843}
844
845void GuiShapeEdPreview::setOrbitPos( const Point3F& pos )
846{

Callers 5

main.csFile · 0.80
ShapeEditorFunction · 0.80
main.csFile · 0.80
ShapeEditorFunction · 0.80

Calls 8

mSqrtFunction · 0.85
setPositionMethod · 0.45
inverseMethod · 0.45
getCenterMethod · 0.45
mulMethod · 0.45
len_xMethod · 0.45
len_zMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected