Re-namespaced VoxelDebug
parent
abcb307170
commit
14840634de
|
@ -811,7 +811,7 @@ void VoxelGraphEditor::update_range_analysis_gizmo() {
|
|||
const AABB aabb = _range_analysis_dialog->get_aabb();
|
||||
_debug_renderer.begin();
|
||||
_debug_renderer.draw_box(parent_transform * Transform3D(Basis().scaled(aabb.size), aabb.position),
|
||||
VoxelDebug::ID_VOXEL_GRAPH_DEBUG_BOUNDS);
|
||||
DebugColors::ID_VOXEL_GRAPH_DEBUG_BOUNDS);
|
||||
_debug_renderer.end();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ private:
|
|||
bool _nothing_selected_check_scheduled = false;
|
||||
float _time_before_preview_update = 0.f;
|
||||
Node3D *_voxel_node = nullptr;
|
||||
VoxelDebug::DebugRenderer _debug_renderer;
|
||||
zylann::DebugRenderer _debug_renderer;
|
||||
};
|
||||
|
||||
#endif // VOXEL_GRAPH_EDITOR_H
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
|
||||
#include <scene/resources/mesh.h>
|
||||
|
||||
using namespace zylann;
|
||||
namespace zylann {
|
||||
|
||||
namespace VoxelDebug {
|
||||
|
||||
FixedArray<Ref<Mesh>, ID_COUNT> g_wirecubes;
|
||||
FixedArray<Ref<Mesh>, DebugColors::ID_COUNT> g_wirecubes;
|
||||
bool g_finalized = false;
|
||||
|
||||
template <typename T>
|
||||
|
@ -18,15 +16,15 @@ void raw_copy_to(Vector<T> &dst, const T *src, unsigned int count) {
|
|||
memcpy(dst.ptrw(), src, count * sizeof(T));
|
||||
}
|
||||
|
||||
static Color get_color(ColorID id) {
|
||||
static Color get_color(DebugColors::ColorID id) {
|
||||
switch (id) {
|
||||
case ID_VOXEL_BOUNDS:
|
||||
case DebugColors::ID_VOXEL_BOUNDS:
|
||||
return Color(1, 1, 1);
|
||||
case ID_OCTREE_BOUNDS:
|
||||
case DebugColors::ID_OCTREE_BOUNDS:
|
||||
return Color(0.5, 0.5, 0.5);
|
||||
case ID_VOXEL_GRAPH_DEBUG_BOUNDS:
|
||||
case DebugColors::ID_VOXEL_GRAPH_DEBUG_BOUNDS:
|
||||
return Color(1.0, 1.0, 0.0);
|
||||
case ID_WHITE:
|
||||
case DebugColors::ID_WHITE:
|
||||
return Color(1, 1, 1);
|
||||
default:
|
||||
CRASH_NOW_MSG("Unexpected index");
|
||||
|
@ -34,7 +32,7 @@ static Color get_color(ColorID id) {
|
|||
return Color();
|
||||
}
|
||||
|
||||
Ref<Mesh> get_wirecube(ColorID id) {
|
||||
Ref<Mesh> get_debug_wirecube(DebugColors::ColorID id) {
|
||||
CRASH_COND(g_finalized);
|
||||
|
||||
Ref<Mesh> &wirecube = g_wirecubes[id];
|
||||
|
@ -99,7 +97,7 @@ Ref<Mesh> get_wirecube(ColorID id) {
|
|||
return wirecube;
|
||||
}
|
||||
|
||||
void free_resources() {
|
||||
void free_debug_resources() {
|
||||
for (unsigned int i = 0; i < g_wirecubes.size(); ++i) {
|
||||
g_wirecubes[i].unref();
|
||||
}
|
||||
|
@ -147,7 +145,7 @@ private:
|
|||
Transform3D _transform;
|
||||
bool _visible = true;
|
||||
Ref<Mesh> _mesh;
|
||||
DirectMeshInstance _mesh_instance;
|
||||
zylann::DirectMeshInstance _mesh_instance;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -180,7 +178,7 @@ void DebugRenderer::begin() {
|
|||
_mm_renderer.begin();
|
||||
}
|
||||
|
||||
void DebugRenderer::draw_box(const Transform3D &t, ColorID color) {
|
||||
void DebugRenderer::draw_box(const Transform3D &t, DebugColors::ColorID color) {
|
||||
// Pick an existing item, or create one
|
||||
DebugRendererItem *item;
|
||||
if (_current >= _items.size()) {
|
||||
|
@ -191,7 +189,7 @@ void DebugRenderer::draw_box(const Transform3D &t, ColorID color) {
|
|||
item = _items[_current];
|
||||
}
|
||||
|
||||
item->set_mesh(get_wirecube(color));
|
||||
item->set_mesh(get_debug_wirecube(color));
|
||||
item->set_transform(t);
|
||||
item->set_visible(true);
|
||||
|
||||
|
@ -222,7 +220,7 @@ DebugMultiMeshRenderer::DebugMultiMeshRenderer() {
|
|||
// It should be off anyways, but it's rather concerning.
|
||||
_multimesh_instance.set_cast_shadows_setting(RenderingServer::SHADOW_CASTING_SETTING_OFF);
|
||||
_multimesh.instantiate();
|
||||
Ref<Mesh> wirecube = get_wirecube(ID_WHITE);
|
||||
Ref<Mesh> wirecube = get_debug_wirecube(DebugColors::ID_WHITE);
|
||||
_multimesh->set_mesh(wirecube);
|
||||
_multimesh->set_transform_format(MultiMesh::TRANSFORM_3D);
|
||||
// TODO Optimize: Godot needs to bring back 8-bit color attributes on multimesh, 32-bit colors are too much
|
||||
|
@ -281,4 +279,4 @@ void DebugMultiMeshRenderer::clear() {
|
|||
_multimesh->set_instance_count(0);
|
||||
}
|
||||
|
||||
} // namespace VoxelDebug
|
||||
} // namespace zylann
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
#include <vector>
|
||||
|
||||
class Mesh;
|
||||
namespace zylann {
|
||||
class DirectMeshInstance;
|
||||
}
|
||||
class World3D;
|
||||
|
||||
namespace VoxelDebug {
|
||||
namespace zylann {
|
||||
|
||||
class DirectMeshInstance;
|
||||
|
||||
namespace DebugColors {
|
||||
|
||||
enum ColorID { //
|
||||
ID_VOXEL_BOUNDS = 0,
|
||||
|
@ -21,8 +22,10 @@ enum ColorID { //
|
|||
ID_COUNT
|
||||
};
|
||||
|
||||
Ref<Mesh> get_wirecube(ColorID id);
|
||||
void free_resources();
|
||||
} //namespace DebugColors
|
||||
|
||||
Ref<Mesh> get_debug_wirecube(DebugColors::ColorID id);
|
||||
void free_debug_resources();
|
||||
|
||||
class DebugMultiMeshRenderer {
|
||||
public:
|
||||
|
@ -31,7 +34,7 @@ public:
|
|||
|
||||
void set_world(World3D *world);
|
||||
void begin();
|
||||
void draw_box(const Transform3D &t, zylann::Color8 color);
|
||||
void draw_box(const Transform3D &t, Color8 color);
|
||||
void end();
|
||||
void clear();
|
||||
|
||||
|
@ -58,11 +61,11 @@ public:
|
|||
// Call this before issuing drawing commands
|
||||
void begin();
|
||||
|
||||
void draw_box(const Transform3D &t, ColorID color);
|
||||
void draw_box(const Transform3D &t, DebugColors::ColorID color);
|
||||
|
||||
// Draws a box wireframe using MultiMesh, allowing to draw much more without slowing down.
|
||||
// The box's origin is its lower corner. Size is defined by the transform's basis.
|
||||
void draw_box_mm(const Transform3D &t, zylann::Color8 color);
|
||||
void draw_box_mm(const Transform3D &t, Color8 color);
|
||||
|
||||
// Call this after issuing all drawing commands
|
||||
void end();
|
||||
|
@ -78,6 +81,6 @@ private:
|
|||
DebugMultiMeshRenderer _mm_renderer;
|
||||
};
|
||||
|
||||
} // namespace VoxelDebug
|
||||
} //namespace zylann
|
||||
|
||||
#endif // VOXEL_DEBUG_H
|
||||
|
|
|
@ -194,7 +194,7 @@ void unregister_voxel_types() {
|
|||
// TODO No remove?
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
VoxelDebug::free_resources();
|
||||
zylann::free_debug_resources();
|
||||
|
||||
// TODO Seriously, no remove?
|
||||
//EditorPlugins::remove_by_type<VoxelGraphEditorPlugin>();
|
||||
|
|
|
@ -206,7 +206,7 @@ private:
|
|||
VoxelLodTerrain *_parent;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
VoxelDebug::DebugRenderer _debug_renderer;
|
||||
zylann::DebugRenderer _debug_renderer;
|
||||
bool _gizmos_enabled = false;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -2781,7 +2781,7 @@ Array VoxelLodTerrain::debug_get_octrees_detailed() const {
|
|||
void VoxelLodTerrain::update_gizmos() {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
|
||||
VoxelDebug::DebugRenderer &dr = _debug_renderer;
|
||||
DebugRenderer &dr = _debug_renderer;
|
||||
dr.begin();
|
||||
|
||||
const Transform3D parent_transform = get_global_transform();
|
||||
|
@ -2792,7 +2792,7 @@ void VoxelLodTerrain::update_gizmos() {
|
|||
const Basis local_octree_basis = Basis().scaled(Vector3(octree_size, octree_size, octree_size));
|
||||
for (Map<Vector3i, OctreeItem>::Element *e = _lod_octrees.front(); e; e = e->next()) {
|
||||
const Transform3D local_transform(local_octree_basis, e->key() * octree_size);
|
||||
dr.draw_box(parent_transform * local_transform, VoxelDebug::ID_OCTREE_BOUNDS);
|
||||
dr.draw_box(parent_transform * local_transform, DebugColors::ID_OCTREE_BOUNDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2804,7 +2804,7 @@ void VoxelLodTerrain::update_gizmos() {
|
|||
const Vector3 size = _bounds_in_voxels.size;
|
||||
const Transform3D local_transform(
|
||||
Basis().scaled(size + margin * 2.f), Vector3(_bounds_in_voxels.pos) - margin);
|
||||
dr.draw_box(parent_transform * local_transform, VoxelDebug::ID_VOXEL_BOUNDS);
|
||||
dr.draw_box(parent_transform * local_transform, DebugColors::ID_VOXEL_BOUNDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -401,7 +401,7 @@ private:
|
|||
bool _show_octree_node_gizmos = false;
|
||||
bool _show_edited_blocks = false;
|
||||
unsigned int _edited_blocks_gizmos_lod_index = 0;
|
||||
VoxelDebug::DebugRenderer _debug_renderer;
|
||||
zylann::DebugRenderer _debug_renderer;
|
||||
#endif
|
||||
|
||||
Stats _stats;
|
||||
|
|
Loading…
Reference in New Issue