mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
Add handling to RotationF's addRotation function to ensure formatted return
This commit is contained in:
parent
8256aca65e
commit
c5d5a91356
2 changed files with 19 additions and 4 deletions
|
|
@ -325,14 +325,21 @@ TEST(Maths, RotationF_Calculations)
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DefineEngineFunction(AddRotation, RotationF, (RotationF a, RotationF b), ,
|
DefineEngineFunction(AddRotation, RotationF, (RotationF a, RotationF b, const char* returnType), ("Euler"),
|
||||||
"Adds two rotations together.\n"
|
"Adds two rotations together.\n"
|
||||||
"@param a Rotation one."
|
"@param a Rotation one."
|
||||||
"@param b Rotation two."
|
"@param b Rotation two."
|
||||||
"@returns v sum of both rotations."
|
"@returns v sum of both rotations."
|
||||||
"@ingroup Math")
|
"@ingroup Math")
|
||||||
{
|
{
|
||||||
return a + b;
|
RotationF ret;
|
||||||
|
RotationF sum = a + b;
|
||||||
|
if (String(returnType) == String("Euler"))
|
||||||
|
ret.set(sum.asEulerF());
|
||||||
|
else
|
||||||
|
ret.set(sum.asAxisAngle());
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineFunction(SubtractRotation, RotationF, (RotationF a, RotationF b), ,
|
DefineEngineFunction(SubtractRotation, RotationF, (RotationF a, RotationF b), ,
|
||||||
|
|
|
||||||
|
|
@ -620,8 +620,16 @@ ConsoleGetType(TypeRotationF)
|
||||||
static const U32 bufSize = 256;
|
static const U32 bufSize = 256;
|
||||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||||
|
|
||||||
EulerF out = pt->asEulerF(RotationF::Degrees);
|
if (pt->mRotationType == RotationF::Euler)
|
||||||
dSprintf(returnBuffer, bufSize, "%g %g %g", out.x, out.y, out.z);
|
{
|
||||||
|
EulerF out = pt->asEulerF(RotationF::Degrees);
|
||||||
|
dSprintf(returnBuffer, bufSize, "%g %g %g", out.x, out.y, out.z);
|
||||||
|
}
|
||||||
|
else if (pt->mRotationType == RotationF::AxisAngle)
|
||||||
|
{
|
||||||
|
AngAxisF out = pt->asAxisAngle(RotationF::Degrees);
|
||||||
|
dSprintf(returnBuffer, bufSize, "%g %g %g %g", out.axis.x, out.axis.y, out.axis.z, out.angle);
|
||||||
|
}
|
||||||
|
|
||||||
return returnBuffer;
|
return returnBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue