How you managing the scale problem
I'm new to Godot, and not too experienced with programming in general, so I'm struggling a bit navigating the ivoyager project. I know from my past dabblings that all game engines can't deal with a solar system to scale, especially if human size objects are involved. How does iVoyager handle the extreme scales, and where in the code should I poke around for this?
Comments
- Global.scale (find in singletons/global.gd) defines "engine units" per km. I think it's set to 1e-9 or something like that in last version. Some engine errors start to happen at 1.0 or maybe a bit above that.
- Dynamically adjusting near and far properties of the camera (tree_nodes/voyager_camera.gd) as the camera moves in and out from its parent object. You can't just set them to super small and super large (respectively) and leave it at that. But I found that it works if I adjust them together as the camera zooms closer or farther from its parent. I have some small moon models in the next version (coming soon I hope) and you can zoom to kilometers just fine. I believe smaller/closer models (even human scale) will work, but I have not tested this yet.
- The camera is always near the origin (i.e., has small global translation). As you move to Pluto, it's really the sun (and all its other children) that are moving away. This is done by a single line of code in voyager_camera.gd, just search for "CENTER_ORIGIN_SHIFTING". It looks a little obscure but I'm literally just moving the sun to the opposite translation of the camera's parent body (the camera re-parents itself when it moves from one body to another). If you set CENTER_ORIGIN_SHIFTING = false, then you will see Pluto shake wildly from imprecision errors.
One thing that is weird is that Godot 3.x versions have *partially* implemented double precision float. GDScript vars and a lot of math works as double precision. However, most engine stuff is single precision. The Godot devs say we will have full double precision implementation in Godot 4.0.It just so happens I'm overhauling the scale system (and units in general) so it will look a little different in next version. Global.scale is gone. Instead, there is a static class UnitDefs that defines SI units like SECOND, METER, KG, etc. So now we have UnitsDef.METER = 1e-12 (or something like that) and that defines our simulator scale.
Hope you're having fun with I, Voyager! I'd love to have some other developers involved.
Models that are (or will be) part of the core I, Voyager packages go in ivoyager_assets/models/. The current development ivoyager_assets has Phobos, Deimos, Hyperion and a couple asteroids in there. I'd like to add at least a few real spacecraft there as well: Voyager 1 & 2, etc. (Note: there is an issue posted about a graphics glitch, possibly related to some of my new models.)
Models for your own project should go somewhere else. (The idea is to stay out of ivoyager & ivoyager_assets unless you intend to contribute changes to I, Voyager.)