Aynone else seen this bug?
by Max Robinson · in Torque Game Engine · 02/29/2004 (2:04 pm) · 11 replies
If you've ever raised the visible limit past 1000 (to say, 3000) you'll notice that some objects over 1000 units away aren't visible unless you are in a obs camera.
Well, in shapebase.cc, there are some lines:
This is only executed on the server, yet it is getting the client's scene graph. Basically this means thats it always sets vis distance to 1000!
All you have to do to fix this is set the sky to gServerSceneGraph->getCurrentSky(); instead.
I couldn't find any other discussion on this, so It seemed worthy of posting. This should probably get into the head, I'd think.
Well, in shapebase.cc, there are some lines:
// grab the visible distance from the sky Sky * sky = gClientSceneGraph->getCurrentSky(); if(sky) query->visibleDistance = sky->getVisibleDistance(); else query->visibleDistance = 1000.f;
This is only executed on the server, yet it is getting the client's scene graph. Basically this means thats it always sets vis distance to 1000!
All you have to do to fix this is set the sky to gServerSceneGraph->getCurrentSky(); instead.
I couldn't find any other discussion on this, so It seemed worthy of posting. This should probably get into the head, I'd think.
#2
02/29/2004 (2:15 pm)
Sweet!
#3
Both the client and server objects trace through that function. I'll paste what I think the function should be rewritten to and I would ask other people to check my work.
new function:
02/29/2004 (3:40 pm)
Actually that is not 100% correct.Both the client and server objects trace through that function. I'll paste what I think the function should be rewritten to and I would ask other people to check my work.
new function:
void ShapeBase::onCameraScopeQuery(NetConnection *cr, CameraScopeQuery * query)
{
// update the camera query
query->camera = this;
// bool grabEye = true;
if(GameConnection * con = dynamic_cast<GameConnection*>(cr))
{
// get the fov from the connection (in deg)
F32 fov;
if (con->getControlCameraFov(&fov))
{
query->fov = mDegToRad(fov/2);
query->sinFov = mSin(query->fov);
query->cosFov = mCos(query->fov);
}
}
// failed to query the camera info?
// if(grabEye) LH - always use eye as good enough, avoid camera animate
{
MatrixF eyeTransform;
getEyeTransform(&eyeTransform);
eyeTransform.getColumn(3, &query->pos);
eyeTransform.getColumn(1, &query->orientation);
}
// RDB: moved sky stuff down further
// First, we are certainly in scope, and whatever we're riding is too...
cr->objectInScope(this);
if (isMounted())
cr->objectInScope(mMount.object);
if (mSceneManager == NULL) {
// Scope everything...
gServerContainer.findObjects(0xFFFFFFFF,scopeCallback,cr);
return;
}
// grab the visible distance from the sky
// RDB: use mSceneManager on this so we dont have to keep track
// of whether we are on the client scene or server scene
Sky * sky = mSceneManager->getCurrentSky();
if(sky)
query->visibleDistance = sky->getVisibleDistance();
else
query->visibleDistance = 1000.f;
// update the scenemanager
mSceneManager->scopeScene(query->pos, query->visibleDistance, cr);
// let the (game)connection do some scoping of its own (commandermap...)
cr->doneScopingScene();
}
#4
02/29/2004 (3:53 pm)
Actually I stand corrected. The server is the only one that travels through that function. I could have sworn both did but meh.
#5
02/29/2004 (6:35 pm)
Hmm... A pickle for me to contemplate tomorrow.
#6
Only saw echoes on server with this one... and I saw a lot of them, too!
03/01/2004 (3:46 pm)
Heh, I just run with a console print in there, and run server & client separate. Only saw echoes on server with this one... and I saw a lot of them, too!
#7
I have noticed this a lot so I figured I may as well ask the question here:
Doesn't just leave to much of a chance for someone to come a long and try to add something to the else only to find out that its not bracked.
Is there a reason for not using brackets around the if and else. Here is what I was meaning. I don't want to start a flame war over convention but it seems to be a GG convention so I figured I would ask why?
Thanks, Ben
EDIT: the else didn't have an trailing enter.
03/01/2004 (4:40 pm)
Hello Everybody, I have noticed this a lot so I figured I may as well ask the question here:
Sky * sky = mSceneManager->getCurrentSky(); if(sky) query->visibleDistance = sky->getVisibleDistance(); else query->visibleDistance = 1000.f;
Doesn't just leave to much of a chance for someone to come a long and try to add something to the else only to find out that its not bracked.
Is there a reason for not using brackets around the if and else. Here is what I was meaning. I don't want to start a flame war over convention but it seems to be a GG convention so I figured I would ask why?
Sky * sky = mSceneManager->getCurrentSky();
if(sky) {
query->visibleDistance = sky->getVisibleDistance();
} else {
query->visibleDistance = 1000.f;
}Thanks, Ben
EDIT: the else didn't have an trailing enter.
#8
In many cases adding the brackets for short if statements like this detriments readability by adding clutter.
At least, that's how it is in Torque, and that's how I write my code. This is certainly a grey area, and there's a lot of different ways of approaching it. :)
03/01/2004 (8:48 pm)
It is assumed that the coder is familiar enough with C++ to notice the "one liners" and add brackets if necessary.In many cases adding the brackets for short if statements like this detriments readability by adding clutter.
At least, that's how it is in Torque, and that's how I write my code. This is certainly a grey area, and there's a lot of different ways of approaching it. :)
#9
joke {
As long as its not monday morning or after a party :)
}
Thanks for letting me know. I had noticed and figured that had to be a reason but wasn't sure what it was.
Thanks, Ben
03/02/2004 (6:43 pm)
Hello Ben, joke {
As long as its not monday morning or after a party :)
}
Thanks for letting me know. I had noticed and figured that had to be a reason but wasn't sure what it was.
Thanks, Ben
#10

With stretched terrain, I get normal framerates, and it doesnt even look bad up close either.
03/05/2004 (10:21 am)
3k vis distance rocks...
With stretched terrain, I get normal framerates, and it doesnt even look bad up close either.
#11
03/07/2004 (12:13 pm)
Nice. That looks pretty sweet. Tho the fog is still pretty close :(
Associate Kyle Carter