Strange object disappearing

Feb 12, 2012 at 6:51 PM

While playing with picking bug I stumbled upon another thing. Look here:

http://www.youtube.com/watch?v=lfvgLQA7cwg

It looks like when you rotate camera in certain direction the object disappears, but only then the camera is in certain position. For example when you look from point [0,0,0] towards X axis everything is ok. Then you move along X and suddenly the object is gone. But when you rotate the camera without moving it - bam, the object is back... and gone again when you turn camera back.

I have tried to use material Terrain.qsm (actualy my material is based on that one) and I got the same results :/ In this case I'm clueless, graphics programing is a black magic for me :) Do you have any ideas what may be wrong?

Coordinator
Feb 14, 2012 at 5:33 AM
Edited Feb 14, 2012 at 5:39 AM

That looks like an issue with frustum culling calculation. Since that is not heightfield, but rather a triangle mesh shape, it would be calculating a bounding sphere for the entire physics shape and then comparing that to the camera frustum. Either the frustum culling calculation is off, or the bounding sphere is inaccurate.

Where were you a month ago when I had a lot of time to work on this stuff? ;)
I feel bad now because I'm so busy as work, I want more time to investigate stuff like this.
The exact line where the bounding sphere for your terrain is compared against the view frustum is line 281 in RenderComponent.cs:
if (!desc.ViewFrustum.Intersects(this.boundingSphere))
{
return;
}
I would calculate the distance between the opposing corners of your terrain that are furthest apart. Unless you have an insanely high or low section in your terrain the opposing corners distance from each other will likely be almost equal to the bounding sphere's diameter. You can then place a breakpoint on line 281 and see if your calculations match what the bounding sphere's diameter actually reports to be.
I'm not entirely sure how the bounding sphere would be incorrect, it takes into account ever vertex in the render mesh, and accounts for scale of the mesh as well, when calcuating the bounding radius. This is done in LoadModel() and ProcessBoundingRadius(), both also within RenderComponent.cs. Unless you've changed the scale after the initial loading of the render component, that might be able to cause something like this.
I will put a bounding radius renderer on the list for the next version, it would be helpful when debugging issues like these, and it should be easy enough since we already render sphere for physics shapes.
Feb 14, 2012 at 6:07 PM

Thank you for all those tips, I'll look in that as soon as I can :) I'm also sharing time between work, family and rare moments when I can code for pleasure or play, so you shouldn't feel bad about your short time - you're already replaying quicker than one could expect, and I thank you for that :) Now after all that sweet things have been said, I'll try to get back to your suggestions closer to Thursday, I hope.