From 5434305274a65ae54d71c89254de63c518368884 Mon Sep 17 00:00:00 2001 From: Vsevolod Kremianskii Date: Wed, 11 Nov 2020 14:34:11 +0700 Subject: [PATCH] feat: Add ability to print debug info on selected object --- src/game/object/area.cpp | 19 +++++++++++++++++++ src/game/object/area.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/game/object/area.cpp b/src/game/object/area.cpp index ecb7c5c5..4866817e 100644 --- a/src/game/object/area.cpp +++ b/src/game/object/area.cpp @@ -18,6 +18,7 @@ #include "area.h" #include +#include #include @@ -450,11 +451,29 @@ bool Area::handleKeyDown(const SDL_KeyboardEvent &event) { _objectSelector.selectNext(); return true; + case SDL_SCANCODE_SLASH: { + int objectId = _objectSelector.selectedObjectId(); + if (objectId != -1) { + shared_ptr object(find(objectId)); + printDebugInfo(*object); + } + return true; + } + default: return false; } } +void Area::printDebugInfo(const SpatialObject &object) { + ostringstream ss; + ss << boost::format("tag='%s'") % object.tag(); + ss << boost::format(",pos=[%0.2f,%0.2f,%0.2f]") % object.position().x % object.position().y % object.position().z; + ss << boost::format(",model='%s'") % object.model()->name(); + + debug("Selected object: " + ss.str()); +} + bool Area::getElevationAt(const glm::vec2 &position, const SpatialObject *except, Room *&room, float &z) const { RaycastProperties props; props.origin = glm::vec3(position, kElevationTestZ); diff --git a/src/game/object/area.h b/src/game/object/area.h index 071739ff..8b20884e 100644 --- a/src/game/object/area.h +++ b/src/game/object/area.h @@ -162,6 +162,8 @@ private: void updateVisibility(); void updateSounds(); + void printDebugInfo(const SpatialObject &object); + bool findCameraObstacle(const glm::vec3 &origin, const glm::vec3 &dest, glm::vec3 &intersection) const; bool findCreatureObstacle(const Creature &creature, const glm::vec3 &dest) const; bool getElevationAt(const glm::vec2 &position, const SpatialObject *except, Room *&room, float &z) const;