1.8 Severe miscalculations with rotations
by Kirk Longendyke · in Torque Game Engine Advanced · 11/21/2008 (7:00 pm) · 6 replies
Reproduction steps:
1- create a flying vehicle.
2- kill gravity and auto-leveling to remove those variables from the observation-equasion
3- watch as left becomes right, up becomes up and left, and down becomes down and right and after a while it almost seems to go into a floating gimbol-lock...
Already reviewed flyingvehicle, vehicle, and rigid, and the only difference that has anything to do with positional calcualations is the include change from mPoint.h to mPoint3.h wich are two completely seperate files...
1- create a flying vehicle.
2- kill gravity and auto-leveling to remove those variables from the observation-equasion
3- watch as left becomes right, up becomes up and left, and down becomes down and right and after a while it almost seems to go into a floating gimbol-lock...
Already reviewed flyingvehicle, vehicle, and rigid, and the only difference that has anything to do with positional calcualations is the include change from mPoint.h to mPoint3.h wich are two completely seperate files...
#2
QuatF & QuatF::set( const MatrixF & mat )
Having been flipped around was the culprit in fixing one of my personal gui elements that used that to point a camera at a targeted object, and did note a few similar changes in the getangles functions.
Can also confirm from an overhaul of fxShapeReplicator to set the spawned instances to floating relative rotations to the pivotpoint seems to have worked from the get-go, so that knocks out those posibilities... one thing I did notice was direct-entering the rotations in the editor seems to be flipping values arround a bit as well.
(example: in = 1 0 0 45 would become -1 0 0 -45)
Personal note: I am, as always, reluctant to criticize folks busting their asses... but this... can't in good conscience refrain from expressing the magnitude of the disappointment in finding something this fundamental broken in a large update. Though I do sympathize with the desire to make a thorough set of overhauls quickly... Perhaps a bit less pushing for more, and a bit more frequent peer review schedule's in order... After all, we can't help hunt down what we've got so little relative time to double-check... Apologies before-hand if that offends, but did feel the need to say it.../Personal note.
11/25/2008 (4:22 am)
Didn't solve *this* issue, but an ancillary bug involving the values inQuatF & QuatF::set( const MatrixF & mat )
Having been flipped around was the culprit in fixing one of my personal gui elements that used that to point a camera at a targeted object, and did note a few similar changes in the getangles functions.
Can also confirm from an overhaul of fxShapeReplicator to set the spawned instances to floating relative rotations to the pivotpoint seems to have worked from the get-go, so that knocks out those posibilities... one thing I did notice was direct-entering the rotations in the editor seems to be flipping values arround a bit as well.
(example: in = 1 0 0 45 would become -1 0 0 -45)
Personal note: I am, as always, reluctant to criticize folks busting their asses... but this... can't in good conscience refrain from expressing the magnitude of the disappointment in finding something this fundamental broken in a large update. Though I do sympathize with the desire to make a thorough set of overhauls quickly... Perhaps a bit less pushing for more, and a bit more frequent peer review schedule's in order... After all, we can't help hunt down what we've got so little relative time to double-check... Apologies before-hand if that offends, but did feel the need to say it.../Personal note.
#3
11/25/2008 (6:03 am)
Kirk: A note on your personal note: Keep in mind that this is a beta release for this very reason. The number of 'deep' changes that these guys brought over from the internal dev version is... monumental. It represent several man-years of work. Given that they were not the ones making the original changes, overall they've done a remarkable job bringing them over, but things were bound to slip through. The whole purpose of doing a beta release of code is to get more eyes on things to tighten it up. My recommendation is if you have a project based on a previous version or are starting a new project and are time-constrained, use 1.7.x - a beta isn't meant for production.
#4
and for the sake of thoroughness, the two rotation-heavy changes to eleminiate the used functions as problem areas:
this one worked without modifications, so no need to look too far into those:
and this was the one that uses rotations to point at an object (the one that needed fixing by flipping QuatF & QuatF::set( const MatrixF & mat ) back arround to 1.7.1 spec)
11/25/2008 (8:15 am)
Oh, quite agreed. They've done yeoman's work on it. Merely expressing the sentiment that this much at once was ill-advised with a projected timetable *their end* to finish up (unless the timetables changed from the last irc meet) in at this point just 2 weeks and so few eyes to assist with so much changed.and for the sake of thoroughness, the two rotation-heavy changes to eleminiate the used functions as problem areas:
this one worked without modifications, so no need to look too far into those:
void fxShapeReplicator::CreateShapes(void)
if (mFieldData.mAllowFloat)
{
// Get the Replicator Position.
Point3F tShapePosition;
MatrixF tTransform = getTransform();
tShapePosition = Point3F(0,0,0);
tTransform.setPosition(tShapePosition);
ShapePosition = getPosition();
// Calculate a random offset
HypX = RandomGen.randF(mFieldData.mInnerRadiusX, mFieldData.mOuterRadiusX);
HypY = RandomGen.randF(mFieldData.mInnerRadiusY, mFieldData.mOuterRadiusY);
HypZ = RandomGen.randF(0, mFieldData.mOffsetZ) - (mFieldData.mOffsetZ/2);
if (mFieldData.mArc !=0)
Angle = RandomGen.randF(0, mDegToRad((F32)mFieldData.mArc));
else
Angle = RandomGen.randF(0, (F32)M_2PI);
// Calcualte the new position.
tShapePosition.x += HypX * mCos(Angle);
tShapePosition.y += HypY * mSin(Angle);
tShapePosition.z += HypZ;
tTransform.mulP(tShapePosition);
ShapePosition += tShapePosition;
}
else
{
// Find it a home ...
// Set Quaternion Roation.
QRotation.set(ShapeRotation);
// Set Transform Rotation.
QRotation.setMatrix(&XForm);
// Set Position.
XForm.setColumn(3, ShapePosition);
// Set Shape Position / Rotation.
fxStatic->setTransform(XForm);and this was the one that uses rotations to point at an object (the one that needed fixing by flipping QuatF & QuatF::set( const MatrixF & mat ) back arround to 1.7.1 spec)
bool GuiViewport::processCameraQuery(CameraQuery * query)
{
Point3F CameraRotation(0, 0, mDegToRad(mRotateView)); // Rotated View.
// Get Game Connection.
GameConnection* pConnection = dynamic_cast<GameConnection *>(NetConnection::getConnectionToServer());
// Did we get the connection?
if (pConnection)
{
// Yes, so get control camera transform.
//skip out if we can't find a camera,if theres no target recorded, or if the recorded target's now invalid, or if the shape's just fubar
if (!(pConnection->getControlCameraTransform(0.032f, &query->cameraMatrix))) return(false);
if ((pConnection->mAimAtObject == 0)&&(pConnection->getControlObject() == NULL)) return(false);
ShapeBase* target = static_cast<ShapeBase*>(Sim::findObject(pConnection->mAimAtObject));
if(!target) return(false);
ShapeBase* targetObjMount = target->getObjectMount();
if (targetObjMount != NULL) target = targetObjMount;
TSShape const* tsShape = target->getShape();
if(!bool(tsShape)) return(false);
MatrixF camTrans(true);
// get vector between object and observer
Point3F camPos = pConnection->getControlObject()->getRenderPosition();
Point3F aimPos = target->getRenderPosition();
Point3F objVec = aimPos - camPos;
if (objVec.isZero()) objVec = Point3F(0,1,0);
Point3F offsetPoint = aimPos + ((tsShape->radius * 1.5f)/objVec.len()) * (camPos-aimPos);
objVec.normalize();
MathUtils::getAnglesFromVector(objVec, mRot.z, mRot.x);
mRot.x = 0 - mRot.x;
camTrans = MathUtils::createOrientFromDir(objVec);
MatrixF xRot, zRot;
xRot.set(EulerF(mRot.x, 0, 0));
zRot.set(EulerF(0, 0, mRot.z));
camTrans.mul(zRot, xRot);
camTrans.setColumn(3, offsetPoint);
// Set Camera Matrix.
query->cameraMatrix = camTrans;
// Set Near/Far Planes.
query->nearPlane = Con::getFloatVariable("$pref::Video::nearPlane", 0.01f);//0.001f;
Sky* pSky = gClientSceneGraph->getCurrentSky();
if (pSky) query->farPlane = pSky->getVisibleDistance();
else query->farPlane = 1000.0f;
// Return OK.
return(true);
}
// Return Error.
return(false);
}
#5
11/25/2008 (10:15 am)
Ah, I understand what you're getting at. I didn't realize they'd given it such a short timeline.
#6
12/16/2008 (9:59 pm)
Issue resolved with 1.8.0
Associate Tom Spilman
Sickhead Games
Seems like its rotating around the wrong frame... if you select the vehicle in the editor you can see the axis gizmo is not where its supposed to be.