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

Method fitToShape

Engine/source/gui/editor/guiShapeEdPreview.cpp:868–901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

866}
867
868void GuiShapeEdPreview::fitToShape()
869{
870 if ( !mModel )
871 return;
872
873 // Determine the shape bounding box given the current camera rotation
874 MatrixF camRotMatrix( smCamMatrix );
875 camRotMatrix.setPosition( Point3F::Zero );
876 camRotMatrix.inverse();
877
878 Box3F bounds;
879 computeSceneBounds( bounds );
880 mOrbitPos = bounds.getCenter();
881
882 camRotMatrix.mul( bounds );
883
884 // Estimate the camera distance to fill the view by comparing the radii
885 // of the box and the viewport
886 F32 len_x = bounds.len_x();
887 F32 len_z = bounds.len_z();
888 F32 shapeRadius = mSqrt( len_x*len_x + len_z*len_z ) / 2;
889 F32 viewRadius = 0.45f * getMin( getExtent().x, getExtent().y );
890
891 // Set camera parameters
892 if ( mDisplayType == DisplayTypePerspective )
893 {
894 mOrbitDist = ( shapeRadius / viewRadius ) * mSaveWorldToScreenScale.y;
895 }
896 else
897 {
898 mOrthoCamTrans.set( 0, 0, 0 );
899 mOrthoFOV = shapeRadius * viewRadius / 320;
900 }
901}
902
903void GuiShapeEdPreview::setOrbitPos( const Point3F& pos )
904{

Callers 1

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