RigsofRods
Soft-body Physics Simulation
GUI_CollisionsDebug.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2022 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
24 
25 #pragma once
26 
27 #include "Collisions.h"
28 #include "ForwardDeclarations.h"
29 
30 #include <Ogre.h>
31 #include <vector>
32 #include "imgui.h"
33 
34 namespace RoR {
35 namespace GUI {
36 
39 {
40 public:
41  const ImVec4 COLOR_EVENTBOX = ImVec4(181/255.f, 51/255.f, 64/255.f, 1.f);
42  const ImVec4 COLOR_COLLMESH = ImVec4(209/255.f, 109/255.f, 44/255.f, 1.f);
43  const float WIDTH_DRAWDIST = 75.f;
44  const float DEFAULT_DRAWDIST = 200.f;
45 
46  void SetVisible(bool v);
47  bool IsVisible() const { return m_is_visible; }
48  bool IsHovered() const { return IsVisible() && m_is_hovered; }
49 
50  void Draw();
51  void CleanUp();
52 
53  // EVENTBOX
54  void SetDrawEventBoxes(bool val);
55  void AddCollisionBoxDebugMesh(collision_box_t const& coll_box);
56  void DrawCollisionBoxDebugText(collision_box_t const& coll_box);
57  Ogre::Vector3 GetCollBoxWorldPos(collision_box_t const& coll_box);
58  void ClearEventBoxVisuals();
59 
60  // COLLMESH
61  void SetDrawCollisionMeshes(bool val);
62  void AddCollisionMeshDebugMesh(collision_mesh_t const& coll_mesh);
63  void DrawCollisionMeshDebugText(collision_mesh_t const& coll_mesh);
65 
66  // CELL
67  void SetDrawCollisionCells(bool val);
69 
70 private:
71 
72  void DrawLabelAtWorldPos(std::string const& caption, Ogre::Vector3 const& world_pos, ImVec4 const& text_color);
74 
75  // EVENTBOX
76  std::vector<Ogre::SceneNode*> m_collision_boxes;
77  bool m_draw_collision_boxes = false;
79 
80  // COLLMESH
81  std::vector<Ogre::SceneNode*> m_collision_meshes;
84 
85  // CELL
86  std::vector<Ogre::SceneNode*> m_collision_cells;
87  Ogre::SceneNode* m_collision_grid_root = nullptr;
88  bool m_draw_collision_cells = false;
90  int m_cell_generator_distance_limit = 50; // meters from character, to reduce memory load.
91 
92  bool m_draw_labels = true;
93  bool m_labels_draw_types = true;
94  bool m_labels_draw_sources = true;
95  bool m_is_visible = false;
96  bool m_is_hovered = false;
97 };
98 
99 } // namespace GUI
100 } // namespace RoR
RoR::GUI::CollisionsDebug::m_collision_cells
std::vector< Ogre::SceneNode * > m_collision_cells
Definition: GUI_CollisionsDebug.h:86
RoR::GUI::CollisionsDebug::GenerateCellDebugMaterials
void GenerateCellDebugMaterials()
Definition: GUI_CollisionsDebug.cpp:408
ForwardDeclarations.h
Global forward declarations.
RoR::GUI::CollisionsDebug::m_collision_mesh_draw_distance
float m_collision_mesh_draw_distance
Definition: GUI_CollisionsDebug.h:83
RoR::GUI::CollisionsDebug::ClearEventBoxVisuals
void ClearEventBoxVisuals()
Definition: GUI_CollisionsDebug.cpp:532
RoR::collision_mesh_t
Records which collision triangles belong to which mesh.
Definition: Collisions.h:64
RoR::GUI::CollisionsDebug::SetDrawEventBoxes
void SetDrawEventBoxes(bool val)
Definition: GUI_CollisionsDebug.cpp:448
RoR::GUI::CollisionsDebug::m_is_visible
bool m_is_visible
Definition: GUI_CollisionsDebug.h:95
RoR::GUI::CollisionsDebug::m_labels_draw_sources
bool m_labels_draw_sources
Definition: GUI_CollisionsDebug.h:94
RoR::collision_box_t
Definition: SimData.h:714
RoR::GUI::CollisionsDebug::DrawCollisionBoxDebugText
void DrawCollisionBoxDebugText(collision_box_t const &coll_box)
Definition: GUI_CollisionsDebug.cpp:324
RoR::GUI::CollisionsDebug::ClearCollisionMeshVisuals
void ClearCollisionMeshVisuals()
Definition: GUI_CollisionsDebug.cpp:519
RoR::GUI::CollisionsDebug::m_collision_meshes
std::vector< Ogre::SceneNode * > m_collision_meshes
Definition: GUI_CollisionsDebug.h:81
RoR::GUI::CollisionsDebug::AddCollisionBoxDebugMesh
void AddCollisionBoxDebugMesh(collision_box_t const &coll_box)
Definition: GUI_CollisionsDebug.cpp:221
RoR::GUI::CollisionsDebug::DrawCollisionMeshDebugText
void DrawCollisionMeshDebugText(collision_mesh_t const &coll_mesh)
Definition: GUI_CollisionsDebug.cpp:309
RoR::GUI::CollisionsDebug::AddCollisionMeshDebugMesh
void AddCollisionMeshDebugMesh(collision_mesh_t const &coll_mesh)
Definition: GUI_CollisionsDebug.cpp:191
RoR::GUI::CollisionsDebug::ClearCollisionCellVisuals
void ClearCollisionCellVisuals()
Definition: GUI_CollisionsDebug.cpp:545
RoR::GUI::CollisionsDebug::COLOR_EVENTBOX
const ImVec4 COLOR_EVENTBOX
Definition: GUI_CollisionsDebug.h:41
RoR::GUI::CollisionsDebug::m_draw_collision_cells
bool m_draw_collision_cells
Definition: GUI_CollisionsDebug.h:88
RoR::GUI::CollisionsDebug::DEFAULT_DRAWDIST
const float DEFAULT_DRAWDIST
Definition: GUI_CollisionsDebug.h:44
RoR::GUI::CollisionsDebug::m_labels_draw_types
bool m_labels_draw_types
Definition: GUI_CollisionsDebug.h:93
RoR::GUI::CollisionsDebug::m_draw_labels
bool m_draw_labels
Definition: GUI_CollisionsDebug.h:92
RoR::GUI::CollisionsDebug::IsVisible
bool IsVisible() const
Definition: GUI_CollisionsDebug.h:47
RoR::GUI::CollisionsDebug::m_collision_cell_draw_distance
float m_collision_cell_draw_distance
Definition: GUI_CollisionsDebug.h:89
RoR::GUI::CollisionsDebug::m_collision_grid_root
Ogre::SceneNode * m_collision_grid_root
Definition: GUI_CollisionsDebug.h:87
RoR::GUI::CollisionsDebug::Draw
void Draw()
Definition: GUI_CollisionsDebug.cpp:42
RoR::GUI::CollisionsDebug::DrawLabelAtWorldPos
void DrawLabelAtWorldPos(std::string const &caption, Ogre::Vector3 const &world_pos, ImVec4 const &text_color)
Definition: GUI_CollisionsDebug.cpp:358
RoR::GUI::CollisionsDebug::m_cell_generator_distance_limit
int m_cell_generator_distance_limit
Definition: GUI_CollisionsDebug.h:90
RoR::GUI::CollisionsDebug::m_draw_collision_meshes
bool m_draw_collision_meshes
Definition: GUI_CollisionsDebug.h:82
RoR::GUI::CollisionsDebug::m_collision_box_draw_distance
float m_collision_box_draw_distance
Definition: GUI_CollisionsDebug.h:78
RoR::GUI::CollisionsDebug::m_draw_collision_boxes
bool m_draw_collision_boxes
Definition: GUI_CollisionsDebug.h:77
RoR::GUI::CollisionsDebug::COLOR_COLLMESH
const ImVec4 COLOR_COLLMESH
Definition: GUI_CollisionsDebug.h:42
RoR::GUI::CollisionsDebug::SetVisible
void SetVisible(bool v)
Definition: GUI_CollisionsDebug.cpp:564
RoR::GUI::CollisionsDebug
Diagnostic view for static terrain collisions and script event-boxes.
Definition: GUI_CollisionsDebug.h:38
RoR::GUI::CollisionsDebug::CleanUp
void CleanUp()
Definition: GUI_CollisionsDebug.cpp:396
RoR::GUI::CollisionsDebug::SetDrawCollisionMeshes
void SetDrawCollisionMeshes(bool val)
Definition: GUI_CollisionsDebug.cpp:467
RoR::GUI::CollisionsDebug::GetCollBoxWorldPos
Ogre::Vector3 GetCollBoxWorldPos(collision_box_t const &coll_box)
Definition: GUI_CollisionsDebug.cpp:304
Collisions.h
RoR::GUI::CollisionsDebug::WIDTH_DRAWDIST
const float WIDTH_DRAWDIST
Definition: GUI_CollisionsDebug.h:43
RoR::GUI::CollisionsDebug::IsHovered
bool IsHovered() const
Definition: GUI_CollisionsDebug.h:48
RoR::GUI::CollisionsDebug::SetDrawCollisionCells
void SetDrawCollisionCells(bool val)
Definition: GUI_CollisionsDebug.cpp:486
RoR::GUI::CollisionsDebug::m_collision_boxes
std::vector< Ogre::SceneNode * > m_collision_boxes
Definition: GUI_CollisionsDebug.h:76
RoR
Definition: AppContext.h:36
RoR::GUI::CollisionsDebug::m_is_hovered
bool m_is_hovered
Definition: GUI_CollisionsDebug.h:96