TanTanDev / binary_greedy_mesher_demo

Other
227 stars 29 forks source link

Remove padding early to reduce memory #6

Open duckdoom5 opened 4 months ago

duckdoom5 commented 4 months ago

You can remove the padding early to fit the culled faces into a u32, reducing the required memory even more. We can also update the colFaceMasks array to use CHUNK_SIZE, since the padded values are never used. We can even do the same for axisCols. We only need them to have a u64row value to store the two additional bits.

I also updated the voxel neighbours checking loop to remove the corner bits from being processed twice. Excuse the amount of code, I personally have it as a function with callback in c++, but I don't know how to do it in Rust.

Note: Did not try to compile nor test the rust version, sorry if it doesn't. (I can help fix it, if so.) I'm using c++, and have verified it works there!

mastamitche commented 1 week ago

Appreciate the thinking and application.

After I added this to my modified version it needed tweaking pretty significantly a few overflows and other issues but all in all great performance boost!

If anyone would like the rust version ping me.