Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Really big gameworlds, variable problems

Author
Message
jlahtinen
14
Years of Service
User Offline
Joined: 26th Oct 2009
Location: Finland
Posted: 10th Feb 2014 14:10
If you make a game map sized 1.000.000x1.000.000 (db units) in DB.

Then add camera in the program. Up&down arrows forward/backward left/right arrows turn the camera, basic stuff.

The problem is float accuracy. When you move in angle and camera's x# and z# are big enough then x# or z# "stops" adding up.

Scaling won't help, because you need to divide moving speed also and the same float limit still exists.


How do you get around this? If anyone understood my example.

My AppGameKit project: http://forum.thegamecreators.com/?m=forum_view&t=206794&b=48
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 10th Feb 2014 15:06
I suppose you could create a set of sectors for your world and keep separate variables for those, for example you have 10x10x10 sectors of a certain size. When moving far enough you reset your floating point coordinates and update the sector instead. Would be some work, but it should work if you really need that huge a world... but do you really?
It takes a lot to break the float limits


"Why do programmers get Halloween and Christmas mixed up?"
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 10th Feb 2014 16:20 Edited at: 10th Feb 2014 16:23
Quote: "If you make a game map sized 1.000.000x1.000.000 (db units) in DB."


Really? Why so huge? How could you possibly populate that with other objects and still have a frame rate above 3? Have you moved through a terrain/matrix that is even 1/10 that size? It takes 'forever'.

Quote: "How do you get around this?"


Don't make something so huge in the first place. If you really need something that big, make it in chunks, so you can manage it.
Quote: "
It takes a lot to break the float limits "

Agreed.

So many games to code.....so little time.
jlahtinen
14
Years of Service
User Offline
Joined: 26th Oct 2009
Location: Finland
Posted: 10th Feb 2014 23:09
Why? Well why code anything?

The maker of Evochron managed it and dealt the problem with DB even.

I hope someone in here knows how to get around this.

My AppGameKit project: http://forum.thegamecreators.com/?m=forum_view&t=206794&b=48
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 11th Feb 2014 01:12
Quote: "The maker of Evochron managed it and dealt the problem with DB even."

Got any source on that?

Quote: "I hope someone in here knows how to get around this."

We just told you. You split up your world into segments / chunks / whatever-you-want-to-call-it that fit within the 32-bit floating point range. When you get to the end of it you move onto the next chunk and when this happens you reset your float coordinates so that you're at position (0, 0, 0) in chunk (1, 0, 0) which is the same as being at the absolute position (2 000 000 000, 0, 0) / what have you. You'll have to keep track of the chunks and move objects around to fit with where you currently are yourself though.

But don't make things ridoncelously large just because you think you have to. For example, have you considered just dividing the size of everything by 10 000 or something? If you need sizes in the billions chances are you don't need any discernable detail when moving corresponding to a single unit. Or maybe you do, hard to say without you telling us what you're doing


"Why do programmers get Halloween and Christmas mixed up?"
pcRaider
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 11th Feb 2014 05:17
This is the map which TDK_man made.
The map divides it and is connected.
There are a lot of small maps in that.

windowsXp

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Feb 2014 19:30 Edited at: 26th May 2014 19:49
[ EDITED ]

So many games to code.....so little time.
jlahtinen
14
Years of Service
User Offline
Joined: 26th Oct 2009
Location: Finland
Posted: 12th Feb 2014 11:16
Yeah, Newcomers' board wasn't a right choice I see.

Quote: "For example, have you considered just dividing the size of everything by 10 000 or something?"


Like I wrote, dividing won't work if you want to keep moving speeds and distances the same. If you divide movement speed, you divide the interger limits also.


Quote: "This is the map which TDK_man made.
The map divides it and is connected.
There are a lot of small maps in that."


Thank you, I'll check this out.


Quote: "I will ask you again, Why so huge? Do you actually need a map that large? Have you actually created a map (that fits within float limits) and populated it with stationary objects, NPCs, player, whatever and need more? My feeling is that you have not, because my experience tells me that even with a high-end rig, DBP will bog down to a crawl by the time you are rendering a number of objects, and at the same time providing reasonably accurate collision, controlling a player and providing AI for the NPCs, not to mention moving/animating objects. "


I was just wondering on how to make something like Space engine or Evochron. Basically a galaxy with realistic distances and sizes.

Lots of objects? You can use procedural-programming, streaming, LOD-levels, viewdistances etc, that is not the problem.


