mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #321 from DavidWyand-GG/ExtendedMoveChanges
ExtendedMove changes
This commit is contained in:
commit
b1feed56fd
|
|
@ -18,6 +18,7 @@ MODULE_END;
|
|||
S32 ExtendedMoveManager::mPosX[ExtendedMove::MaxPositionsRotations] = { 0, };
|
||||
S32 ExtendedMoveManager::mPosY[ExtendedMove::MaxPositionsRotations] = { 0, };
|
||||
S32 ExtendedMoveManager::mPosZ[ExtendedMove::MaxPositionsRotations] = { 0, };
|
||||
bool ExtendedMoveManager::mRotIsEuler[ExtendedMove::MaxPositionsRotations] = { 0, };
|
||||
F32 ExtendedMoveManager::mRotAX[ExtendedMove::MaxPositionsRotations] = { 0, };
|
||||
F32 ExtendedMoveManager::mRotAY[ExtendedMove::MaxPositionsRotations] = { 0, };
|
||||
F32 ExtendedMoveManager::mRotAZ[ExtendedMove::MaxPositionsRotations] = { 0, };
|
||||
|
|
@ -44,6 +45,15 @@ void ExtendedMoveManager::init()
|
|||
"Z position of controller in millimeters. Only 13 bits are networked.\n"
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvRotIsEuler%d", i);
|
||||
Con::addVariable(varName, TypeBool, &mRotIsEuler[i],
|
||||
"@brief Indicates that the given rotation is Euler angles.\n\n"
|
||||
"When false (the default) the given rotation is a four component angled axis "
|
||||
"(a vector and angle). When true, the given rotation is a three component "
|
||||
"Euler angle. When using Euler angles, the $mvRotA component of the ExtendedMove "
|
||||
"is ignored for this set of rotations.\n"
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvRotX%d", i);
|
||||
Con::addVariable(varName, TypeF32, &mRotAX[i],
|
||||
"X rotation vector component of controller.\n"
|
||||
|
|
@ -83,6 +93,8 @@ ExtendedMove::ExtendedMove() : Move()
|
|||
rotY[i] = 0;
|
||||
rotZ[i] = 0;
|
||||
rotW[i] = 1;
|
||||
|
||||
EulerBasedRotation[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,8 +118,11 @@ void ExtendedMove::pack(BitStream *stream, const Move * basemove)
|
|||
(posZ[i] != extBaseMove->posZ[i]) ||
|
||||
(rotX[i] != extBaseMove->rotX[i]) ||
|
||||
(rotY[i] != extBaseMove->rotY[i]) ||
|
||||
(rotZ[i] != extBaseMove->rotZ[i]) ||
|
||||
(rotW[i] != extBaseMove->rotW[i]);
|
||||
(rotZ[i] != extBaseMove->rotZ[i]);
|
||||
if(!EulerBasedRotation[i])
|
||||
{
|
||||
check = check || (rotW[i] != extBaseMove->rotW[i]);
|
||||
}
|
||||
|
||||
extendedDifferent = extendedDifferent || check;
|
||||
}
|
||||
|
|
@ -125,14 +140,18 @@ void ExtendedMove::pack(BitStream *stream, const Move * basemove)
|
|||
stream->writeSignedInt(posZ[i], MaxPositionBits);
|
||||
|
||||
// Rotation
|
||||
stream->writeFlag(EulerBasedRotation[i]);
|
||||
if(stream->writeFlag(rotX[i] != extBaseMove->rotX[i]))
|
||||
stream->writeInt(crotX[i], MaxRotationBits);
|
||||
if(stream->writeFlag(rotY[i] != extBaseMove->rotY[i]))
|
||||
stream->writeInt(crotY[i], MaxRotationBits);
|
||||
if(stream->writeFlag(rotZ[i] != extBaseMove->rotZ[i]))
|
||||
stream->writeInt(crotZ[i], MaxRotationBits);
|
||||
if(stream->writeFlag(rotW[i] != extBaseMove->rotW[i]))
|
||||
stream->writeInt(crotW[i], MaxRotationBits);
|
||||
if(!EulerBasedRotation[i])
|
||||
{
|
||||
if(stream->writeFlag(rotW[i] != extBaseMove->rotW[i]))
|
||||
stream->writeInt(crotW[i], MaxRotationBits);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -172,10 +191,14 @@ void ExtendedMove::unpack(BitStream *stream, const Move * basemove)
|
|||
posZ[i] = extBaseMove->posZ[i];
|
||||
|
||||
// Rotation
|
||||
EulerBasedRotation[i] = stream->readFlag();
|
||||
F32 scale = 1.0f;
|
||||
if(EulerBasedRotation[i])
|
||||
scale = M_2PI_F;
|
||||
if(stream->readFlag())
|
||||
{
|
||||
crotX[i] = stream->readInt(MaxRotationBits);
|
||||
rotX[i] = UNCLAMPROT(crotX[i]);
|
||||
rotX[i] = UNCLAMPROT(crotX[i]) * scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -185,7 +208,7 @@ void ExtendedMove::unpack(BitStream *stream, const Move * basemove)
|
|||
if(stream->readFlag())
|
||||
{
|
||||
crotY[i] = stream->readInt(MaxRotationBits);
|
||||
rotY[i] = UNCLAMPROT(crotY[i]);
|
||||
rotY[i] = UNCLAMPROT(crotY[i]) * scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -195,21 +218,24 @@ void ExtendedMove::unpack(BitStream *stream, const Move * basemove)
|
|||
if(stream->readFlag())
|
||||
{
|
||||
crotZ[i] = stream->readInt(MaxRotationBits);
|
||||
rotZ[i] = UNCLAMPROT(crotZ[i]);
|
||||
rotZ[i] = UNCLAMPROT(crotZ[i]) * scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotZ[i] = extBaseMove->rotZ[i];
|
||||
}
|
||||
|
||||
if(stream->readFlag())
|
||||
if(!EulerBasedRotation[i])
|
||||
{
|
||||
crotW[i] = stream->readInt(MaxRotationBits);
|
||||
rotW[i] = UNCLAMPROT(crotW[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
rotW[i] = extBaseMove->rotW[i];
|
||||
if(stream->readFlag())
|
||||
{
|
||||
crotW[i] = stream->readInt(MaxRotationBits);
|
||||
rotW[i] = UNCLAMPROT(crotW[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
rotW[i] = extBaseMove->rotW[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -231,10 +257,19 @@ void ExtendedMove::clamp()
|
|||
posZ[i] = CLAMPPOS(posZ[i]);
|
||||
|
||||
// Rotations
|
||||
crotX[i] = CLAMPROT(rotX[i]);
|
||||
crotY[i] = CLAMPROT(rotY[i]);
|
||||
crotZ[i] = CLAMPROT(rotZ[i]);
|
||||
crotW[i] = CLAMPROT(rotW[i]);
|
||||
if(EulerBasedRotation[i])
|
||||
{
|
||||
crotX[i] = CLAMPROT(rotX[i] / M_2PI_F);
|
||||
crotY[i] = CLAMPROT(rotY[i] / M_2PI_F);
|
||||
crotZ[i] = CLAMPROT(rotZ[i] / M_2PI_F);
|
||||
}
|
||||
else
|
||||
{
|
||||
crotX[i] = CLAMPROT(rotX[i]);
|
||||
crotY[i] = CLAMPROT(rotY[i]);
|
||||
crotZ[i] = CLAMPROT(rotZ[i]);
|
||||
crotW[i] = CLAMPROT(rotW[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform the standard Move clamp
|
||||
|
|
@ -247,10 +282,19 @@ void ExtendedMove::unclamp()
|
|||
for(U32 i=0; i<MaxPositionsRotations; ++i)
|
||||
{
|
||||
// Rotations
|
||||
rotX[i] = UNCLAMPROT(crotX[i]);
|
||||
rotY[i] = UNCLAMPROT(crotY[i]);
|
||||
rotZ[i] = UNCLAMPROT(crotZ[i]);
|
||||
rotW[i] = UNCLAMPROT(crotW[i]);
|
||||
if(EulerBasedRotation[i])
|
||||
{
|
||||
rotX[i] = UNCLAMPROT(crotX[i]) * M_2PI_F;
|
||||
rotY[i] = UNCLAMPROT(crotY[i]) * M_2PI_F;
|
||||
rotZ[i] = UNCLAMPROT(crotZ[i]) * M_2PI_F;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotX[i] = UNCLAMPROT(crotX[i]);
|
||||
rotY[i] = UNCLAMPROT(crotY[i]);
|
||||
rotZ[i] = UNCLAMPROT(crotZ[i]);
|
||||
rotW[i] = UNCLAMPROT(crotW[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform the standard Move unclamp
|
||||
|
|
|
|||
|
|
@ -9,15 +9,17 @@ struct ExtendedMove : public Move
|
|||
typedef Move Parent;
|
||||
|
||||
enum Constants {
|
||||
MaxPositionsRotations = 2,
|
||||
MaxPositionsRotations = 3,
|
||||
|
||||
MaxPositionBits = 13,
|
||||
MaxRotationBits = 11,
|
||||
MaxRotationBits = 16,
|
||||
};
|
||||
|
||||
// Position is in millimeters
|
||||
S32 posX[MaxPositionsRotations], posY[MaxPositionsRotations], posZ[MaxPositionsRotations];
|
||||
|
||||
bool EulerBasedRotation[MaxPositionsRotations];
|
||||
|
||||
F32 rotX[MaxPositionsRotations], rotY[MaxPositionsRotations], rotZ[MaxPositionsRotations], rotW[MaxPositionsRotations];
|
||||
|
||||
// Network clamped rotation
|
||||
|
|
@ -40,6 +42,7 @@ public:
|
|||
static S32 mPosX[ExtendedMove::MaxPositionsRotations];
|
||||
static S32 mPosY[ExtendedMove::MaxPositionsRotations];
|
||||
static S32 mPosZ[ExtendedMove::MaxPositionsRotations];
|
||||
static bool mRotIsEuler[ExtendedMove::MaxPositionsRotations];
|
||||
static F32 mRotAX[ExtendedMove::MaxPositionsRotations];
|
||||
static F32 mRotAY[ExtendedMove::MaxPositionsRotations];
|
||||
static F32 mRotAZ[ExtendedMove::MaxPositionsRotations];
|
||||
|
|
|
|||
|
|
@ -63,13 +63,24 @@ bool ExtendedMoveList::getNextExtMove( ExtendedMove &curMove )
|
|||
curMove.posY[i] = ExtendedMoveManager::mPosY[i];
|
||||
curMove.posZ[i] = ExtendedMoveManager::mPosZ[i];
|
||||
|
||||
// Process rotation. Rotation is passed in as an Angle Axis in degrees.
|
||||
// We need to convert this into a Quat.
|
||||
QuatF q(Point3F(ExtendedMoveManager::mRotAX[i], ExtendedMoveManager::mRotAY[i], ExtendedMoveManager::mRotAZ[i]), mDegToRad(ExtendedMoveManager::mRotAA[i]));
|
||||
curMove.rotX[i] = q.x;
|
||||
curMove.rotY[i] = q.y;
|
||||
curMove.rotZ[i] = q.z;
|
||||
curMove.rotW[i] = q.w;
|
||||
// Process rotation. There are two possible forms of rotation: Angle Axis and Euler angles.
|
||||
curMove.EulerBasedRotation[i] = ExtendedMoveManager::mRotIsEuler[i];
|
||||
if(curMove.EulerBasedRotation[i])
|
||||
{
|
||||
// Euler angle based rotation passed in as degrees. We only need to work with three components.
|
||||
curMove.rotX[i] = mDegToRad(ExtendedMoveManager::mRotAX[i]);
|
||||
curMove.rotY[i] = mDegToRad(ExtendedMoveManager::mRotAY[i]);
|
||||
curMove.rotZ[i] = mDegToRad(ExtendedMoveManager::mRotAZ[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Rotation is passed in as an Angle Axis in degrees. We need to convert this into a Quat.
|
||||
QuatF q(Point3F(ExtendedMoveManager::mRotAX[i], ExtendedMoveManager::mRotAY[i], ExtendedMoveManager::mRotAZ[i]), mDegToRad(ExtendedMoveManager::mRotAA[i]));
|
||||
curMove.rotX[i] = q.x;
|
||||
curMove.rotY[i] = q.y;
|
||||
curMove.rotZ[i] = q.z;
|
||||
curMove.rotW[i] = q.w;
|
||||
}
|
||||
}
|
||||
|
||||
if (mConnection->getControlObject())
|
||||
|
|
|
|||
Loading…
Reference in a new issue