Fixes drawing of the 2D plugins on the 3D view
This commit is contained in:
parent
f148e8eede
commit
5172642c32
18 changed files with 100 additions and 70 deletions
|
@ -5928,17 +5928,31 @@ bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp
|
|||
return discard;
|
||||
}
|
||||
|
||||
void EditorPluginList::forward_draw_over_viewport(Control *p_overlay) {
|
||||
void EditorPluginList::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
for (int i = 0; i < plugins_list.size(); i++) {
|
||||
plugins_list[i]->forward_draw_over_viewport(p_overlay);
|
||||
plugins_list[i]->forward_canvas_draw_over_viewport(p_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPluginList::forward_force_draw_over_viewport(Control *p_overlay) {
|
||||
void EditorPluginList::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
for (int i = 0; i < plugins_list.size(); i++) {
|
||||
plugins_list[i]->forward_force_draw_over_viewport(p_overlay);
|
||||
plugins_list[i]->forward_canvas_force_draw_over_viewport(p_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPluginList::forward_spatial_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
for (int i = 0; i < plugins_list.size(); i++) {
|
||||
plugins_list[i]->forward_spatial_draw_over_viewport(p_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPluginList::forward_spatial_force_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
for (int i = 0; i < plugins_list.size(); i++) {
|
||||
plugins_list[i]->forward_spatial_force_draw_over_viewport(p_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -812,9 +812,11 @@ public:
|
|||
void make_visible(bool p_visible);
|
||||
void edit(Object *p_object);
|
||||
bool forward_gui_input(const Ref<InputEvent> &p_event);
|
||||
void forward_canvas_draw_over_viewport(Control *p_overlay);
|
||||
void forward_canvas_force_draw_over_viewport(Control *p_overlay);
|
||||
bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
|
||||
void forward_draw_over_viewport(Control *p_overlay);
|
||||
void forward_force_draw_over_viewport(Control *p_overlay);
|
||||
void forward_spatial_draw_over_viewport(Control *p_overlay);
|
||||
void forward_spatial_force_draw_over_viewport(Control *p_overlay);
|
||||
void add_plugin(EditorPlugin *p_plugin);
|
||||
void clear();
|
||||
bool empty();
|
||||
|
|
|
@ -503,17 +503,17 @@ bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void EditorPlugin::forward_draw_over_viewport(Control *p_overlay) {
|
||||
void EditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (get_script_instance() && get_script_instance()->has_method("forward_draw_over_viewport")) {
|
||||
get_script_instance()->call("forward_draw_over_viewport", p_overlay);
|
||||
if (get_script_instance() && get_script_instance()->has_method("forward_canvas_draw_over_viewport")) {
|
||||
get_script_instance()->call("forward_canvas_draw_over_viewport", p_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPlugin::forward_force_draw_over_viewport(Control *p_overlay) {
|
||||
void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (get_script_instance() && get_script_instance()->has_method("forward_force_draw_over_viewport")) {
|
||||
get_script_instance()->call("forward_force_draw_over_viewport", p_overlay);
|
||||
if (get_script_instance() && get_script_instance()->has_method("forward_canvas_force_draw_over_viewport")) {
|
||||
get_script_instance()->call("forward_canvas_force_draw_over_viewport", p_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,6 +545,20 @@ bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEv
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_draw_over_viewport")) {
|
||||
get_script_instance()->call("forward_spatial_draw_over_viewport", p_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPlugin::forward_spatial_force_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_force_draw_over_viewport")) {
|
||||
get_script_instance()->call("forward_spatial_force_draw_over_viewport", p_overlay);
|
||||
}
|
||||
}
|
||||
String EditorPlugin::get_name() const {
|
||||
|
||||
if (get_script_instance() && get_script_instance()->has_method("get_plugin_name")) {
|
||||
|
@ -769,8 +783,8 @@ void EditorPlugin::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_script_create_dialog"), &EditorPlugin::get_script_create_dialog);
|
||||
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::OBJECT, "get_plugin_icon"));
|
||||
|
|
|
@ -174,9 +174,13 @@ public:
|
|||
void notify_resource_saved(const Ref<Resource> &p_resource);
|
||||
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event);
|
||||
virtual void forward_draw_over_viewport(Control *p_overlay);
|
||||
virtual void forward_force_draw_over_viewport(Control *p_overlay);
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay);
|
||||
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay);
|
||||
|
||||
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
|
||||
virtual void forward_spatial_draw_over_viewport(Control *p_overlay);
|
||||
virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay);
|
||||
|
||||
virtual String get_name() const;
|
||||
virtual const Ref<Texture> get_icon() const;
|
||||
virtual bool has_main_screen() const;
|
||||
|
|
|
@ -512,12 +512,10 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
|
|||
return false;
|
||||
}
|
||||
|
||||
void AbstractPolygon2DEditor::forward_draw_over_viewport(Control *p_overlay) {
|
||||
void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
if (!_get_node())
|
||||
return;
|
||||
|
||||
Control *vpc = canvas_item_editor->get_viewport_control();
|
||||
|
||||
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
|
||||
const Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
|
||||
|
||||
|
@ -558,7 +556,7 @@ void AbstractPolygon2DEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
Vector2 point = xform.xform(p);
|
||||
Vector2 next_point = xform.xform(p2);
|
||||
|
||||
vpc->draw_line(point, next_point, col, 2 * EDSCALE);
|
||||
p_overlay->draw_line(point, next_point, col, 2 * EDSCALE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,7 +580,7 @@ void AbstractPolygon2DEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
p2 = points[(i + 1) % n_points] + offset;
|
||||
|
||||
const Vector2 next_point = xform.xform(p2);
|
||||
vpc->draw_line(point, next_point, col, 2 * EDSCALE);
|
||||
p_overlay->draw_line(point, next_point, col, 2 * EDSCALE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,14 +592,14 @@ void AbstractPolygon2DEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
const Vector2 point = xform.xform(p);
|
||||
|
||||
const Color modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1);
|
||||
vpc->draw_texture(handle, point - handle->get_size() * 0.5, modulate);
|
||||
p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, modulate);
|
||||
}
|
||||
}
|
||||
|
||||
if (edge_point.valid()) {
|
||||
|
||||
Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
|
||||
vpc->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5);
|
||||
p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ protected:
|
|||
|
||||
public:
|
||||
bool forward_gui_input(const Ref<InputEvent> &p_event);
|
||||
void forward_draw_over_viewport(Control *p_overlay);
|
||||
void forward_canvas_draw_over_viewport(Control *p_overlay);
|
||||
|
||||
void edit(Node *p_polygon);
|
||||
AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wip_destructive = true);
|
||||
|
@ -153,7 +153,7 @@ class AbstractPolygon2DEditorPlugin : public EditorPlugin {
|
|||
|
||||
public:
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return polygon_editor->forward_gui_input(p_event); }
|
||||
virtual void forward_draw_over_viewport(Control *p_overlay) { polygon_editor->forward_draw_over_viewport(p_overlay); }
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { polygon_editor->forward_canvas_draw_over_viewport(p_overlay); }
|
||||
|
||||
bool has_main_screen() const { return false; }
|
||||
virtual String get_name() const { return klass; }
|
||||
|
|
|
@ -908,7 +908,7 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
|
|||
}
|
||||
}
|
||||
|
||||
void AnimationPlayerEditor::forward_force_draw_over_viewport(Control *p_overlay) {
|
||||
void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (!onion.can_overlay)
|
||||
return;
|
||||
|
|
|
@ -246,7 +246,7 @@ public:
|
|||
|
||||
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
|
||||
void edit(AnimationPlayer *p_player);
|
||||
void forward_force_draw_over_viewport(Control *p_overlay);
|
||||
void forward_canvas_force_draw_over_viewport(Control *p_overlay);
|
||||
|
||||
AnimationPlayerEditor(EditorNode *p_editor, AnimationPlayerEditorPlugin *p_plugin);
|
||||
};
|
||||
|
@ -271,7 +271,7 @@ public:
|
|||
virtual bool handles(Object *p_object) const;
|
||||
virtual void make_visible(bool p_visible);
|
||||
|
||||
virtual void forward_force_draw_over_viewport(Control *p_overlay) { anim_editor->forward_force_draw_over_viewport(p_overlay); }
|
||||
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay) { anim_editor->forward_canvas_force_draw_over_viewport(p_overlay); }
|
||||
|
||||
AnimationPlayerEditorPlugin(EditorNode *p_node);
|
||||
~AnimationPlayerEditorPlugin();
|
||||
|
|
|
@ -3018,6 +3018,7 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) {
|
|||
}
|
||||
|
||||
void CanvasItemEditor::_draw_viewport() {
|
||||
|
||||
// Update the transform
|
||||
transform = Transform2D();
|
||||
transform.scale_basis(Size2(zoom, zoom));
|
||||
|
@ -3066,11 +3067,11 @@ void CanvasItemEditor::_draw_viewport() {
|
|||
|
||||
EditorPluginList *over_plugin_list = editor->get_editor_plugins_over();
|
||||
if (!over_plugin_list->empty()) {
|
||||
over_plugin_list->forward_draw_over_viewport(viewport);
|
||||
over_plugin_list->forward_canvas_draw_over_viewport(viewport);
|
||||
}
|
||||
EditorPluginList *force_over_plugin_list = editor->get_editor_plugins_force_over();
|
||||
if (!force_over_plugin_list->empty()) {
|
||||
force_over_plugin_list->forward_force_draw_over_viewport(viewport);
|
||||
force_over_plugin_list->forward_canvas_force_draw_over_viewport(viewport);
|
||||
}
|
||||
|
||||
_draw_bones();
|
||||
|
|
|
@ -415,7 +415,7 @@ void CollisionShape2DEditor::_get_current_shape_type() {
|
|||
canvas_item_editor->get_viewport_control()->update();
|
||||
}
|
||||
|
||||
void CollisionShape2DEditor::forward_draw_over_viewport(Control *p_overlay) {
|
||||
void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (!node) {
|
||||
return;
|
||||
|
|
|
@ -75,7 +75,7 @@ protected:
|
|||
|
||||
public:
|
||||
bool forward_canvas_gui_input(const Ref<InputEvent> &p_event);
|
||||
void forward_draw_over_viewport(Control *p_overlay);
|
||||
void forward_canvas_draw_over_viewport(Control *p_overlay);
|
||||
void edit(Node *p_node);
|
||||
|
||||
CollisionShape2DEditor(EditorNode *p_editor);
|
||||
|
@ -89,7 +89,7 @@ class CollisionShape2DEditorPlugin : public EditorPlugin {
|
|||
|
||||
public:
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return collision_shape_2d_editor->forward_canvas_gui_input(p_event); }
|
||||
virtual void forward_draw_over_viewport(Control *p_overlay) { return collision_shape_2d_editor->forward_draw_over_viewport(p_overlay); }
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return collision_shape_2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
|
||||
|
||||
virtual String get_name() const { return "CollisionShape2D"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
|
|
|
@ -319,13 +319,11 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void LightOccluder2DEditor::forward_draw_over_viewport(Control *p_overlay) {
|
||||
void LightOccluder2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (!node || !node->get_occluder_polygon().is_valid())
|
||||
return;
|
||||
|
||||
Control *vpc = canvas_item_editor->get_viewport_control();
|
||||
|
||||
Vector<Vector2> poly;
|
||||
|
||||
if (wip_active)
|
||||
|
@ -353,9 +351,9 @@ void LightOccluder2DEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
if (i == poly.size() - 1 && (!node->get_occluder_polygon()->is_closed() || wip_active)) {
|
||||
|
||||
} else {
|
||||
vpc->draw_line(point, next_point, col, 2);
|
||||
p_overlay->draw_line(point, next_point, col, 2);
|
||||
}
|
||||
vpc->draw_texture(handle, point - handle->get_size() * 0.5);
|
||||
p_overlay->draw_texture(handle, point - handle->get_size() * 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ protected:
|
|||
|
||||
public:
|
||||
Vector2 snap_point(const Vector2 &p_point) const;
|
||||
void forward_draw_over_viewport(Control *p_overlay);
|
||||
void forward_canvas_draw_over_viewport(Control *p_overlay);
|
||||
bool forward_gui_input(const Ref<InputEvent> &p_event);
|
||||
void edit(Node *p_collision_polygon);
|
||||
LightOccluder2DEditor(EditorNode *p_editor);
|
||||
|
@ -98,7 +98,7 @@ class LightOccluder2DEditorPlugin : public EditorPlugin {
|
|||
|
||||
public:
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return light_occluder_editor->forward_gui_input(p_event); }
|
||||
virtual void forward_draw_over_viewport(Control *p_overlay) { return light_occluder_editor->forward_draw_over_viewport(p_overlay); }
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return light_occluder_editor->forward_canvas_draw_over_viewport(p_overlay); }
|
||||
|
||||
virtual String get_name() const { return "LightOccluder2D"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
|
|
|
@ -288,7 +288,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void Path2DEditor::forward_draw_over_viewport(Control *p_overlay) {
|
||||
void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (!node)
|
||||
return;
|
||||
|
|
|
@ -107,7 +107,7 @@ protected:
|
|||
|
||||
public:
|
||||
bool forward_gui_input(const Ref<InputEvent> &p_event);
|
||||
void forward_draw_over_viewport(Control *p_overlay);
|
||||
void forward_canvas_draw_over_viewport(Control *p_overlay);
|
||||
void edit(Node *p_path2d);
|
||||
Path2DEditor(EditorNode *p_editor);
|
||||
};
|
||||
|
@ -121,7 +121,7 @@ class Path2DEditorPlugin : public EditorPlugin {
|
|||
|
||||
public:
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return path2d_editor->forward_gui_input(p_event); }
|
||||
virtual void forward_draw_over_viewport(Control *p_overlay) { return path2d_editor->forward_draw_over_viewport(p_overlay); }
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return path2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
|
||||
|
||||
virtual String get_name() const { return "Path2D"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
|
|
|
@ -2312,12 +2312,12 @@ void SpatialEditorViewport::_draw() {
|
|||
|
||||
EditorPluginList *over_plugin_list = EditorNode::get_singleton()->get_editor_plugins_over();
|
||||
if (!over_plugin_list->empty()) {
|
||||
over_plugin_list->forward_draw_over_viewport(surface);
|
||||
over_plugin_list->forward_spatial_draw_over_viewport(surface);
|
||||
}
|
||||
|
||||
EditorPluginList *force_over_plugin_list = editor->get_editor_plugins_force_over();
|
||||
if (!force_over_plugin_list->empty()) {
|
||||
force_over_plugin_list->forward_force_draw_over_viewport(surface);
|
||||
force_over_plugin_list->forward_spatial_force_draw_over_viewport(surface);
|
||||
}
|
||||
|
||||
if (surface->has_focus()) {
|
||||
|
@ -2346,7 +2346,6 @@ void SpatialEditorViewport::_draw() {
|
|||
Point2 center = _point_to_screen(_edit.center);
|
||||
VisualServer::get_singleton()->canvas_item_add_line(ci, _edit.mouse_pos, center, Color(0.4, 0.7, 1.0, 0.8));
|
||||
}
|
||||
|
||||
if (previewing) {
|
||||
|
||||
Size2 ss = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
|
||||
|
|
|
@ -686,7 +686,7 @@ void TileMapEditor::_erase_selection() {
|
|||
}
|
||||
}
|
||||
|
||||
void TileMapEditor::_draw_cell(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform) {
|
||||
void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform) {
|
||||
|
||||
Ref<Texture> t = node->get_tileset()->tile_get_texture(p_cell);
|
||||
|
||||
|
@ -783,19 +783,19 @@ void TileMapEditor::_draw_cell(int p_cell, const Point2i &p_point, bool p_flip_h
|
|||
modulate.a = 0.5;
|
||||
|
||||
if (r.has_no_area())
|
||||
canvas_item_editor->draw_texture_rect(t, rect, false, modulate, p_transpose);
|
||||
p_viewport->draw_texture_rect(t, rect, false, modulate, p_transpose);
|
||||
else
|
||||
canvas_item_editor->draw_texture_rect_region(t, rect, r, modulate, p_transpose);
|
||||
p_viewport->draw_texture_rect_region(t, rect, r, modulate, p_transpose);
|
||||
}
|
||||
|
||||
void TileMapEditor::_draw_fill_preview(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform) {
|
||||
void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform) {
|
||||
|
||||
PoolVector<Vector2> points = _bucket_fill(p_point, false, true);
|
||||
PoolVector<Vector2>::Read pr = points.read();
|
||||
int len = points.size();
|
||||
|
||||
for (int i = 0; i < len; ++i) {
|
||||
_draw_cell(p_cell, pr[i], p_flip_h, p_flip_v, p_transpose, p_xform);
|
||||
_draw_cell(p_viewport, p_cell, pr[i], p_flip_h, p_flip_v, p_transpose, p_xform);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1390,17 +1390,17 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
||||
void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
Transform2D cell_xf = node->get_cell_transform();
|
||||
|
||||
Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
|
||||
Transform2D xform = p_overlay->get_canvas_transform() * node->get_global_transform();
|
||||
Transform2D xform_inv = xform.affine_inverse();
|
||||
|
||||
Size2 screen_size = canvas_item_editor->get_size();
|
||||
Size2 screen_size = p_overlay->get_size();
|
||||
{
|
||||
Rect2 aabb;
|
||||
aabb.position = node->world_to_map(xform_inv.xform(Vector2()));
|
||||
|
@ -1419,7 +1419,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
Vector2 to = xform.xform(node->map_to_world(Vector2(i, si.position.y + si.size.y + 1)));
|
||||
|
||||
Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
|
||||
canvas_item_editor->draw_line(from, to, col, 1);
|
||||
p_overlay->draw_line(from, to, col, 1);
|
||||
if (max_lines-- == 0)
|
||||
break;
|
||||
}
|
||||
|
@ -1439,7 +1439,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
Vector2 from = xform.xform(node->map_to_world(Vector2(i, j), true) + ofs);
|
||||
Vector2 to = xform.xform(node->map_to_world(Vector2(i, j + 1), true) + ofs);
|
||||
Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
|
||||
canvas_item_editor->draw_line(from, to, col, 1);
|
||||
p_overlay->draw_line(from, to, col, 1);
|
||||
|
||||
if (max_lines-- == 0)
|
||||
break;
|
||||
|
@ -1457,7 +1457,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
Vector2 to = xform.xform(node->map_to_world(Vector2(si.position.x + si.size.x + 1, i)));
|
||||
|
||||
Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
|
||||
canvas_item_editor->draw_line(from, to, col, 1);
|
||||
p_overlay->draw_line(from, to, col, 1);
|
||||
|
||||
if (max_lines-- == 0)
|
||||
break;
|
||||
|
@ -1476,7 +1476,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
Vector2 from = xform.xform(node->map_to_world(Vector2(j, i), true) + ofs);
|
||||
Vector2 to = xform.xform(node->map_to_world(Vector2(j + 1, i), true) + ofs);
|
||||
Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
|
||||
canvas_item_editor->draw_line(from, to, col, 1);
|
||||
p_overlay->draw_line(from, to, col, 1);
|
||||
|
||||
if (max_lines-- == 0)
|
||||
break;
|
||||
|
@ -1493,7 +1493,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
points.push_back(xform.xform(node->map_to_world((rectangle.position + Point2(rectangle.size.x + 1, rectangle.size.y + 1)))));
|
||||
points.push_back(xform.xform(node->map_to_world((rectangle.position + Point2(0, rectangle.size.y + 1)))));
|
||||
|
||||
canvas_item_editor->draw_colored_polygon(points, Color(0.2, 0.8, 1, 0.4));
|
||||
p_overlay->draw_colored_polygon(points, Color(0.2, 0.8, 1, 0.4));
|
||||
}
|
||||
|
||||
if (mouse_over) {
|
||||
|
@ -1519,7 +1519,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
col = Color(1.0, 0.4, 0.2, 0.8);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
canvas_item_editor->draw_line(endpoints[i], endpoints[(i + 1) % 4], col, 2);
|
||||
p_overlay->draw_line(endpoints[i], endpoints[(i + 1) % 4], col, 2);
|
||||
|
||||
bool bucket_preview = EditorSettings::get_singleton()->get("editors/tile_map/bucket_fill_preview");
|
||||
if (tool == TOOL_SELECTING || tool == TOOL_PICKING || !bucket_preview) {
|
||||
|
@ -1538,7 +1538,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
|
||||
for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
|
||||
|
||||
_draw_cell(ids[0], E->key(), flip_h, flip_v, transpose, xform);
|
||||
_draw_cell(p_overlay, ids[0], E->key(), flip_h, flip_v, transpose, xform);
|
||||
}
|
||||
|
||||
} else if (tool == TOOL_RECTANGLE_PAINT) {
|
||||
|
@ -1551,7 +1551,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) {
|
||||
for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) {
|
||||
|
||||
_draw_cell(ids[0], Point2i(j, i), flip_h, flip_v, transpose, xform);
|
||||
_draw_cell(p_overlay, ids[0], Point2i(j, i), flip_h, flip_v, transpose, xform);
|
||||
}
|
||||
}
|
||||
} else if (tool == TOOL_PASTING) {
|
||||
|
@ -1573,7 +1573,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
|
||||
TileData tcd = E->get();
|
||||
|
||||
_draw_cell(tcd.cell, tcd.pos + ofs, tcd.flip_h, tcd.flip_v, tcd.transpose, xform);
|
||||
_draw_cell(p_overlay, tcd.cell, tcd.pos + ofs, tcd.flip_h, tcd.flip_v, tcd.transpose, xform);
|
||||
}
|
||||
|
||||
Rect2i duplicate = rectangle;
|
||||
|
@ -1585,12 +1585,12 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
points.push_back(xform.xform(node->map_to_world((duplicate.position + Point2(duplicate.size.x + 1, duplicate.size.y + 1)))));
|
||||
points.push_back(xform.xform(node->map_to_world((duplicate.position + Point2(0, duplicate.size.y + 1)))));
|
||||
|
||||
canvas_item_editor->draw_colored_polygon(points, Color(0.2, 1.0, 0.8, 0.2));
|
||||
p_overlay->draw_colored_polygon(points, Color(0.2, 1.0, 0.8, 0.2));
|
||||
|
||||
} else if (tool == TOOL_BUCKET) {
|
||||
|
||||
Vector<int> tiles = get_selected_tiles();
|
||||
_draw_fill_preview(tiles[0], over_tile, flip_h, flip_v, transpose, xform);
|
||||
_draw_fill_preview(p_overlay, tiles[0], over_tile, flip_h, flip_v, transpose, xform);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -1599,7 +1599,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) {
|
|||
if (st.size() == 1 && st[0] == TileMap::INVALID_CELL)
|
||||
return;
|
||||
|
||||
_draw_cell(st[0], over_tile, flip_h, flip_v, transpose, xform);
|
||||
_draw_cell(p_overlay, st[0], over_tile, flip_h, flip_v, transpose, xform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,8 +168,8 @@ class TileMapEditor : public VBoxContainer {
|
|||
void _select(const Point2i &p_from, const Point2i &p_to);
|
||||
void _erase_selection();
|
||||
|
||||
void _draw_cell(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform);
|
||||
void _draw_fill_preview(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform);
|
||||
void _draw_cell(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform);
|
||||
void _draw_fill_preview(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform);
|
||||
void _clear_bucket_cache();
|
||||
|
||||
void _update_copydata();
|
||||
|
@ -206,7 +206,7 @@ public:
|
|||
HBoxContainer *get_toolbar() const { return toolbar; }
|
||||
|
||||
bool forward_gui_input(const Ref<InputEvent> &p_event);
|
||||
void forward_draw_over_viewport(Control *p_overlay);
|
||||
void forward_canvas_draw_over_viewport(Control *p_overlay);
|
||||
|
||||
void edit(Node *p_tile_map);
|
||||
|
||||
|
@ -225,7 +225,7 @@ protected:
|
|||
|
||||
public:
|
||||
virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return tile_map_editor->forward_gui_input(p_event); }
|
||||
virtual void forward_draw_over_viewport(Control *p_overlay) { tile_map_editor->forward_draw_over_viewport(p_overlay); }
|
||||
virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { tile_map_editor->forward_canvas_draw_over_viewport(p_overlay); }
|
||||
|
||||
virtual String get_name() const { return "TileMap"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
|
|
Loading…
Reference in a new issue