Jump to content
  • Advertisement
Sign in to follow this  
DanielH

1+1=3

This topic is 4279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
How are you subdividing your mesh? It sounds like you have an off-by-one error someplace, likely in the way you assign indices. Code would be helpful if you can post it.

Share this post


Link to post
Share on other sites
your code must be wrong, you don't need 258 vx.
Assert() in every place you build/access your array and your indicies and you'll find something
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!