Worked on debugging and metadata stuff
This commit is contained in:
91
src/modules/stream/line_metadata_editor.cpp
Normal file
91
src/modules/stream/line_metadata_editor.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <scene/gui/item_list.h>
|
||||
#include <scene/gui/box_container.h>
|
||||
#include <scene/gui/spin_box.h>
|
||||
#include <scene/gui/grid_container.h>
|
||||
#include <scene/gui/label.h>
|
||||
#include "editor_event.h"
|
||||
#include "road_lines_data.h"
|
||||
#include "line_metadata_editor.h"
|
||||
|
||||
static ItemList *line_buildings_list;
|
||||
static ItemList *line_building_types_list;
|
||||
static SpinBox *line_segment_num;
|
||||
LineMetadataEditor::LineMetadataEditor()
|
||||
{
|
||||
}
|
||||
|
||||
LineMetadataEditor::~LineMetadataEditor()
|
||||
{
|
||||
if (line_buildings_list) {
|
||||
line_buildings_list->queue_delete();
|
||||
line_buildings_list = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void LineMetadataEditor::_notification(int which)
|
||||
{
|
||||
switch (which) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
VBoxContainer *box = memnew(VBoxContainer);
|
||||
line_buildings_list = memnew(ItemList);
|
||||
line_buildings_list->set_custom_minimum_size(
|
||||
Vector2(0.0f, 80.0f));
|
||||
box->add_child(line_buildings_list);
|
||||
line_buildings_list->set_owner(this);
|
||||
line_building_types_list = memnew(ItemList);
|
||||
line_building_types_list->set_custom_minimum_size(
|
||||
Vector2(0.0f, 80.0f));
|
||||
box->add_child(line_building_types_list);
|
||||
line_building_types_list->set_owner(this);
|
||||
GridContainer *grid = memnew(GridContainer);
|
||||
grid->set_columns(2);
|
||||
Label *label = memnew(Label);
|
||||
label->set_text("Segment:");
|
||||
grid->add_child(label);
|
||||
line_segment_num = memnew(SpinBox);
|
||||
grid->add_child(line_segment_num);
|
||||
box->add_child(grid);
|
||||
add_child(box);
|
||||
box->set_owner(this);
|
||||
line_buildings_list->set_owner(this);
|
||||
EditorEvent::get_singleton()->event.add_listener(
|
||||
this, &LineMetadataEditor::event_handler);
|
||||
Array args;
|
||||
EditorEvent::get_singleton()->event.emit(
|
||||
"lines_get_current_line", args);
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
EditorEvent::get_singleton()->event.remove_listener(
|
||||
this, &LineMetadataEditor::event_handler);
|
||||
if (line_buildings_list) {
|
||||
line_buildings_list->queue_delete();
|
||||
line_buildings_list = nullptr;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void LineMetadataEditor::_bind_methods()
|
||||
{
|
||||
}
|
||||
|
||||
void LineMetadataEditor::event_handler(const String &event, const Array &args)
|
||||
{
|
||||
if (event == "lines_select_line") {
|
||||
const String ¤t_line = args[0];
|
||||
print_line("line selected: " + current_line);
|
||||
#if 0
|
||||
if (current_line.ends_with("_buildings")) {
|
||||
int i;
|
||||
for (i = 0; i < u_controls.size(); i++)
|
||||
u_controls[i]->queue_delete();
|
||||
ItemList *item_list = memnew(ItemList);
|
||||
add_child RoadLinesData::get_singleton()
|
||||
-> lines[current_line]
|
||||
.metadata;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
15
src/modules/stream/line_metadata_editor.h
Normal file
15
src/modules/stream/line_metadata_editor.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <scene/gui/panel_container.h>
|
||||
#include "editor_event.h"
|
||||
|
||||
class LineMetadataEditor : public PanelContainer {
|
||||
GDCLASS(LineMetadataEditor, PanelContainer)
|
||||
public:
|
||||
LineMetadataEditor();
|
||||
virtual ~LineMetadataEditor();
|
||||
|
||||
private:
|
||||
Vector<Control *> u_controls;
|
||||
void _notification(int which);
|
||||
static void _bind_methods();
|
||||
void event_handler(const String &event, const Array &args);
|
||||
};
|
||||
@@ -36,6 +36,9 @@ void NavPanel::_notification(int which)
|
||||
add_child(h);
|
||||
add_child(v);
|
||||
add_child(r);
|
||||
h->set_focus_mode(Control::FOCUS_CLICK);
|
||||
v->set_focus_mode(Control::FOCUS_CLICK);
|
||||
r->set_focus_mode(Control::FOCUS_CLICK);
|
||||
h->connect("gui_input", this, "gui_input_handler_h");
|
||||
v->connect("gui_input", this, "gui_input_handler_v");
|
||||
r->connect("gui_input", this, "gui_input_handler_r");
|
||||
@@ -114,6 +117,7 @@ void NavPanel::gui_input_handler_h(const Ref<InputEvent> &e)
|
||||
{
|
||||
if (Input::get_singleton()->is_action_just_pressed("mouse1")) {
|
||||
h_active = true;
|
||||
h->grab_focus();
|
||||
Input::get_singleton()->set_mouse_mode(
|
||||
Input::MOUSE_MODE_CAPTURED);
|
||||
} else if (Input::get_singleton()->is_action_just_released("mouse1")) {
|
||||
@@ -140,6 +144,7 @@ void NavPanel::gui_input_handler_v(const Ref<InputEvent> &e)
|
||||
v_active = true;
|
||||
Input::get_singleton()->set_mouse_mode(
|
||||
Input::MOUSE_MODE_CAPTURED);
|
||||
v->grab_focus();
|
||||
} else if (Input::get_singleton()->is_action_just_released("mouse1")) {
|
||||
v_active = false;
|
||||
Input::get_singleton()->set_mouse_mode(
|
||||
@@ -167,6 +172,7 @@ void NavPanel::gui_input_handler_r(const Ref<InputEvent> &e)
|
||||
r_active = true;
|
||||
Input::get_singleton()->set_mouse_mode(
|
||||
Input::MOUSE_MODE_CAPTURED);
|
||||
r->grab_focus();
|
||||
|
||||
} else if (Input::get_singleton()->is_action_just_released("mouse1")) {
|
||||
r_active = false;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "road_debug.h"
|
||||
#include "world_editor.h"
|
||||
#include "nav_panel.h"
|
||||
#include "line_metadata_editor.h"
|
||||
|
||||
void register_stream_types()
|
||||
{
|
||||
@@ -10,6 +11,7 @@ void register_stream_types()
|
||||
ClassDB::register_class<RoadDebug>();
|
||||
ClassDB::register_class<WorldEditor>();
|
||||
ClassDB::register_class<NavPanel>();
|
||||
ClassDB::register_class<LineMetadataEditor>();
|
||||
}
|
||||
|
||||
void unregister_stream_types()
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "from_string.h"
|
||||
#include "road_lines_data.h"
|
||||
|
||||
static ImmediateGeometry *debug_im;
|
||||
ImmediateGeometry *RoadLinesData::debug_im = nullptr;
|
||||
static Ref<Material> debug_material;
|
||||
RoadLinesData::RoadLinesData()
|
||||
{
|
||||
@@ -73,10 +73,12 @@ RoadLinesData *RoadLinesData::get_singleton()
|
||||
|
||||
RoadLinesData::~RoadLinesData()
|
||||
{
|
||||
#if 0
|
||||
if (debug_im) {
|
||||
memdelete(debug_im);
|
||||
debug_im = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RoadLinesData::cleanup()
|
||||
@@ -159,7 +161,6 @@ uint32_t RoadLinesData::road_lines_hash(const Vector3 &v)
|
||||
int z = (int)(v.z / 100);
|
||||
return x ^ (y * 100) ^ (z * 10000);
|
||||
}
|
||||
|
||||
void RoadLinesData::road_lines_curve_index(
|
||||
struct RoadLinesData::road_line &rline,
|
||||
std::unordered_map<uint32_t, std::vector<Vector3> >
|
||||
@@ -454,20 +455,24 @@ void RoadLinesData::dump_road_lines(const std::vector<Vector3> &road_lines_nodes
|
||||
}
|
||||
}
|
||||
|
||||
static inline ImmediateGeometry *get_debug_node()
|
||||
ImmediateGeometry *RoadLinesData::get_debug_node()
|
||||
{
|
||||
debug_im = memnew(ImmediateGeometry);
|
||||
Ref<SpatialMaterial> tmpmat;
|
||||
tmpmat.instance();
|
||||
tmpmat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
|
||||
tmpmat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true);
|
||||
tmpmat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
debug_material = tmpmat;
|
||||
debug_im->set_material_override(debug_material);
|
||||
SceneTree::get_singleton()
|
||||
->get_current_scene()
|
||||
->get_viewport()
|
||||
->add_child(debug_im);
|
||||
if (!debug_im) {
|
||||
debug_im = memnew(ImmediateGeometry);
|
||||
Ref<SpatialMaterial> tmpmat;
|
||||
tmpmat.instance();
|
||||
tmpmat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,
|
||||
true);
|
||||
tmpmat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST,
|
||||
true);
|
||||
tmpmat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
debug_material = tmpmat;
|
||||
debug_im->set_material_override(debug_material);
|
||||
SceneTree::get_singleton()
|
||||
->get_current_scene()
|
||||
->get_viewport()
|
||||
->call_deferred("add_child", debug_im);
|
||||
}
|
||||
return debug_im;
|
||||
}
|
||||
|
||||
@@ -477,19 +482,35 @@ void RoadLinesData::process_lines(
|
||||
std::vector<Vector3> &road_lines_nodes)
|
||||
{
|
||||
int i;
|
||||
get_debug_node();
|
||||
debug_im->clear();
|
||||
get_debug_node()->clear();
|
||||
index_lines(road_lines_nodes_hash, road_lines_nodes);
|
||||
debug_im->begin(Mesh::PRIMITIVE_LINES);
|
||||
for (i = 0; i < (int)road_lines_nodes.size(); i++) {
|
||||
debug_im->set_color(Color(0.1f, 0.6f, 0.6f, 1.0f));
|
||||
debug_im->add_vertex(road_lines_nodes[i]);
|
||||
debug_im->set_color(Color(0.1f, 0.6f, 0.6f, 1.0f));
|
||||
debug_im->add_vertex(road_lines_nodes[i] +
|
||||
Vector3(0.0f, 200.0f, 0.0f));
|
||||
}
|
||||
debug_im->end();
|
||||
insert_close_points(road_lines_nodes, 160.0f);
|
||||
update_road_lines_nodes(road_lines_nodes);
|
||||
dump_road_lines(road_lines_nodes);
|
||||
if (debug_flags & 1) {
|
||||
get_debug_node()->begin(Mesh::PRIMITIVE_LINES);
|
||||
for (i = 0; i < (int)road_lines_nodes.size(); i++) {
|
||||
print_line("debug_node: " + itos(i) + " " +
|
||||
(road_lines_nodes[i].operator String()));
|
||||
get_debug_node()->set_color(
|
||||
Color(0.1f, 0.6f, 0.6f, 1.0f));
|
||||
get_debug_node()->add_vertex(road_lines_nodes[i]);
|
||||
get_debug_node()->set_color(
|
||||
Color(0.1f, 0.6f, 0.6f, 1.0f));
|
||||
get_debug_node()->add_vertex(
|
||||
road_lines_nodes[i] +
|
||||
Vector3(0.0f, 200.0f, 0.0f));
|
||||
}
|
||||
get_debug_node()->end();
|
||||
}
|
||||
}
|
||||
|
||||
void RoadLinesData::set_debug_flags(int debug_flags)
|
||||
{
|
||||
this->debug_flags = debug_flags;
|
||||
}
|
||||
|
||||
int RoadLinesData::get_debug_flags() const
|
||||
{
|
||||
return debug_flags;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#ifndef ROAD_LINES_DATA_H
|
||||
#define ROAD_LINES_DATA_H
|
||||
#include "callable.h"
|
||||
class ImmediateGeometry;
|
||||
class RoadLinesData {
|
||||
int debug_flags;
|
||||
String road_lines_path;
|
||||
uint32_t road_lines_hash(const Vector3 &v);
|
||||
static ImmediateGeometry *debug_im;
|
||||
static ImmediateGeometry *get_debug_node();
|
||||
|
||||
protected:
|
||||
RoadLinesData();
|
||||
@@ -30,6 +34,8 @@ public:
|
||||
void process_lines(std::unordered_map<uint32_t, std::vector<Vector3> >
|
||||
&road_lines_nodes_hash,
|
||||
std::vector<Vector3> &road_lines_nodes);
|
||||
void set_debug_flags(int debug_flags);
|
||||
int get_debug_flags() const;
|
||||
|
||||
private:
|
||||
void index_lines(std::unordered_map<uint32_t, std::vector<Vector3> >
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <core/os/time.h>
|
||||
#include <core/io/json.h>
|
||||
#include <modules/regex/regex.h>
|
||||
#include "editor_event.h"
|
||||
#include "world_editor.h"
|
||||
#include "from_string.h"
|
||||
#include "road_lines_data.h"
|
||||
@@ -157,6 +158,8 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
static String current_line = "";
|
||||
|
||||
class HandlePointSelection : public Object {
|
||||
GDCLASS(HandlePointSelection, Object)
|
||||
RoadLinesEditor *editor;
|
||||
@@ -286,6 +289,8 @@ public:
|
||||
protected:
|
||||
void update_metadata_editor()
|
||||
{
|
||||
if (current_line == "")
|
||||
return;
|
||||
TextEdit *metadata_edit = editor->get_as_node<TextEdit>(
|
||||
"%road_lines_metadata_edit");
|
||||
String text = editor->get_current_line_metadata();
|
||||
@@ -313,6 +318,10 @@ protected:
|
||||
break;
|
||||
case 23:
|
||||
/* edit line metadata */
|
||||
if (current_line == "") {
|
||||
print_error("No current line set");
|
||||
return;
|
||||
}
|
||||
editor->get_as_node<Control>("%road_lines_base")->hide();
|
||||
editor->get_as_node<Control>(
|
||||
"%road_lines_edit_metadata_dlg")
|
||||
@@ -340,6 +349,58 @@ protected:
|
||||
case 101:
|
||||
editor->save_data();
|
||||
break;
|
||||
case 201:
|
||||
case 210:
|
||||
case 211:
|
||||
case 212: {
|
||||
print_line("selected item 201");
|
||||
int i, j;
|
||||
Node *menu_block = editor->get_as_node<Node>(
|
||||
"%road_lines_menu_block");
|
||||
for (i = 0; i < menu_block->get_child_count(); i++) {
|
||||
Node *menu_button_node =
|
||||
menu_block->get_child(i);
|
||||
MenuButton *menu_button =
|
||||
Object::cast_to<MenuButton>(
|
||||
menu_button_node);
|
||||
if (!menu_button)
|
||||
continue;
|
||||
PopupMenu *popup = menu_button->get_popup();
|
||||
for (j = 0; j < popup->get_item_count(); j++) {
|
||||
int nid = popup->get_item_id(j);
|
||||
if (nid == id) {
|
||||
bool checked =
|
||||
popup->is_item_checked(
|
||||
j);
|
||||
if (checked)
|
||||
print_line("checked");
|
||||
else
|
||||
print_line("unchecked");
|
||||
checked = !checked;
|
||||
popup->set_item_checked(
|
||||
j, checked);
|
||||
switch (id) {
|
||||
case 201:
|
||||
editor->set_update_roads(
|
||||
checked);
|
||||
break;
|
||||
case 210:
|
||||
editor->set_debug_road_nodes(
|
||||
checked);
|
||||
break;
|
||||
case 211:
|
||||
editor->set_debug_road_edges(
|
||||
checked);
|
||||
break;
|
||||
case 212:
|
||||
editor->set_debug_road_wedges(
|
||||
checked);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
print_line("menu option pressed: " + itos(id));
|
||||
}
|
||||
@@ -467,6 +528,10 @@ RoadLinesEditor::RoadLinesEditor(WorldEditor *editor)
|
||||
, cursor_enabled(false)
|
||||
, filter_text("")
|
||||
, camera_moved(false)
|
||||
, update_roads(false)
|
||||
, debug_road_nodes(false)
|
||||
, debug_road_edges(false)
|
||||
, debug_road_wedges(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -483,7 +548,6 @@ Node *RoadLinesEditor::scene()
|
||||
return editor->get_tree()->get_current_scene();
|
||||
}
|
||||
|
||||
static String current_line = "";
|
||||
void RoadLinesEditor::update_line_geometry()
|
||||
{
|
||||
RoadLinesData *rld = RoadLinesData::get_singleton();
|
||||
@@ -553,6 +617,9 @@ void RoadLinesEditor::select_line(const String &line_name)
|
||||
set_line_index(0);
|
||||
update_line_geometry();
|
||||
}
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_select_line", args);
|
||||
update_ui();
|
||||
}
|
||||
|
||||
@@ -572,6 +639,9 @@ void RoadLinesEditor::line_create_point()
|
||||
int index = get_line_index();
|
||||
rld->lines[current_line].points.insert(
|
||||
rld->lines[current_line].points.begin() + index + 1, xform);
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line", args);
|
||||
update_line_geometry();
|
||||
update_line_index_ui();
|
||||
SpinBox *sp_line_index = get_as_node<SpinBox>("%line_index");
|
||||
@@ -589,6 +659,9 @@ void RoadLinesEditor::line_delete_point()
|
||||
return;
|
||||
rld->lines[current_line].points.erase(
|
||||
rld->lines[current_line].points.begin() + index);
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line", args);
|
||||
update_line_geometry();
|
||||
update_line_index_ui();
|
||||
SpinBox *sp_line_index = get_as_node<SpinBox>("%line_index");
|
||||
@@ -607,6 +680,9 @@ void RoadLinesEditor::set_point_to_cursor()
|
||||
Transform xform = cursor->get_global_transform();
|
||||
int index = get_line_index();
|
||||
rld->lines[current_line].points[index].origin = xform.origin;
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line", args);
|
||||
update_line_geometry();
|
||||
set_ui_point_position(rld->lines[current_line].points[index].origin);
|
||||
}
|
||||
@@ -798,6 +874,9 @@ void RoadLinesEditor::set_point_position(const Vector3 &position)
|
||||
RoadLinesData *rld = RoadLinesData::get_singleton();
|
||||
int index = get_line_index();
|
||||
rld->lines[current_line].points[index].origin = position;
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line", args);
|
||||
update_line_geometry();
|
||||
}
|
||||
void RoadLinesEditor::set_ui_cursor_position(const Vector3 &cursor_position)
|
||||
@@ -869,12 +948,16 @@ void RoadLinesEditor::activate()
|
||||
new_line_handler = memnew(HandleCreateNewLine(this));
|
||||
if (!point_selection_handler)
|
||||
point_selection_handler = memnew(HandlePointSelection(this));
|
||||
EditorEvent::get_singleton()->event.add_listener(
|
||||
this, &RoadLinesEditor::event_handler);
|
||||
|
||||
active = true;
|
||||
}
|
||||
|
||||
void RoadLinesEditor::deactivate()
|
||||
{
|
||||
EditorEvent::get_singleton()->event.remove_listener(
|
||||
this, &RoadLinesEditor::event_handler);
|
||||
Node *lines_list_node =
|
||||
editor->get_tree()->get_current_scene()->get_node(
|
||||
NodePath("%lines_list"));
|
||||
@@ -913,6 +996,15 @@ void RoadLinesEditor::place_generated_objects()
|
||||
void RoadLinesEditor::rebuild_roads()
|
||||
{
|
||||
Array args;
|
||||
int debug_flags = 0;
|
||||
if (debug_road_nodes)
|
||||
debug_flags |= (1 << 0);
|
||||
if (debug_road_edges)
|
||||
debug_flags |= (1 << 1);
|
||||
if (debug_road_wedges)
|
||||
debug_flags |= (1 << 2);
|
||||
print_line("rebuild_roads: debug: " + itos(debug_flags));
|
||||
args.push_back(debug_flags);
|
||||
editor->editor_command("rebuild_roads", args);
|
||||
}
|
||||
void RoadLinesEditor::remove_road_meshes()
|
||||
@@ -925,6 +1017,22 @@ void RoadLinesEditor::handle_input()
|
||||
if (editor->get_camera_mode() != 3)
|
||||
return;
|
||||
}
|
||||
void RoadLinesEditor::set_update_roads(bool checked)
|
||||
{
|
||||
update_roads = checked;
|
||||
}
|
||||
void RoadLinesEditor::set_debug_road_nodes(bool checked)
|
||||
{
|
||||
debug_road_nodes = checked;
|
||||
}
|
||||
void RoadLinesEditor::set_debug_road_edges(bool checked)
|
||||
{
|
||||
debug_road_edges = checked;
|
||||
}
|
||||
void RoadLinesEditor::set_debug_road_wedges(bool checked)
|
||||
{
|
||||
debug_road_wedges = checked;
|
||||
}
|
||||
void RoadLinesEditor::place_zebras()
|
||||
{
|
||||
Array args;
|
||||
@@ -1053,3 +1161,21 @@ template <class T> T *RoadLinesEditor::get_as_node(const String &path)
|
||||
assert(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RoadLinesEditor::event_handler(const String &event, const Array &args)
|
||||
{
|
||||
if (event == "lines_get_current_line" && current_line != "") {
|
||||
Array nargs;
|
||||
nargs.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_select_line",
|
||||
nargs);
|
||||
}
|
||||
if (event == "lines_changed_line") {
|
||||
if (!update_roads)
|
||||
print_line("road update disabled");
|
||||
if (current_line.ends_with("_road"))
|
||||
print_line("the line is a road");
|
||||
if (current_line.ends_with("_road") && update_roads)
|
||||
rebuild_roads();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ class RoadLinesEditor {
|
||||
Ref<RegEx> re;
|
||||
bool camera_moved;
|
||||
Vector3 camera_motion;
|
||||
void event_handler(const String &event, const Array &args);
|
||||
bool update_roads; // 201
|
||||
bool debug_road_nodes; // 210
|
||||
bool debug_road_edges; // 211
|
||||
bool debug_road_wedges; // 212
|
||||
|
||||
public:
|
||||
RoadLinesEditor(WorldEditor *editor);
|
||||
@@ -49,6 +54,10 @@ public:
|
||||
void rebuild_roads();
|
||||
void remove_road_meshes();
|
||||
void handle_input();
|
||||
void set_update_roads(bool checked);
|
||||
void set_debug_road_nodes(bool checked);
|
||||
void set_debug_road_edges(bool checked);
|
||||
void set_debug_road_wedges(bool checked);
|
||||
|
||||
protected:
|
||||
void activate();
|
||||
|
||||
@@ -34,6 +34,7 @@ struct RoadLinesProcessing {
|
||||
std::unordered_map<uint32_t, std::vector<struct wedge> > wedges;
|
||||
String road_center_mesh_path, road_mid_mesh_path,
|
||||
road_sidewalk_mesh_path;
|
||||
int debug_flags;
|
||||
static struct RoadLinesProcessing *singleton;
|
||||
static RoadLinesProcessing *get_singleton()
|
||||
{
|
||||
@@ -186,6 +187,14 @@ struct RoadLinesProcessing {
|
||||
singleton = nullptr;
|
||||
}
|
||||
}
|
||||
void set_debug_flags(int debug_flags)
|
||||
{
|
||||
this->debug_flags = debug_flags;
|
||||
}
|
||||
int get_debug_flags() const
|
||||
{
|
||||
return debug_flags;
|
||||
}
|
||||
void road_setup()
|
||||
{
|
||||
RoadLinesData *rld = RoadLinesData::get_singleton();
|
||||
@@ -194,6 +203,7 @@ struct RoadLinesProcessing {
|
||||
road_lines_nodes_hash;
|
||||
road_lines_nodes.clear();
|
||||
road_lines_nodes_hash.clear();
|
||||
rld->set_debug_flags(debug_flags);
|
||||
rld->process_lines(road_lines_nodes_hash, road_lines_nodes);
|
||||
create_nodes(road_lines_nodes);
|
||||
create_edges();
|
||||
@@ -631,8 +641,9 @@ public:
|
||||
};
|
||||
RoadMeshProcessing *RoadMeshProcessing::singleton;
|
||||
|
||||
void RoadProcessing::road_setup(Node *target)
|
||||
void RoadProcessing::road_setup(Node *target, int debug_flags)
|
||||
{
|
||||
RoadLinesProcessing::get_singleton()->set_debug_flags(debug_flags);
|
||||
RoadLinesProcessing::get_singleton()->road_setup();
|
||||
RoadMeshProcessing::get_singleton()->create_road_meshes(target);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ class Node;
|
||||
class ImmediateGeometry;
|
||||
class RoadProcessing {
|
||||
public:
|
||||
static void road_setup(Node *target);
|
||||
static void road_setup(Node *target, int debug_flags);
|
||||
static void remove_road_meshes(Node *target);
|
||||
static void load_data();
|
||||
static void cleanup();
|
||||
|
||||
@@ -398,7 +398,10 @@ void StreamWorld::run_command(const String &command, const Array &args)
|
||||
remove_generated_stuff();
|
||||
update_items();
|
||||
} else if (command == "rebuild_roads") {
|
||||
RoadProcessing::road_setup(this);
|
||||
if (args.size() > 0)
|
||||
RoadProcessing::road_setup(this, args[0]);
|
||||
else
|
||||
RoadProcessing::road_setup(this, 0);
|
||||
print_line("road_rebuild done");
|
||||
} else if (command == "remove_road_meshes") {
|
||||
RoadProcessing::remove_road_meshes(this);
|
||||
@@ -426,7 +429,7 @@ void StreamWorld::_notification(int which)
|
||||
current_scene = get_tree()->get_root();
|
||||
}
|
||||
ERR_FAIL_COND_MSG(!current_scene, "No current scene");
|
||||
RoadProcessing::road_setup(this);
|
||||
RoadProcessing::road_setup(this, 0);
|
||||
set_process(true);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user