summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp12
-rw-r--r--editor/plugins/texture_region_editor_plugin.h15
-rw-r--r--scene/3d/visual_instance_3d.cpp9
-rw-r--r--scene/3d/visual_instance_3d.h1
4 files changed, 29 insertions, 8 deletions
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 79e09404a0..3f4f9a4f4d 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -83,6 +83,7 @@ void TextureRegionEditor::_region_draw() {
mtx.scale_basis(Vector2(draw_zoom, draw_zoom));
RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx);
+ edit_draw->draw_rect(Rect2(Point2(), base_tex->get_size()), Color(0.5, 0.5, 0.5, 0.5), false);
edit_draw->draw_texture(base_tex, Point2());
RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D());
@@ -234,6 +235,14 @@ void TextureRegionEditor::_region_draw() {
updating_scroll = false;
+ if (request_center && hscroll->get_min() < 0) {
+ hscroll->set_value((hscroll->get_min() + hscroll->get_max() - hscroll->get_page()) / 2);
+ vscroll->set_value((vscroll->get_min() + vscroll->get_max() - vscroll->get_page()) / 2);
+ // This ensures that the view is updated correctly.
+ callable_bind(callable_mp(this, &TextureRegionEditor::_pan_callback), Vector2(1, 0)).call_deferred(nullptr, 0);
+ request_center = false;
+ }
+
if (node_ninepatch || obj_styleBox.is_valid()) {
float margins[4] = { 0 };
if (node_ninepatch) {
@@ -922,7 +931,8 @@ void TextureRegionEditor::edit(Object *p_obj) {
atlas_tex = Ref<AtlasTexture>(nullptr);
}
edit_draw->update();
- popup_centered_ratio();
+ popup_centered_ratio(0.5);
+ request_center = true;
}
void TextureRegionEditor::_texture_changed() {
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index dd92f6e3eb..a18c87f153 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -71,10 +71,10 @@ class TextureRegionEditor : public AcceptDialog {
UndoRedo *undo_redo = nullptr;
Vector2 draw_ofs;
- float draw_zoom;
- bool updating_scroll;
+ float draw_zoom = 0.0;
+ bool updating_scroll = false;
- int snap_mode;
+ int snap_mode = 0;
Vector2 snap_offset;
Vector2 snap_step;
Vector2 snap_separation;
@@ -88,15 +88,16 @@ class TextureRegionEditor : public AcceptDialog {
Rect2 rect;
Rect2 rect_prev;
float prev_margin = 0.0f;
- int edited_margin;
+ int edited_margin = 0;
HashMap<RID, List<Rect2>> cache_map;
List<Rect2> autoslice_cache;
- bool autoslice_is_dirty;
+ bool autoslice_is_dirty = false;
- bool drag;
+ bool drag = false;
bool creating = false;
Vector2 drag_from;
- int drag_index;
+ int drag_index = 0;
+ bool request_center = false;
Ref<ViewPanner> panner;
void _scroll_callback(Vector2 p_scroll_vec, bool p_alt);
diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp
index 273e01989a..e40c8bfa2b 100644
--- a/scene/3d/visual_instance_3d.cpp
+++ b/scene/3d/visual_instance_3d.cpp
@@ -496,3 +496,12 @@ void GeometryInstance3D::_bind_methods() {
GeometryInstance3D::GeometryInstance3D() {
//RS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
}
+
+GeometryInstance3D::~GeometryInstance3D() {
+ if (material_overlay.is_valid()) {
+ set_material_overlay(Ref<Material>());
+ }
+ if (material_override.is_valid()) {
+ set_material_override(Ref<Material>());
+ }
+}
diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h
index f8fd4378fe..e5f98bd65e 100644
--- a/scene/3d/visual_instance_3d.h
+++ b/scene/3d/visual_instance_3d.h
@@ -188,6 +188,7 @@ public:
TypedArray<String> get_configuration_warnings() const override;
GeometryInstance3D();
+ virtual ~GeometryInstance3D();
};
VARIANT_ENUM_CAST(GeometryInstance3D::ShadowCastingSetting);