mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 21:10:32 +00:00
Replaced a ton of ConsoleMethods with the DefineConsoleMethod Macro.
This commit is contained in:
parent
378a933894
commit
acb192e2a5
133 changed files with 1716 additions and 2087 deletions
|
|
@ -94,14 +94,22 @@ DefineConsoleFunction( mFloor, S32, ( F32 v ),,
|
|||
return (S32)mFloor( v );
|
||||
}
|
||||
|
||||
DefineConsoleFunction( mRound, S32, ( F32 v ),,
|
||||
"Round v to the nearest integer.\n"
|
||||
"@param v Number to convert to integer."
|
||||
"@returns Number converted to integer."
|
||||
"@ingroup Math" )
|
||||
{
|
||||
return (S32)mFloor( v + 0.5f );
|
||||
}
|
||||
DefineConsoleFunction( mRound, F32, ( F32 v, S32 n ), (0),
|
||||
"Round v to the nth decimal place or the nearest whole number by default."
|
||||
"@param v Value to roundn"
|
||||
"@param n Number of decimal places to round to, 0 by defaultn"
|
||||
"@return The rounded value as a S32."
|
||||
"@ingroup Math" )
|
||||
{
|
||||
if(n <= 0)
|
||||
{
|
||||
return mRound(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mRound(v, n);
|
||||
}
|
||||
}
|
||||
|
||||
DefineConsoleFunction( mCeil, S32, ( F32 v ),,
|
||||
"Round v up to the nearest integer.\n"
|
||||
|
|
@ -119,8 +127,9 @@ DefineConsoleFunction( mFloatLength, const char*, ( F32 v, U32 precision ),,
|
|||
"@returns Number formatted to the specified number of decimal places."
|
||||
"@ingroup Math" )
|
||||
{
|
||||
char fmtString[8] = "%.0f";
|
||||
if (precision > 9)
|
||||
char fmtString[8] = "%.9f";
|
||||
|
||||
if (precision >= 9)
|
||||
precision = 9;
|
||||
fmtString[2] = '0' + precision;
|
||||
|
||||
|
|
|
|||
|
|
@ -200,6 +200,18 @@ inline F32 mFmod(const F32 val, const F32 mod)
|
|||
return fmod(val, mod);
|
||||
}
|
||||
|
||||
inline S32 mRound(const F32 val)
|
||||
{
|
||||
return (S32)floor(val + 0.5f);
|
||||
}
|
||||
|
||||
inline F32 mRound(const F32 val, const S32 n)
|
||||
{
|
||||
S32 place = (S32) pow(10.0f, n);
|
||||
|
||||
return mFloor((val*place)+0.5)/place;
|
||||
}
|
||||
|
||||
inline S32 mAbs(const S32 val)
|
||||
{
|
||||
return abs(val);
|
||||
|
|
|
|||
|
|
@ -831,6 +831,26 @@ DefineConsoleFunction( VectorOrthoBasis, MatrixF, ( AngAxisF aa ),,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//ConsoleFunction(VectorRot, const char*, 3, 3, "(Vector3F, float) rotate a vector in 2d")
|
||||
DefineConsoleFunction( VectorRot, const char*, (Point3F v, F32 angle), , "(Vector3F, float) rotate a vector in 2d")
|
||||
{
|
||||
//VectorF v(0,0,0);
|
||||
//dSscanf(argv[1],"%g %g %g",&v.x,&v.y,&v.z);
|
||||
//dSscanf(axeStr,"%g %g %g",&v.x,&v.y,&v.z);
|
||||
|
||||
//float angle = dAtof(argv[2]);
|
||||
//float angle = dAtof(angleStr);
|
||||
|
||||
float x = 0, y = 0;
|
||||
|
||||
x = v.x * cos(angle) - v.y * sin(angle);
|
||||
y = v.x * sin(angle) + v.y * cos(angle);
|
||||
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
dSprintf(returnBuffer,256,"%g %g %g", x, y, v.z);
|
||||
return returnBuffer;
|
||||
}
|
||||
|
||||
DefineConsoleFunction( VectorLerp, VectorF, ( VectorF a, VectorF b, F32 t ),,
|
||||
"Linearly interpolate between two vectors by @a t.\n"
|
||||
"@param a Vector to start interpolation from.\n"
|
||||
|
|
@ -999,7 +1019,7 @@ F32 mRandF()
|
|||
return gRandGen.randF();
|
||||
}
|
||||
|
||||
ConsoleFunction( getRandom, F32, 1, 3,
|
||||
DefineConsoleFunction( getRandom, F32, (S32 a, S32 b), (1, 0),
|
||||
"( int a, int b ) "
|
||||
"@brief Returns a random number based on parameters passed in..\n\n"
|
||||
"If no parameters are passed in, getRandom() will return a float between 0.0 and 1.0. If one "
|
||||
|
|
@ -1013,14 +1033,14 @@ ConsoleFunction( getRandom, F32, 1, 3,
|
|||
"@see setRandomSeed\n"
|
||||
"@ingroup Random" )
|
||||
{
|
||||
if (argc == 2)
|
||||
return F32(gRandGen.randI(0,getMax( dAtoi(argv[1]), 0 )));
|
||||
if (b == 0)
|
||||
return F32(gRandGen.randI(0,getMax( a, 0 )));
|
||||
else
|
||||
{
|
||||
if (argc == 3)
|
||||
if (b != 0)
|
||||
{
|
||||
S32 min = dAtoi(argv[1]);
|
||||
S32 max = dAtoi(argv[2]);
|
||||
S32 min = a;
|
||||
S32 max = b;
|
||||
if (min > max)
|
||||
{
|
||||
S32 t = min;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "tResponseCurve.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT( SimResponseCurve );
|
||||
|
||||
|
|
@ -63,17 +64,17 @@ void SimResponseCurve::clear()
|
|||
mCurve.clear();
|
||||
}
|
||||
|
||||
ConsoleMethod( SimResponseCurve, addPoint, void, 4, 4, "addPoint( F32 value, F32 time )" )
|
||||
DefineConsoleMethod( SimResponseCurve, addPoint, void, ( F32 value, F32 time ), , "addPoint( F32 value, F32 time )" )
|
||||
{
|
||||
object->addPoint( dAtof(argv[2]), dAtof(argv[3]) );
|
||||
object->addPoint( value, time );
|
||||
}
|
||||
|
||||
ConsoleMethod( SimResponseCurve, getValue, F32, 3, 3, "getValue( F32 time )" )
|
||||
DefineConsoleMethod( SimResponseCurve, getValue, F32, ( F32 time ), , "getValue( F32 time )" )
|
||||
{
|
||||
return object->getValue( dAtof(argv[2]) );
|
||||
return object->getValue( time );
|
||||
}
|
||||
|
||||
ConsoleMethod( SimResponseCurve, clear, void, 2, 2, "clear()" )
|
||||
DefineConsoleMethod( SimResponseCurve, clear, void, (), , "clear()" )
|
||||
{
|
||||
object->clear();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue