From 56d47935845c312189fdc8a05f0bb08935632478 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Thu, 21 Dec 2023 17:34:33 -0500 Subject: don't set the debug hitbox to an entity without an instance --- editor/editor.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'editor') diff --git a/editor/editor.cpp b/editor/editor.cpp index f5e0d8d..5016070 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -229,12 +229,19 @@ void PkeEditor_Tick(double delta) { } EntityHandle focusedHandle = selectedEntity != EntityHandle_MAX ? selectedEntity : hoveredEntity; + bool found = false; if (focusedHandle != EntityHandle_MAX) { const auto *inst = ECS_GetInstance(focusedHandle); - const auto *grBinds = ECS_GetGrBinds(inst->grBindsHandle); - pkeDebugHitbox.instanceBuffer = grBinds->instanceBuffer; - pkeDebugHitbox.instanceStartingIndex = inst->index; - } else { + if (inst != nullptr) { + const auto *grBinds = ECS_GetGrBinds(inst->grBindsHandle); + if (grBinds != nullptr) { + pkeDebugHitbox.instanceBuffer = grBinds->instanceBuffer; + pkeDebugHitbox.instanceStartingIndex = inst->index; + found = true; + } + } + } + if (!found) { pkeDebugHitbox.instanceBuffer = VK_NULL_HANDLE; pkeDebugHitbox.instanceStartingIndex = 0; } -- cgit v1.2.3