Skip to content

meshing movement and other stuff#11

Merged
dawc17 merged 3 commits into
masterfrom
dev
Mar 11, 2026
Merged

meshing movement and other stuff#11
dawc17 merged 3 commits into
masterfrom
dev

Conversation

@dawc17

@dawc17 dawc17 commented Mar 11, 2026

Copy link
Copy Markdown
Owner

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

  • The buildGreedyMesh function 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]
  • The JobSystem now pools MeshChunkJob objects, preserving vector capacity across uses and reducing heap allocations and buffer reallocation. The mesh job pool is managed via new acquireMeshJob and releaseMeshJob methods, which are integrated into the chunk meshing workflow. [1] [2] [3] [4]

Job System Threading and Performance

  • The job system now tracks pending jobs with an atomic counter, making pendingJobCount lock-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]
  • The job system's hasCompletedWork method is updated to check each result queue with its own mutex, improving concurrency and responsiveness.

Terrain Generation

  • The generateTerrain function now accepts an optional outTerrainHeights parameter, 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

  • The water simulator's findDistanceToHole method 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

  • Minor UI window position adjustments in imgui.ini and a small input handling tweak to prevent player movement when the inventory is open. [1] [2] [3]
  • Addition of a .claude/settings.local.json file with specific Bash command permissions.

dawc17 added 3 commits March 11, 2026 22:09
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.
@dawc17
dawc17 merged commit 19bf15b into master Mar 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant