Sign in to follow this  
DanielH

1+1=3

Recommended Posts

Hi I'm working on a terrain engine but I have some problems with very basic maths. I divide the world into diffrent segments. Each segment is 256 quads wide. Each segment consists of 8 patches. A patch is 32 quads wide. I've created a vertex buffer with an array of vertices sized 257*257. But this just render an ugly graphic disaster. When I change the vertice buffer to 258*258 it works like a charm. But why? I can't see how how this happens since 256 quads shouldn't use more than 257 vertices per row/column. And I never use indexes outside that bound (afaik, tried to find any places where I do but couldn't find any). Am I being a total retard with the numbers or does my code contain some extremly hard to catch bug? I've looked through it hundreds of times now but still haven't found anything. And I can't live with a 258x258 buffer just because it works, if I don't understand why! :P

Share this post


Link to post
Share on other sites
I don't think anybody has ever written a quad-base terrain engine without getting an off-by-one error somewhere. Because there are so many places it can happen, liberal use of ASSERT and step-debugging through the nested loops is highly recommended.

Regards
Admiral

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this