It is currently Fri Dec 13, 2013 5:56 pm

 All times are UTC

 Page 1 of 1 [ 6 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Can i use doubles vectors in xnaPosted: Sat Jan 07, 2012 8:48 am

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
I have come to a bit of a problem well its not reall a problem as it is anoying. I have reached my limit on my planet renderer, if the planet radius is over 5000000.0f, i get wiered issues with the camera and also the distance calculation always comes out as NAN. i gather this is due to the float been too small to handle the numbers. I know in dx you could just write a double vector class, is it possible to use one in xna, or would i just hae to find a way round it , any advice is great guys.

Top

 Post subject: Re: Can i use doubles vectors in xnaPosted: Sat Jan 07, 2012 2:07 pm
 Dexterous Droid

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3751
Location: South Africa
floats can hold really big numbers (up to 10^34). It's just that you only have about 7 significant figures with single precision. If you're getting a NAN, I think that means you're dividing by 0 somewhere. So rather than your problem being that floats can't hold big enough numbers, maybe they're not able to hold a small enough number somewhere in your code.

_________________
Whatever the mind can conceive and believe, it can achieve

Top

 Post subject: Re: Can i use doubles vectors in xnaPosted: Sat Jan 07, 2012 3:01 pm

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
Thanx.
sorry thats what i mean i think its to do with precicion on a smaller numbers specially when it get down to the really high detail on the terrain. but would using doubles work for this, or is it just completely pointless as the numbers passed to the shader/rendering piepline are stil float.

Top

 Post subject: Re: Can i use doubles vectors in xnaPosted: Sat Jan 07, 2012 7:37 pm
 Dexterous Droid

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3751
Location: South Africa
Using doubles might work, but it would still leave you with the same problem if you crank up your scales enough and it would possibly slow your program down a bit. Rather have a look at where the NaN is getting spat out and add some code to handle the edge case.

Reading this http://steve.hollasch.net/cgindex/coding/ieeefloat.html I think I was wrong about you dividing by 0 - that should give you infinity. Have a look at the "Special Operations" table where it shows what operations will result in NaN. There's an even more comprehensive list on Wikipedia http://en.wikipedia.org/wiki/NaN#Creation. Rather fix your code than try to solve the problem with a bigger data-type.

_________________
Whatever the mind can conceive and believe, it can achieve

Top

 Post subject: Re: Can i use doubles vectors in xnaPosted: Sun Jan 08, 2012 12:29 pm

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
I figured it out it was the noise generation function, and also a little added variable i shouldent, so i just used my new simplex noise class, and got rid of the redundant variable and hey presto . The only thing was that it bloody took 4 hours of adding NAN exceptions to functions and tracing it back to the right line of code causing the problem. The funny thing was it was only troughing this out if i used a heightmap, if i used a heightmap generated using fractals, it just works, cant be bothered to figure out why it works perfectly now. I have though moved most distance calculation variables to doubles, i want the acuracy and to be ohnest at the ground i get around 120fps not moving and about 40 - 60 moving, but ofcource the problem with quadtrees, its the updating, i need to find a way to speed this up.

cant use vertex and index buffers they just take too dam long to create, cant create them at loadtime or memory will go nuts. I only use 1 set of index buffers so this helps. anyways im just rambling now, thanx for the help .

Top

 Post subject: Re: Can i use doubles vectors in xnaPosted: Sun Jan 08, 2012 8:45 pm
 Dexterous Droid

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3751
Location: South Africa
Nice, well done

_________________
Whatever the mind can conceive and believe, it can achieve

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 6 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ Forums    Forum Rules and Posting Guidelines Wiki Discussion    Help    Content Issues Game Programming Discussion    C and C++ Game Programming    Java Game Programming    Language Agnostic Programming    .NET Game Programming    VB Game Programming    Mobile Game Programming    Web-Based Game Programming    Other Languages    OpenGL Development    Direct X Development Game Development Discussion    Game Design    Game Media Off-Topic Discussion    Announcements    Off-Topic    Community Projects    News