Add wireframe toggle, InstancedMesh class, chunk managment, procedural generation, greedy mesher, and culling (face, back-face, frustum).#5
Conversation
…ork on the project the last 2 days was because I got a big flu on Sunday but I feel better now.
…eshing, frustum culling, back face culling
Review Summary by QodoAdd procedural terrain generation with chunk system, greedy meshing, and frustum culling
WalkthroughsDescription• Implement procedural terrain generation with chunk-based world system • Add greedy meshing algorithm for optimized mesh generation • Implement frustum culling for rendering performance optimization • Add wireframe toggle mode and back-face culling for rendering • Create InstancedMesh class for efficient instanced rendering Diagramflowchart LR
A["Engine"] -->|manages| B["ChunkManager"]
B -->|contains| C["Chunks"]
C -->|generates| D["Mesh via Greedy Meshing"]
B -->|applies| E["Frustum Culling"]
E -->|filters| F["Visible Chunks"]
F -->|renders| G["InstancedMesh"]
A -->|toggles| H["Wireframe Mode"]
A -->|enables| I["Back-face Culling"]
File Changes1. src/Core/Engine.cpp
|
Code Review by Qodo
1. Wireframe toggle GL calls inverted
|
| if (wireframeMode) { | ||
| glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||
| wireframeMode = false; | ||
| } else if (!wireframeMode) { | ||
| glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | ||
| wireframeMode = true; | ||
| } |
There was a problem hiding this comment.
1. Wireframe toggle gl calls inverted 🐞 Bug ✓ Correctness
When wireframeMode is true, the code calls glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) (wireframe) and then sets wireframeMode = false; when it is false, it calls GL_FILL (solid) and sets wireframeMode = true. The GL calls are swapped relative to the flag, so the first keypress applies GL_FILL (no visible change from default) and the second press activates wireframe — the toggle is delayed by one press and the feature is non-functional on first use.
Agent Prompt
## Issue description
The wireframe toggle in Engine.cpp has its OpenGL polygon mode calls swapped relative to the `wireframeMode` flag. When `wireframeMode` is `true` (wireframe is active), the code calls `GL_LINE` again instead of `GL_FILL` to turn it off, and vice versa.
## Issue Context
`wireframeMode` starts as `false` (solid fill is the default). The intent is: if currently in wireframe mode, switch to fill; if currently in fill mode, switch to wireframe.
## Fix Focus Areas
- src/Core/Engine.cpp[82-88]: Swap the `glPolygonMode` calls so that the `if (wireframeMode)` branch calls `GL_FILL` and the `else` branch calls `GL_LINE`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| void InstancedMesh::DrawInstanced(int count) { | ||
| glBindVertexArray(VAO); | ||
| glDrawElementsInstanced(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0, count); | ||
| glBindVertexArray(0); |
There was a problem hiding this comment.
2. Drawinstanced ignores stored instancecount 🐞 Bug ⛯ Reliability
InstancedMesh::DrawInstanced(int count) passes the caller-supplied count directly to glDrawElementsInstanced, completely ignoring the instanceCount member that was stored during SetData(). If a caller passes a count larger than the number of instance positions uploaded to the GPU, the GPU will read out-of-bounds from the instance VBO, causing undefined behavior or a GPU crash.
Agent Prompt
## Issue description
`DrawInstanced(int count)` ignores the `instanceCount` member set during `SetData()` and uses the caller-supplied `count` instead. This allows callers to accidentally pass an incorrect count, causing out-of-bounds GPU memory reads.
## Issue Context
The `instanceCount` member is correctly set in `SetData()` (InstancedMesh.cpp line 53) but is never used in `DrawInstanced`. The parameter name `instanceCount` in the public API (InstancedMesh.hpp line 16) shadows the private member.
## Fix Focus Areas
- src/Render/InstancedMesh.cpp[57-60]: Remove the `count` parameter and use `this->instanceCount` in the `glDrawElementsInstanced` call.
- src/Render/InstancedMesh.hpp[16-16]: Update the declaration to `void DrawInstanced()` (no parameter).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.