ADD: BVH Selection ongoing
This commit is contained in:
@@ -466,6 +466,7 @@ void VulkanEngine::draw()
|
||||
_lastPick.mesh = picked.sourceMesh;
|
||||
_lastPick.scene = picked.sourceScene;
|
||||
_lastPick.worldPos = fallbackPos;
|
||||
_lastPick.worldTransform = picked.transform;
|
||||
_lastPick.firstIndex = picked.firstIndex;
|
||||
_lastPick.indexCount = picked.indexCount;
|
||||
_lastPick.surfaceIndex = picked.surfaceIndex;
|
||||
@@ -496,6 +497,7 @@ void VulkanEngine::draw()
|
||||
_hoverPick.mesh = hoverObj.sourceMesh;
|
||||
_hoverPick.scene = hoverObj.sourceScene;
|
||||
_hoverPick.worldPos = hoverPos;
|
||||
_hoverPick.worldTransform = hoverObj.transform;
|
||||
_hoverPick.firstIndex = hoverObj.firstIndex;
|
||||
_hoverPick.indexCount = hoverObj.indexCount;
|
||||
_hoverPick.surfaceIndex = hoverObj.surfaceIndex;
|
||||
@@ -816,6 +818,7 @@ void VulkanEngine::run()
|
||||
_lastPick.mesh = hitObject.sourceMesh;
|
||||
_lastPick.scene = hitObject.sourceScene;
|
||||
_lastPick.worldPos = hitPos;
|
||||
_lastPick.worldTransform = hitObject.transform;
|
||||
_lastPick.firstIndex = hitObject.firstIndex;
|
||||
_lastPick.indexCount = hitObject.indexCount;
|
||||
_lastPick.surfaceIndex = hitObject.surfaceIndex;
|
||||
@@ -851,6 +854,7 @@ void VulkanEngine::run()
|
||||
// Use bounds origin transformed to world as a representative point.
|
||||
glm::vec3 centerWorld = glm::vec3(obj.transform * glm::vec4(obj.bounds.origin, 1.0f));
|
||||
info.worldPos = centerWorld;
|
||||
info.worldTransform = obj.transform;
|
||||
info.firstIndex = obj.firstIndex;
|
||||
info.indexCount = obj.indexCount;
|
||||
info.surfaceIndex = obj.surfaceIndex;
|
||||
|
||||
@@ -121,6 +121,7 @@ public:
|
||||
MeshAsset *mesh = nullptr;
|
||||
LoadedGLTF *scene = nullptr;
|
||||
glm::vec3 worldPos{0.0f};
|
||||
glm::mat4 worldTransform{1.0f};
|
||||
uint32_t indexCount = 0;
|
||||
uint32_t firstIndex = 0;
|
||||
uint32_t surfaceIndex = 0;
|
||||
@@ -151,6 +152,8 @@ public:
|
||||
|
||||
// Toggle to enable/disable ID-buffer picking in addition to raycast
|
||||
bool _useIdBufferPicking = false;
|
||||
// Debug: draw mesh BVH boxes for last pick
|
||||
bool _debugDrawBVH = false;
|
||||
|
||||
// Debug: persistent pass enable overrides (by pass name)
|
||||
std::unordered_map<std::string, bool> _rgPassToggles;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "engine_context.h"
|
||||
#include <vk_types.h>
|
||||
|
||||
#include "mesh_bvh.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// Background / compute playground
|
||||
@@ -538,7 +540,9 @@ static void ui_scene(VulkanEngine *eng)
|
||||
ImGui::Text("Opaque draws: %zu", dc.OpaqueSurfaces.size());
|
||||
ImGui::Text("Transp draws: %zu", dc.TransparentSurfaces.size());
|
||||
ImGui::Checkbox("Use ID-buffer picking", &eng->_useIdBufferPicking);
|
||||
ImGui::Checkbox("Debug draw mesh BVH (last pick)", &eng->_debugDrawBVH);
|
||||
ImGui::Separator();
|
||||
|
||||
if (eng->_lastPick.valid)
|
||||
{
|
||||
const char *meshName = eng->_lastPick.mesh ? eng->_lastPick.mesh->name.c_str() : "<unknown>";
|
||||
@@ -556,6 +560,21 @@ static void ui_scene(VulkanEngine *eng)
|
||||
ImGui::Text("Indices: first=%u count=%u",
|
||||
eng->_lastPick.firstIndex,
|
||||
eng->_lastPick.indexCount);
|
||||
|
||||
if (eng->_sceneManager)
|
||||
{
|
||||
const SceneManager::PickingDebug &dbg = eng->_sceneManager->getPickingDebug();
|
||||
ImGui::Text("Mesh BVH used: %s, hit: %s, fallback box: %s",
|
||||
dbg.usedMeshBVH ? "yes" : "no",
|
||||
dbg.meshBVHHit ? "yes" : "no",
|
||||
dbg.meshBVHFallbackBox ? "yes" : "no");
|
||||
if (dbg.meshBVHPrimCount > 0)
|
||||
{
|
||||
ImGui::Text("Mesh BVH stats: prims=%u, nodes=%u",
|
||||
dbg.meshBVHPrimCount,
|
||||
dbg.meshBVHNodeCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user