Not to be rude, but I dont understand why you question my simple question? You dont have to post if you cant really help. Sorry, I'll ask in the DBPro section.

My AppGameKit project: http://forum.thegamecreators.com/?m=forum_view&t=206794&b=48
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 12th Feb 2014 13:16 Edited at: 12th Feb 2014 13:17
For a space scene where it is unlikely that a ton of objects are in close proximity to your player, one solution could be to detect when your coordinates are approaching values which cannot be accurately stored. At that point, move your camera/player back to 0,0,0 and relocate all of the local scenery objects to positions which are relative to the camera.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Feb 2014 19:41
You're going to have to break your world down into zones. I don't know of any game that would load such a large map at once. Think of a 2D tile map. You only draw the tiles that are visibly on screen and ignore the rest of the map until you've scrolled onto the next column of tiles. You'd essentially be doing the same thing in 3D.

luskos
16
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 14th Feb 2014 05:15
I had very same problem with project of mine.Instead of moving my object around the space i move everything else in a manner that resembles traveling.It was sci-fi rpg and the travel was trough space, i'm not sure if this can help you or if it is even possible to do it with terrain but it works really well, so there is the code.



Coding is My Kung Fu!
And My Kung Fu is better than Yours!
jlahtinen
14
Years of Service
User Offline
Joined: 26th Oct 2009
Location: Finland
Posted: 14th Feb 2014 16:00
Yeah, I thought to do that, but I used a node approach (I think this is more efficient with lots of objects).

Some interesting stuff about same problem with Dungeon siege:

http://scottbilas.com/files/2003/gdc_san_jose/continuous_world_paper.pdf


One solution would be to use multiple viewports with different scales depending on the distances, but that seemed like too much hassle for me.

My AppGameKit project: http://forum.thegamecreators.com/?m=forum_view&t=206794&b=48
The Tall Man
10
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 26th May 2014 10:51
Here's a page on floating point numbers:
http://en.wikipedia.org/wiki/Single_precision

Based on that, 1Mx1M shouldn't be running into any problems.

However a work-around might be this. Instead of creating a map that's 1Mx1M, create one that's 1024x1024, with each of your units being 1/1024 of a DB unit. This gives you an effective range of 1048576, which is more than a million. 1024 is more friendly to floats than 1000.

If you need to scale it up to match what you're loading it, you could either scale it up with the Scale command (which dynamically applies a transformation), or you can scale everything else down with the same command.

Judging what we see is the greatest blinder and self-limiter in the universe.

What we perceive is never reality. It is only a story we tell ourselves based on our current perspective, which has far more to do with our beliefs about ourselves than with anything else.
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Jun 2014 16:49 Edited at: 12th Jun 2014 16:56
RIGHT, Forgive me if any of these techniques have already been mentioned.

Firstly to establish my view of the matter and to better demonstrate what I am going to tell you below is as you probably already know; you have 9,999,999 maximal units either side of zero, -9,999,999 to 9,999,999 for your world. Far less if you introduce interpolated velocities, physics and whatnot. Knowing this will tell you that no open world game made in DBP ever uses that kind of extent, no matter what you see on your screen. And 9,999,999 units and 9.999999 units are as maximal as single floating point units can represent accurately (or is it 0.9999999?). The exception would be a game with no physics or interpolated velocities, which is not what you want.

Secondly, as indicated by the others; the obvious solution is to wrap your coordinates around; afterall; if you did not have to limit your coordinates then what would be the point of this thread.

Any player of the old Sonic the hedgehog games will well remember certain bottomless levels as the hedgehog runs or falls without ever reaching the bottom the level on 16bit hardware. This is a perfect example of wrapping coordinates, or in other words:

AllObjectPositions = WrapValue( AllObjectPositions , MinimumPosition, MaximumPosition )

Matrix1 gave you wrapping functions in its commandset, and double floats can provide you with storage of larger coordinates.

Thirdly, creative thinking on a day to day basis in the context of the scenario, gameflow or objective. A good map design for goals will make your maps seem larger than they are.

In a nutshell, just because something looks like it is moving, does not mean that it is moving. Just because something looks big, does not mean that it is big.

Think of the old ancient Windows space flight screensaver; is the camera really moving? Or is it the stars that are moving?

You may need to be experienced to understand what I am saying here, but you seem quite knowledgeable.

Login to post a reply

Server time is: 2024-04-19 16:38:37
Your offset time is: 2024-04-19 16:38:37