Transfer the current editing state from the active gizmo when a new mesh data instance is selected. Also smaller cleanups.

This commit is contained in:
Relintai 2022-01-23 01:58:43 +01:00
parent 4ef0a39fa2
commit 45a1f42e51
3 changed files with 31 additions and 25 deletions

View File

@ -77,17 +77,17 @@ func set_edit_mode_scale() -> void:
func on_edit_mode_translate_toggled(on : bool) -> void:
if on:
if _plugin:
_plugin.set_translate(on)
_plugin.set_translate()
func on_edit_mode_rotate_toggled(on : bool) -> void:
if on:
if _plugin:
_plugin.set_rotate(on)
_plugin.set_rotate()
func on_edit_mode_scale_toggled(on : bool) -> void:
if on:
if _plugin:
_plugin.set_scale(on)
_plugin.set_scale()
#axis locks
func get_axis_x() -> bool:

View File

@ -287,18 +287,18 @@ func mul_all_selected_with_basis(b : Basis) -> void:
v = b * v
_vertices.set(j, v)
func set_translate(on : bool) -> void:
if on:
edit_mode = EditMode.EDIT_MODE_TRANSLATE
func set_translate() -> void:
edit_mode = EditMode.EDIT_MODE_TRANSLATE
func set_scale(on : bool) -> void:
if on:
edit_mode = EditMode.EDIT_MODE_SCALE
func set_rotate(on : bool) -> void:
if on:
edit_mode = EditMode.EDIT_MODE_ROTATE
func set_scale() -> void:
edit_mode = EditMode.EDIT_MODE_SCALE
func set_rotate() -> void:
edit_mode = EditMode.EDIT_MODE_ROTATE
func set_edit_mode(em : int) -> void:
edit_mode = em
func set_axis_x(on : bool) -> void:
if on:
axis_constraint |= AxisConstraint.X
@ -1233,3 +1233,9 @@ func set_pivot_mdi_origin():
func set_pivot_world_origin():
pivot_type = PivotTypes.PIVOT_TYPE_WORLD_ORIGIN
func transfer_state_from(other) -> void:
edit_mode = other.edit_mode
pivot_type = other.pivot_type
axis_constraint = other.axis_constraint
selection_mode = other.selection_mode

View File

@ -14,8 +14,6 @@ var active_gizmos : Array
var current_mesh_data_instance : MeshDataInstance = null
func _enter_tree():
#print("_enter_tree")
gizmo_plugin = MdiGizmoPlugin.new()
mdi_ed_gui = MDIEdGui.instance()
mdi_ed_gui.set_plugin(self)
@ -58,12 +56,15 @@ func handles(object):
func edit(object):
var mdi : MeshDataInstance = object as MeshDataInstance
current_mesh_data_instance = mdi
if mdi:
if current_mesh_data_instance && mdi.gizmo && current_mesh_data_instance.gizmo:
mdi.gizmo.transfer_state_from(current_mesh_data_instance.gizmo)
mdi_ed_gui.set_mesh_data_resource(mdi.mesh_data)
mdi_ed_gui.set_mesh_data_instance(mdi)
current_mesh_data_instance = mdi
func make_visible(visible):
#print("make_visible")
@ -91,17 +92,17 @@ func unregister_gizmo(gizmo):
active_gizmos.remove(i)
return
func set_translate(on : bool) -> void:
func set_translate() -> void:
if current_mesh_data_instance && current_mesh_data_instance.gizmo:
current_mesh_data_instance.gizmo.set_translate(on)
current_mesh_data_instance.gizmo.set_translate()
func set_scale(on : bool) -> void:
func set_scale() -> void:
if current_mesh_data_instance && current_mesh_data_instance.gizmo:
current_mesh_data_instance.gizmo.set_scale(on)
current_mesh_data_instance.gizmo.set_scale()
func set_rotate(on : bool) -> void:
func set_rotate() -> void:
if current_mesh_data_instance && current_mesh_data_instance.gizmo:
current_mesh_data_instance.gizmo.set_rotate(on)
current_mesh_data_instance.gizmo.set_rotate()
func set_axis_x(on : bool) -> void:
if current_mesh_data_instance && current_mesh_data_instance.gizmo:
@ -119,7 +120,6 @@ func set_selection_mode_vertex() -> void:
if current_mesh_data_instance && current_mesh_data_instance.gizmo:
current_mesh_data_instance.gizmo.set_selection_mode_vertex()
func set_selection_mode_edge() -> void:
if current_mesh_data_instance && current_mesh_data_instance.gizmo:
current_mesh_data_instance.gizmo.set_selection_mode_edge()