Game Development Community

Turning off culling on large DTS shapes

by Thomas \"Man of Ice\" Lund · in Torque Game Engine · 08/30/2004 (12:46 am) · 16 replies

I'm working on a prototype game that uses large DTS player objects - large as in "long". When the players approach each other there is that nasty pop near the edges when the center of the shape gets culled, taking half the player shape out of the scene.

Is there any possibility to say e.g. "turn of culling", "do culling on the bounds box instead of center" or even (wishful thinking) "only cull everything but player controlled objects.

We dont have many player shapes (or shapes in general) so even if all of them are drawn behind my back, then its no problem performance wise.

Any help or hints would be lovely. I cannot find any information on this in the forums at all

#1
08/30/2004 (9:07 am)
I ran into this problem recently, here's a hack which will essentially turn off culling of objects:

Go to sceneTraversal.cc, look for PotentialRenderList::insertObject, and a block of code that looks like this:

bool render = true;
   for (U32 i = 0; i < 5; i++) {
      if (viewPlanes[i].whichSideBox(center, xRad, yRad, zRad, Point3F(0, 0, 0)) == PlaneF::Back) {
         render = false;
         break;
      }
   }

Comment out the for loop.

Then in sceneState.cc, SceneState::isObjectRendered, look for the same block of code (well, really similiar). Do the same process.

You can probably add a method to SceneObj called renderAlways so that you would perform the loop on all objects that do not return true for renderAlways. Or you could change the check to include more points of the bounding box. I didn't go quite this far because I didn't need to.

Hope that helps man.
#2
08/30/2004 (11:30 am)
Thanks!!!

I was (before posting) looking at exactly that code. Commented it out and did not see any changes ingame. I didnt realize there were 2 of those.

I might create a quick resource and do this proper. Lets see if I can get it to work first
#3
09/04/2004 (1:20 pm)
Sounds like an excellent addition to HEAD. I've had to create several objects that "fake" renderalways - this seems like a good way to have real renderalways functionality.
#4
09/08/2004 (6:08 pm)
I cleaned up my changes to make it cleaner. There's a patch available here:
http://knowhere.net/gg/renderAlways.zip

This is my first CVS diff attempt. I probably screwed it up, if you want I can just send you the files I modified.

I modified these files:

engine/scenegraph/scenestate.cc
engine/scenegraph/scenetraversal.cc
sim/sceneobject.h
sim/sceneobject.cc

I added a function to sceneObject called clipPlaneTest, then modified scenestate and scenetraversal to call it. That way, decendant scene objects can decide how to do the clip plane test.

In my little scene object I'm just returning true all of the time of clipPlaneTest. But other objects could implement different tests, like testing all of the points of the bound object against the clip plane or something silly like that. ;)
#5
09/08/2004 (10:16 pm)
Going to test it tonight
#6
09/09/2004 (9:53 am)
Interesting. I'd like to see some performance comparisons, but that's a novel approach. Maybe in 1.4.... :)
#7
08/23/2005 (6:48 pm)
Sorry to necropost here but I've got this same problem. Large DTS shapes that I always want to render...
I tried the quick fix above, but the objects keep popping into and out of view dramatically...

These DTS's are quite huge though..

UFO hovering over a city block...

Oil Tanker...

Both pretty much to scale with the buggy from the racing example.
#8
08/23/2005 (7:31 pm)
@Jason: I was toying with very long dts platforms, and also had the scope issue, but changing both areas of the engine fixed the problem here. Did you make changes in both areas of the engine?

B--
#9
08/23/2005 (11:43 pm)
1.4 has a fix for this; a member on SceneObject called setGlobalBounds, which makes an object act like it has infinite bounds (so always rendered/collided against).
#10
08/24/2005 (12:10 am)
Yeah - you got to change it both places to make it work. They should then stay in view all the time.
#11
08/24/2005 (3:38 am)
Thanks for the reply guys, I did change both places, but the item seems to disappear quite suddenly after a certain distance...
I'll re-check I've done the work correctly.

@Ben, I'm using (at least I believe I'm using) the 1.4 head so this function should be available to me. One question, when you say setGlobalBounds will make it always rendered and collided against... do you mean that all of my object's collision code will trigger against the object all the time? Or will it use its collision mesh instead of the bounds?
I'd like the object rendered always but collide only when I hit it... if that makes any sense...
#12
08/24/2005 (3:44 am)
It just acts like it has an infinitely big bounding box. Its collision info itself won't be altered.
#13
08/24/2005 (3:59 am)
Cheers Ben, I'll look into that when I get home...
While we're on the subject of large DTS's, is there are realistic limit to the size of Truly Huge DTS's? I'm talking Independance day sized UFO's here... Practical? Will the engine cope? It's a fairly low poly model but scaled up to a massive size.
#14
08/24/2005 (11:21 am)
If it's actually big, it'll be fine. If it is scaled you might get some odd behavior (the engine doesn't quite support scaling objects 100%).
#15
08/24/2005 (11:56 am)
I've played a little with scaling, and collision seems to go awefully wrong at some point. Just model it big!
#16
08/25/2005 (5:35 am)
Trouble with modelling it big is Milkshape can only display models of a certain size in the window.
I guess I could always model it normal size then use the scale all tool to make it seriously huge...

Anyone done that?