X Tutup
Skip to content

Make Sphere3D/Icosphere reserve space better#6067

Merged
fluffyfreak merged 4 commits intopioneerspacesim:masterfrom
fluffyfreak:sphere3d-reserve-better
Feb 25, 2025
Merged

Make Sphere3D/Icosphere reserve space better#6067
fluffyfreak merged 4 commits intopioneerspacesim:masterfrom
fluffyfreak:sphere3d-reserve-better

Conversation

@fluffyfreak
Copy link
Contributor

@fluffyfreak fluffyfreak commented Feb 11, 2025

Whilst doing something else I found that the Icosphere::Generate method wasn't reserving space for the indices it generates, and it was also miscalculating the number of vertices it would generate.

I spent some time trying to figure out a nifty formula to calculate those values and then realised I could just build a table of 11 entries for each of the valid subdivision we allow instead.

I have also increased the BaseSphere use of subdivision to 5 (from 4) for smoother atmospheres.

EDIT:
Made the BaseSphere::m_atmos into a static so it's only created once and used throughout the games lifetime instead of creating a new one for every single planet with an atmosphere. Making the icosphere generation faster is good, but avoiding doing it altogether is better still!

@fluffyfreak fluffyfreak added C++ code Rendering Everything related to rendering labels Feb 11, 2025
Copy link
Member

@sturnclaw sturnclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like this change, just one "side quest" thing I'd like to see tackled if you get time.

@fluffyfreak
Copy link
Contributor Author

Changing it based on the planets detail level ended up being quite involved so this now hits 11 files 🤷

@fluffyfreak fluffyfreak merged commit 979ab5f into pioneerspacesim:master Feb 25, 2025
4 checks passed
@fluffyfreak fluffyfreak deleted the sphere3d-reserve-better branch February 25, 2025 10:34
@sturnclaw
Copy link
Member

Whoops, I thought I had merged this already. My bad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ code Rendering Everything related to rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup