MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / ProjectToUnitSquare

Function ProjectToUnitSquare

Source/SysPSP/Input/InputManagerPSP.cpp:975–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

973//
974//*************************************************************************************
975v2 ProjectToUnitSquare( const v2 & in )
976{
977 f32 length( in.Length() );
978 float abs_x( fabsf( in.x ) );
979 float abs_y( fabsf( in.y ) );
980 float scale;
981
982 //
983 // Select the longest axis, and
984 //
985 if( length < 0.01f )
986 {
987 scale = 1.0f;
988 }
989 else if( abs_x > abs_y )
990 {
991 scale = length / abs_x;
992 }
993 else
994 {
995 scale = length / abs_y;
996 }
997
998 return in * scale;
999}
1000
1001//*************************************************************************************
1002//

Callers 1

ApplyDeadzoneFunction · 0.85

Calls 1

LengthMethod · 0.45

Tested by

no test coverage detected