Started mesh merging implementation
This commit is contained in:
@@ -28,40 +28,40 @@ static ImmediateGeometry *line_im = nullptr;
|
||||
// static ImmediateGeometry *debug_im = nullptr;
|
||||
static Ref<Material> debug_material;
|
||||
|
||||
#define __evhandler(vname, mtype) \
|
||||
template <class T> class GDEventHandler_##vname : public Object { \
|
||||
GDCLASS(GDEventHandler_##vname, Object) \
|
||||
T *obj; \
|
||||
\
|
||||
public: \
|
||||
GDEventHandler_##vname(T *obj) \
|
||||
: Object() \
|
||||
, obj(obj) \
|
||||
{ \
|
||||
} \
|
||||
virtual ~GDEventHandler_##vname() \
|
||||
{ \
|
||||
} \
|
||||
bool connect(Object *obj, const String &signal) \
|
||||
{ \
|
||||
return obj->connect(signal, this, "handler"); \
|
||||
} \
|
||||
void disconnect(Object *obj, const String &signal) \
|
||||
{ \
|
||||
obj->disconnect(signal, this, "handler"); \
|
||||
} \
|
||||
\
|
||||
protected: \
|
||||
void handler(const String &event, const Array &args) \
|
||||
{ \
|
||||
obj->vname(event, args); \
|
||||
} \
|
||||
static void _bind_methods() \
|
||||
{ \
|
||||
ClassDB::bind_method( \
|
||||
D_METHOD("handler", "args"), \
|
||||
&GDEventHandler_##vname::handler); \
|
||||
} \
|
||||
#define __evhandler(vname, mtype) \
|
||||
template <class T> class GDEventHandler_##vname : public Object { \
|
||||
GDCLASS(GDEventHandler_##vname, Object) \
|
||||
T *obj; \
|
||||
\
|
||||
public: \
|
||||
GDEventHandler_##vname(T *obj) \
|
||||
: Object() \
|
||||
, obj(obj) \
|
||||
{ \
|
||||
} \
|
||||
virtual ~GDEventHandler_##vname() \
|
||||
{ \
|
||||
} \
|
||||
bool connect(Object *obj, const String &signal) \
|
||||
{ \
|
||||
return obj->connect(signal, this, "handler"); \
|
||||
} \
|
||||
void disconnect(Object *obj, const String &signal) \
|
||||
{ \
|
||||
obj->disconnect(signal, this, "handler"); \
|
||||
} \
|
||||
\
|
||||
protected: \
|
||||
void handler(const String &event, const Vector<Variant> &args) \
|
||||
{ \
|
||||
obj->vname(event, args); \
|
||||
} \
|
||||
static void _bind_methods() \
|
||||
{ \
|
||||
ClassDB::bind_method( \
|
||||
D_METHOD("handler", "args"), \
|
||||
&GDEventHandler_##vname::handler); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define __evhandler_type(vname, mtype) GDEventHandler_##vname<mtype>
|
||||
@@ -704,9 +704,8 @@ 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);
|
||||
EditorEvent::get_singleton()->event.emit("lines_select_line",
|
||||
varray(current_line));
|
||||
update_ui();
|
||||
}
|
||||
|
||||
@@ -725,9 +724,8 @@ void RoadLinesEditor::line_create_point()
|
||||
Transform xform(Basis(), position);
|
||||
int index = get_line_index();
|
||||
rld->insert_line_point(current_line, index + 1, xform);
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line", args);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line",
|
||||
varray(current_line));
|
||||
update_line_geometry();
|
||||
update_line_index_ui();
|
||||
SpinBox *sp_line_index = get_as_node<SpinBox>("%line_index");
|
||||
@@ -744,9 +742,8 @@ void RoadLinesEditor::line_delete_point()
|
||||
if (rld->lines(current_line).points.size() < 2)
|
||||
return;
|
||||
rld->erase_line_point(current_line, index);
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line", args);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line",
|
||||
varray(current_line));
|
||||
update_line_geometry();
|
||||
update_line_index_ui();
|
||||
SpinBox *sp_line_index = get_as_node<SpinBox>("%line_index");
|
||||
@@ -765,9 +762,8 @@ void RoadLinesEditor::set_point_to_cursor()
|
||||
Transform xform = cursor->get_global_transform();
|
||||
int index = get_line_index();
|
||||
rld->set_line_point_position(current_line, index, xform.origin);
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line", args);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line",
|
||||
varray(current_line));
|
||||
update_line_geometry();
|
||||
set_ui_point_position(rld->lines(current_line).points[index].origin);
|
||||
}
|
||||
@@ -841,12 +837,14 @@ void RoadLinesEditor::exit()
|
||||
deactivate();
|
||||
}
|
||||
|
||||
void RoadLinesEditor::editor_command(const String &command, const Array &args)
|
||||
void RoadLinesEditor::editor_command(const String &command,
|
||||
const Vector<Variant> &args)
|
||||
{
|
||||
print_line("command: " + command);
|
||||
}
|
||||
|
||||
void RoadLinesEditor::editor_event(const String &event, const Array &args)
|
||||
void RoadLinesEditor::editor_event(const String &event,
|
||||
const Vector<Variant> &args)
|
||||
{
|
||||
print_line("RoadLinesEditor::event: " + event);
|
||||
if (event == "mouse_press" || event == "mouse_drag") {
|
||||
@@ -974,9 +972,8 @@ void RoadLinesEditor::set_point_position(const Vector3 &position)
|
||||
RoadLinesData *rld = RoadLinesData::get_singleton();
|
||||
int index = get_line_index();
|
||||
rld->set_line_point_position(current_line, index, position);
|
||||
Array args;
|
||||
args.push_back(current_line);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line", args);
|
||||
EditorEvent::get_singleton()->event.emit("lines_changed_line",
|
||||
varray(current_line));
|
||||
update_line_geometry();
|
||||
}
|
||||
void RoadLinesEditor::set_ui_cursor_position(const Vector3 &cursor_position)
|
||||
@@ -1095,7 +1092,6 @@ void RoadLinesEditor::place_generated_objects()
|
||||
}
|
||||
void RoadLinesEditor::rebuild_roads()
|
||||
{
|
||||
Array args;
|
||||
int debug_flags = 0;
|
||||
if (debug_road_nodes)
|
||||
debug_flags |= (1 << 0);
|
||||
@@ -1104,13 +1100,11 @@ void RoadLinesEditor::rebuild_roads()
|
||||
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);
|
||||
editor->editor_command("rebuild_roads", varray(debug_flags));
|
||||
}
|
||||
void RoadLinesEditor::remove_road_meshes()
|
||||
{
|
||||
Array args;
|
||||
editor->editor_command("remove_road_meshes", args);
|
||||
editor->editor_command("remove_road_meshes", varray());
|
||||
}
|
||||
void RoadLinesEditor::handle_input()
|
||||
{
|
||||
@@ -1135,9 +1129,7 @@ void RoadLinesEditor::set_debug_road_wedges(bool checked)
|
||||
}
|
||||
void RoadLinesEditor::place_zebras()
|
||||
{
|
||||
Array args;
|
||||
args.push_back("zebra");
|
||||
editor->editor_command("remove_buildings_by_prefix", args);
|
||||
editor->editor_command("remove_buildings_by_prefix", varray("zebra"));
|
||||
/*
|
||||
func place_zebras():
|
||||
var road_nodes = SceneComps.get_component("road_nodes2")
|
||||
@@ -1250,8 +1242,7 @@ String RoadLinesEditor::get_current_line_metadata() const
|
||||
}
|
||||
void RoadLinesEditor::remove_generated_stuff()
|
||||
{
|
||||
Array args;
|
||||
editor->editor_command("remove_generated_stuff", args);
|
||||
editor->editor_command("remove_generated_stuff", varray());
|
||||
}
|
||||
template <class T> T *RoadLinesEditor::get_as_node(const String &path)
|
||||
{
|
||||
@@ -1262,13 +1253,12 @@ template <class T> T *RoadLinesEditor::get_as_node(const String &path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RoadLinesEditor::event_handler(const String &event, const Array &args)
|
||||
void RoadLinesEditor::event_handler(const String &event,
|
||||
const Vector<Variant> &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);
|
||||
varray(current_line));
|
||||
}
|
||||
if (event == "lines_changed_line") {
|
||||
if (!update_roads)
|
||||
|
||||
Reference in New Issue
Block a user