Added
- New
ChunkCalculator
class for efficient chunk rendering decisions - Sodium compatibility layer (
SodiumCompatibility
andSodiumHooks
classes)
Changed
- Updated
Cobalt
main class to use newChunkCalculator
- Modified
ChunkRenderMixin
to work with new rendering logic
Improved
- Enhanced mod compatibility to work with and without Sodium
- Optimized chunk rendering process
Refactored
- Separated chunk calculation logic from main mod class
- Improved overall code structure and modularity
-
Thread Safety: Switched to
AtomicReference<BitSet>
for efficient chunk management. -
Executor Service: Set as daemon thread and limited to single task execution.
-
Performance: Reduced
Vec3d
objects and precomputed key values. -
Chunk Processing: Optimized loops and rendering logic based on player view.
Performance improvements
-
Replaced
AtomicReference<BitSet>
with avolatile BitSet
to enhance performance. -
Offloaded chunk calculations to a separate thread using
ExecutorService
.
Miscellaneous
-
Added a shutdown hook to gracefully terminate the executor service.
-
Implemented Javadoc-style comments for improved code readability and maintenance.
Performance Improvements
-
Efficient Data Structures: Switched from HashSet to BitSet for managing chunks to render, resulting in faster access times and reduced memory usage.
-
Streamlined Update Mechanisms: Implemented position and rotation thresholds to update chunk rendering only when significant player movement or rotation occurs, minimizing computational overhead.
-
Reduced Computational Load: Optimizations collectively lead to smoother performance without compromising visual fidelity, ensuring a more responsive and immersive gaming experience.
Performance Improvements
-
Precomputed Chunks for Rendering: Moved the calculation of which chunks to render from the mixin's shouldBuild method to the WorldRenderEvents.AFTER_ENTITIES event in the main mod class (Cobalt.java). This reduces per-chunk computation.
-
Thread-Safe Data Sharing: Introduced an AtomicReference<Set<ChunkPos>> named chunksToRender to safely share the set of chunks to render between threads.
-
Simplified shouldBuild Method: Updated the mixin (ChunkRenderMixin.java) to check if a chunk is in the precomputed chunksToRender set, eliminating heavy computations during chunk building.
-
Optimized Sight Line Calculations: Adjusted how chunks intersected by the player's view are calculated and included neighboring chunks for smoother transitions.
-
Code Cleanup: Removed unnecessary variables and methods, like lastRenderedTime, to streamline the code and enhance performance.