-
-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve random system generation, load custom systems from JSON #5622
Improve random system generation, load custom systems from JSON #5622
Conversation
I'll get on it, though it might take me a week 👍 |
Was going to test it, but crashes (window frame is rendered, but then crashes):
|
A backtrace would be useful 😉 Unsure about the crashing - the code should be functional but was cherry-picked out of a larger branch so it's possible I missed an implicit dependency that's present in the full system-editor branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this all looks good, I'm guessing savegame bump and that it cahnges the universe quite a lot.
Approved
I get a crash in testing x64|Debug looks like it's trying to load CityOnPlanet
|
For me, on Windows x64|Debug in VS2019 using CMake it fails with Assimp loading EDIT: this also fails within the ModelCompiler when asked to build that file, or to batch process everything. |
@fluffyfreak ...I haven't rebased this PR onto master since the PR that fixes Assimp in debug mode was merged. That'd be the cause of the crash. |
- Disable 1.25x multiplier to atmospheric density in StarSystemCustomGenerator - Should be replaced with changes to individual system definitions
savegame bump
Avoiding the system index allows generating a system without needing to know the context of how many other systems exist in the sector, which is important for consistent results in the SystemEditor.
SystemBody did not have any concept of Argument of Periapsis, limiting the orbits that could be specified. Random generation has not been adjusted to generate orbits with random argument of periapsis.
- Add JSON-based serialization to SystemBody and StarSystem. - Will replace lua-based serialization for custom systems - Move responsibility for generating body orbit to SystemBody - Hacked in support for using both Lua and Json-based custom system formats; intend to fully deprecate Lua-based
Codepath was never exercised, assumed fixed number was serialized as numerator/denominator. Corrected to load whole/fractional parts as intended.
- Generate all "missing value" random body parameters using consistent per-body hash value. - Avoids implicit dependency on system load order or body layout order. - Semantically separates body parameters which the game should generate for gameplay reasons from body parameters which were not listed in the lua custom system definition.
Add several new heuristics controlling generation of planets and moons around primaries. - Scale body mass and orbit eccentricity based on its distance from the primary; generates more "realistic-looking" results. - Start generating bodies closer to primary (moons of gas giants look closer to Jupiter/Saturn) - More straightforward Hill Radius handling for generating moons. Add orbit generation method for inserting a new body between two existing bodies - Designed to be consumed by the SystemEditor for "random guided" body creation. Generated body orbits are fully parameterized with offset, inclination, and argument of periapsis. - Now supports (rare) retrograde orbits
- SystemBody is now responsible for information about its atmospheric pressure, density, and height of tropopause (0.01 atm height) - Removed old implementation from Planet.cpp
- Ensure body satellite shell density is reproducible outside the initial generation pass. - Add std::initializer_list constructor/seed operation to Random.h - Avoid segfault if asking for satellite shell density for a gravpoint without children
- Increase realism of body arrangements generated through additional post-processing factors. - Fix overflow in mass_from_disk_area (don't take the cube of the orbit apoapsis when not needed) - Fix dense stars generating large numbers of unnaturally-close gas giants - Increase mass falloff towards edge of body satellite radius
- Load other_names from custom system definition - Move random generation of system lawlessless to PopulateStarSystemGenerator - Removes all random generation from StarSystemCustomGenerator
- Ensure bodies are loaded with exactly the same values as they were serialized with - Remove latitude/longitude fields from CustomSystemBody
- Starports in starting systems have "wandered" due to implicit seed changes affecting placement algorithm. Attempt to control that by restoring old seed value.
- SystemBodyData can now be copied by value for use in CustomSystemBody - SystemBody retains the same public interface.
- All data handled via SystemBodyData child - Per-member setters removed from StarSystemGenerator - Random rings now determined during CustomSystem load step
817cda3
to
47f484b
Compare
Rebased onto master (should now run in Win64 Debug), and refactored CustomSystemBody to use a new shared base class Still procrastinating on hooking up JSON custom systems to galaxy generation, but will try to get that done soonish. |
Yep that all works for me in Debug and Release 👍 |
I just tried again, on current state 47f484b. Got this trace, which I don't think amounts to much: GDB Log trace
|
@impaktor you're trying to run the editor, which a) isn't functional in this PR (only the system generation changes are available for testing here), and b) requires you to pass |
- Json Merge-Patch completely overwrites arrays rather than modifying them - Top-level keys in a .patch file starting with '$' can use Json Pointer semantics to refer to an object to modify - Patched values are applied using merge-patch semantics
- Migration path for old 02_local_stars.lua - CustomSystem definitions use nicer storage values for sector position - Loads full system definitions from systems/custom - Loads partial system definitions from systems/partial - Add example Json-based partial system def
Implemented all TODO items and migrated If no further issues arise on this PR, will most likely merge it by end-of-week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for inviting me to look at your code, it was very interesting and informative, and I managed to find a few things to pick on!
@Gliese852 thank you very much for the detailed and comprehensive review of the code! I'll make the appropriate changes to address the review feedback soon - I've left explanations/comments where needed; feel free to ask further questions if I've not answered something clearly / satisfactorily. |
- Fix some unintended divide-by-zero occurrences - Remove leftover code from debugging - Ensure system lawlessness value is correctly setup
I've addressed all review feedback comments except regarding the |
I've also added a few extra syllable fragments to the name generator lists in a very non-exhaustive fashion, which hopefully improve the uniqueness of generated system names slightly. (It also means we can generate systems named Dune now, which was impossible before.) |
This is a prerequisite PR for the system editor which happens to bring some nice standalone features to the table. I've significantly improved the way custom system definitions are loaded and used in system generation, made several opinionated changes to improve the results of system generation, and added JSON as the preferred format for loading custom systems.
Custom System Improvements:
I've mostly focused on reducing the amount of cruft and duplicated effort in custom system handling (as a natural consequence of adding an in-engine editor for custom system files). This results in reproducible round-trip loading and saving of custom system files (in JSON only) and reduces the amount of "knock on" changes tweaking a parameter has on random generation.
As part of this effort, all systems and bodies now receive a seed value for increased determinism in random generation instead of using the system or body index (which would create an implicit dependency on the rest of the sector or system). The number of randomly generated parameters in a system definition are reduced and responsibility for generating "missing" parameters in a Lua system definition file is now handled during the loading phase rather than the system generation phase. (Json files require that all parameters are specified and does not perform standalone generation.)
System Generation Changes:
SystemBodies are now responsible for calculating atmospheric parameters, moved from Planet.cpp. Additionally, SystemBody now has a proper parameterization for Argument of Periapsis, allowing it to fully express a proper orbit.
Bodies now generate in a more realistic fashion in an attempt to relax the behavior of cramming 5-10 gas giants within 5 AU of the primary star. Several scaling factors are applied to body generation, more satellites are generated around gas giants (referencing Jupiter), and a factor is applied to prevent extremely dense stars from generating large numbers of high-mass satellites in a very small orbit.
JSON Custom Systems:
As part of the system editor work, I've added a JSON-based format for loading and saving custom system definitions. This enables repeatable round-trip serialization, potentially higher performance with 100s of custom systems, and is a much easier and less bug-prone format for the engine to import and export. This comes at the cost of the ability to hand-edit the file (unless you want to do fixed-point format conversion by hand as well), though the files remain readable and easy to diff.
This new format makes Lua-based custom systems officially deprecated, as it is much better at representing all of the parameters that make up a system. (When compared to the Lua format, where 50% or more of body parameters were completely implicit and changed based on the order the system was loaded in.)
This new format is 100% fully editable with the upcoming System Editor, which provides a fully visual edit interface to adjust all parameters of a system, provides procedurally-assisted body generation, and can calculate derived parameters like surface gravity and atmosphere height in real-time. Plus undo. Who doesn't like undo?
Sneak peek:
2023-09-04.03-43-02.mp4
(MSAA has been added since...)
The JSON-based format is not end-user testable in this PR without the system editor - this code has been developed in the system editor branch however, and is reasonably bug-free.
TODO:
I'm requesting "review" from @fluffyfreak and @Gliese852 to take a quick look at the description and PR and let me know feedback/thoughts on the general direction. Overall, I'm pretty happy with the code quality and effect of the PR, but more eyes are always welcome!