0

I've been searching around the internet for several hours to find some Farseer implementation which uses double precision, no results. My game is going to have big, open world and I need that precision much.

Where to find such a Farseer implementation or any other Box2D implementation accessible in XNA and Monogame?

For now my options are:

  • Keep on looking
  • Modify Farseer (seems the best, so far)
  • Apply offsets to bodies, so their positions will never exceed the float capacity (this might be problematic, because I could want to have different parts of the world loaded simultaneously - like player 1 and player 2).

Thanks in advance.

Michał
  • 2,202
  • 2
  • 17
  • 33
  • By "double precision," do you mean floating point? – Robert Harvey Jan 10 '14 at 18:05
  • 1
    Yes, I want to use `double` instead of `float` – Michał Jan 10 '14 at 18:06
  • What exact issue are you having with the current `float` implementation? I'm not sure what they'll say, but gamedev.stackexchange.com might have a better opinion. – Nate Jan 10 '14 at 18:21
  • @Nate Problem is, that my world may need big positions, with big precision like `0.0012` and `96512512.8671`. This would not be handled properly (float has 7-8 digits of precision). Thanks for gamedev.stackexchange.com recommendation - I'll try there :) – Michał Jan 10 '14 at 18:26
  • That's also going to be an interesting physics engine that can handle those differences in degrees of scale. Regardless of the single/double math, Box2D likes all its dynamic objects to be something like 0.1m to 10.m dimensionally or things don't play nicely... – FuzzyBunnySlippers Jan 10 '14 at 21:01
  • @FuzzyBunnySlippers The differences will be only in objects' position. Objects' scale is not meant to be unusual – Michał Jan 10 '14 at 21:19
  • Do you actually NEED this? I mean, have you actually generated a world so large you've already exceeded the float.MaxValue = 340,282,300,000,000,000,000,000,000,000,000,000,000? Physics engines have been known to have stability issues with the extremes of floating point numbers, you may very well run into other issues doing this. – craftworkgames Jan 11 '14 at 12:28
  • @craftworkgames I MAY need this. I am writing open world engine (nearly end) and I should look at the things more broadly. Maybe I won't use world that big in the first game I'll create with it. But what about second, or third? Why should I limit myself? And responding directly to the float.MaxValue - try to store 340,282,299,299,299,299,299,299,299,299,299,299,299 in float. It is less than Max for sure. It is not about size in floating points, it's about precision. – Michał Jan 11 '14 at 15:29
  • @Michał My point is that you are creating a LOT of work for yourself for something you don't need yet, and maybe never will. In my experience it's a bad idea to worry about "limiting yourself" because until you hit those limits you don't need to do anything about them. When / if you do hit the limits, you will be able to sort it out then. http://en.wikipedia.org/wiki/You_aren't_gonna_need_it – craftworkgames Jan 14 '14 at 12:21
  • @craftworkgames I talked to my programming prof about that and he said I should make offsets instead of doubles (point 3 in my question). Actually farseer implements that. – Michał Jan 14 '14 at 20:28
  • @craftworkgames But: my engine is an open world engine and it is MEANT for huge worlds. As for now I write engine, not game. That's why I cannot agree with YAGNI when we talk about engines. Let's assume you're from Epic, making the Unreal Engine. If your first game on UE is going to be only in-doors, it doesn't mean you shouldn't make out-doors - because it will be needed for further projects and it will be hard to add it, when engine is made for in-doors. Some changes need to be thought of much before - it's matter of architecture. – Michał Jan 14 '14 at 20:30
  • @Michał Actually, that's exactly what it means. The first iteration of the Unreal engine wasn't meant for huge worlds. It was meant for in-door first person shooters. I'm certain they didn't start by making an open world physics engine. They made an engine so they could make a game. You're goal is to make games. Engine's are there to support game development. http://en.wikipedia.org/wiki/Unreal_Engine – craftworkgames Jan 15 '14 at 00:24

1 Answers1

0

Ok, I edited the Farseer. It seems to work (on the samples attached). It is not exactly double precision - I didn't edit some internal functions of XNA - it is not, strictly speaking, legal :) But if you want, you can actually find these references by "(float)" query after ctrl + F, and create your own implementations for given methods (shouldn't be difficult - 3 or 4 short methods). I edited engine versions for XNA, Mono and XBox, and edited XNA samples.

Here's the link, if somebody needs it: https://dl.dropboxusercontent.com/u/75904715/farseer%20double%20precision.rar

Michał
  • 2,202
  • 2
  • 17
  • 33