feat: Add ability to print debug info on selected object

This commit is contained in:
Vsevolod Kremianskii 2020-11-11 14:34:11 +07:00
parent 58358ce367
commit 5434305274
2 changed files with 21 additions and 0 deletions

View file

@ -18,6 +18,7 @@
#include "area.h"
#include <algorithm>
#include <sstream>
#include <boost/format.hpp>
@ -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<SpatialObject> 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);

View file

@ -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;