void SVGOptionsScreen::GetScale( int write_set ) { bool foundgeom = false; Vehicle *veh = VehicleMgr.GetVehicle(); vector< Geom* > geom_vec = veh->FindGeomVec( veh->GetGeomVec( false ) ); BndBox svgbox; for ( int i = 0 ; i < ( int )geom_vec.size() ; i++ ) { if ( geom_vec[i]->GetSetFlag( write_set ) ) { svgbox.Update( geom_vec[i]->GetBndBox() ); foundgeom = true; } } if ( !foundgeom ) { veh->m_Scale.Set( 0 ); // Set to 0 if no geoms are in the set return; } double length = svgbox.DiagDist(); double convert_scale; if ( length >= 1.0 ) { convert_scale = floor2scale( length, pow( 10.0, mag( length ) ) ); } else { convert_scale = floor2scale( length, pow( 10.0, mag( length ) - 1 ) ); } veh->m_Scale.Set( convert_scale ); }
double magrounddn( double x ) { return MIN( 0.0, floor2scale( x, pow( 10.0, mag( x ) ) ) ); }