Conversation
Multiple engine improvements and optimizations: - Meshing: avoid oversized initial reserves by reserving only when capacity is too small; add a cached (CHUNK_SIZE+1)^2 corner-height table to avoid redundant getFluidHeight calls for water top-faces. - JobSystem: add MeshChunkJob pool (acquire/release) to reuse vector capacity and reduce heap allocations; add atomic pendingCount and per-result mutexes (generations/meshes/saves); increment/decrement pendingCount on enqueue/complete; make hasCompletedWork check each result queue with proper locking; return pendingJobCount via atomic. - Worker/queue changes: protect completed result pushes with the new per-queue mutexes and update pendingCount handling. - ChunkManager: use jobSystem->acquireMeshJob() when enqueueing mesh jobs and release jobs after processing. - TerrainGenerator: add optional outTerrainHeights parameter (filled row-major) and propagate it so generateTerrain computes heights once; applyCaves now uses the provided heights. - WaterSimulator: replace recursive findDistanceToHole with an iterative BFS-based search using a bounded visited grid (maxDepth parameter) to reduce exponential branching. - Misc: adjust a Debug window position in imgui.ini and add a local .claude/settings.local.json file containing permitted Bash commands for local usage. These changes reduce allocations, redundant work, and contention, improving mesh generation and job throughput.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several performance and memory optimizations across the meshing, job system, and terrain generation subsystems, as well as a significant optimization to the water simulation. It also includes some minor configuration and UI changes. The most important changes are grouped by theme below:
Meshing and Memory Efficiency
buildGreedyMeshfunction now reserves a more realistic starting size for its vertex and index buffers and introduces a cache for water corner heights, reducing redundant block reads and memory allocations during meshing. [1] [2] [3]JobSystemnow poolsMeshChunkJobobjects, preserving vector capacity across uses and reducing heap allocations and buffer reallocation. The mesh job pool is managed via newacquireMeshJobandreleaseMeshJobmethods, which are integrated into the chunk meshing workflow. [1] [2] [3] [4]Job System Threading and Performance
pendingJobCountlock-free and more efficient. Separate mutexes are used for each result queue (generationsMutex,meshesMutex,savesMutex) to reduce lock contention between different job types. [1] [2] [3]hasCompletedWorkmethod is updated to check each result queue with its own mutex, improving concurrency and responsiveness.Terrain Generation
generateTerrainfunction now accepts an optionaloutTerrainHeightsparameter, allowing terrain heights to be computed once and reused for cave carving, which avoids redundant noise calculations. The function signature and usage are updated throughout the codebase. [1] [2] [3] [4]Water Simulation Optimization
findDistanceToHolemethod is rewritten from a recursive approach to an iterative BFS using a flat visited grid and queue, greatly improving performance and stack safety for water edge searches.Miscellaneous
imgui.iniand a small input handling tweak to prevent player movement when the inventory is open. [1] [2] [3].claude/settings.local.jsonfile with specific Bash command permissions.