Problem with Waterblock
by James Urquhart · in Torque Game Engine Advanced · 09/11/2005 (12:39 pm) · 6 replies
Hi there,
Currently i have flying vehicles going about in TSE.
Recently, i have been getting this strange assert popping up :
"MatrixF::inverse: non-singular matrix, no inverse."
Oddly enough, i have traced it back to the Waterblock render code :
GuiCanvas::renderFrame -> GuiCanvas::updateReflections -> WaterBlock::updateReflections.
To be specific, here is where it all goes wrong :
Now i notice this error always occurs when i am in the vehicle, usually when the camera is pointing upwards. Usually if i mess up the vehicle and make it collide with something bad (an interior or constantly at the terrain), this assert pops up.
Values of relevant variables are as follows :
The Matrix being inverse'd (camReflectTrans):
camTrans :
mReflectPlane :
Looking at the plane normal, it seems to me that i am looking directly upwards, but thats only a guess...
Anyone got any ideas?
Currently i have flying vehicles going about in TSE.
Recently, i have been getting this strange assert popping up :
"MatrixF::inverse: non-singular matrix, no inverse."
Oddly enough, i have traced it back to the Waterblock render code :
GuiCanvas::renderFrame -> GuiCanvas::updateReflections -> WaterBlock::updateReflections.
To be specific, here is where it all goes wrong :
// store "normal" camera position before changing over to reflected position MatrixF camTrans = query.cameraMatrix; gClientSceneGraph->mNormCamPos = camTrans.getPosition(); // update plane PlaneF plane; Point3F norm; getRenderTransform().getColumn( 2, &norm ); norm.normalize(); plane.set( getRenderPosition(), norm ); mReflectPlane.setPlane( plane ); // set world mat from new camera view MatrixF camReflectTrans = mReflectPlane.getCameraReflection( camTrans ); >> camReflectTrans.inverse(); <<
Now i notice this error always occurs when i am in the vehicle, usually when the camera is pointing upwards. Usually if i mess up the vehicle and make it collide with something bad (an interior or constantly at the terrain), this assert pops up.
Values of relevant variables are as follows :
The Matrix being inverse'd (camReflectTrans):
0 1.742829933e-039 9.302940245e-039 1.347942904e-038 0 0 0 0 -1.3481545e-038 0 -4.622918386e-038 401.2000122 0 0 0 1
camTrans :
0 1.742829933e-039 9.302940245e-039 1.347942904e-038 0 0 0 0 1.3481545e-038 0 4.622918386e-038 1.742862162e-039 7.289827865e-039 0 4.622918386e-038 1.073327642e-038
mReflectPlane :
normal = (0 0 1) d = -200.6000061
Looking at the plane normal, it seems to me that i am looking directly upwards, but thats only a guess...
Anyone got any ideas?
About the author
#2
06/12/2007 (5:42 pm)
I get this too. Any one know a fix?
#3
You could try adding a check before the Assert like this:
That will let you know when it happens and let you keep running.
06/13/2007 (10:20 am)
I've had this happen once. I was mounted, probably looking up.You could try adding a check before the Assert like this:
if(det == 0.0f)
{
Con::executef(3, "MessageBoxOK", "For Your Information","Determinant is zero, engine would have preformed an fatal Assert at this point.");
// Can't invert this matrix, just return
return;
}That will let you know when it happens and let you keep running.
#4
06/14/2007 (3:23 am)
It only happens to me when I run a debug version of TGEA
#5
08/15/2007 (10:47 am)
I am currently having this problem happen to me as well... I just put a mounted particle emitter on my char to shoot bubbles all around him but I am getting this matrix inverse problem pop up when i run the debug build. I really have no idea why it is doing this or how to fix it, any of you guys make any progress towards fixing the problem????
#6
08/15/2007 (4:49 pm)
Just wrap some code around it to ignore if you are running debug I suppose????
Associate James Urquhart
I have come to the conclusion that there is a fault with camTrans, or rather, the camera matrix being passed into the CameraQuery data (query.cameraMatrix).
So, i looked around a bit, and came to this function :
bool GameConnection::getControlCameraTransform(F32 dt, MatrixF* mat) { ShapeBase* obj = getCameraObject(); if(!obj) return false;Now this is interesting... if it can't get the camera object, that function will return false, which will make this function return false :
Then this:
bool GameTSCtrl::processCameraQuery(CameraQuery *camq) { GameUpdateCameraFov(); return GameProcessCameraQuery(camq); }(NOTE: GameUpdateCameraFov could easily crap up too)And finally, returning to our Waterblock reflection function :
// grab camera transform from tsCtrl GuiTSCtrl *tsCtrl; tsCtrl = dynamic_cast<GuiTSCtrl*>( Sim::findObject("PlayGui") ); CameraQuery query; tsCtrl->processCameraQuery( &query );How did this all come about? I have no idea. Its probably something to do with me deleting my vehicle when its "Destroyed", and not returning a proper control state, but thats just a guess :)
And funnily enough, i'm having a slightly hard time reproducing this - just typical :)
However, there really should be extra error checking to prevent this Assert, or extra Assert's to give a clearer idea of what the problem is.