mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Implemented horizontal and vertical mirroring for the uv editor.
This commit is contained in:
parent
8ae0b5b236
commit
05f1c2c365
@ -63,19 +63,23 @@ func _enter_tree():
|
||||
connect("visibility_changed", self, "on_visibility_changed")
|
||||
|
||||
func on_mirror_horizontal_button_pressed() -> void:
|
||||
pass
|
||||
if selected_rect && is_instance_valid(selected_rect):
|
||||
selected_rect.mirror_horizontal()
|
||||
|
||||
func on_mirror_vertical_button_pressed() -> void:
|
||||
pass
|
||||
if selected_rect && is_instance_valid(selected_rect):
|
||||
selected_rect.mirror_vertical()
|
||||
|
||||
func on_rotate_left_button_button_pressed() -> void:
|
||||
pass
|
||||
if selected_rect && is_instance_valid(selected_rect):
|
||||
selected_rect.rotate_uvs(rotation_amount)
|
||||
|
||||
func on_rotate_amount_spinbox_changed(val : float) -> void:
|
||||
rotation_amount = val
|
||||
|
||||
func on_rotate_right_button_button_pressed() -> void:
|
||||
pass
|
||||
if selected_rect && is_instance_valid(selected_rect):
|
||||
selected_rect.rotate_uvs(-rotation_amount)
|
||||
|
||||
func set_plugin(plugin : EditorPlugin) -> void:
|
||||
_plugin = plugin
|
||||
|
@ -52,6 +52,53 @@ func _draw():
|
||||
draw_line(_uvs[_indices[i + 1]] * get_size(), _uvs[_indices[i + 2]] * get_size(), c, 1, false)
|
||||
draw_line(_uvs[_indices[i + 2]] * get_size(), _uvs[_indices[i]] * get_size(), c, 1, false)
|
||||
|
||||
func mirror_horizontal() -> void:
|
||||
var pia : PoolIntArray = PoolIntArray()
|
||||
for index in _indices:
|
||||
var found : bool = false
|
||||
|
||||
for i in pia:
|
||||
if i == index:
|
||||
found = true
|
||||
break
|
||||
|
||||
if found:
|
||||
continue
|
||||
|
||||
pia.append(index)
|
||||
|
||||
var uv : Vector2 = _uvs[index]
|
||||
uv.x = 1.0 - uv.x
|
||||
_uvs.set(index, uv)
|
||||
|
||||
apply_uv()
|
||||
update()
|
||||
|
||||
func mirror_vertical() -> void:
|
||||
var pia : PoolIntArray = PoolIntArray()
|
||||
for index in _indices:
|
||||
var found : bool = false
|
||||
|
||||
for i in pia:
|
||||
if i == index:
|
||||
found = true
|
||||
break
|
||||
|
||||
if found:
|
||||
continue
|
||||
|
||||
pia.append(index)
|
||||
|
||||
var uv : Vector2 = _uvs[index]
|
||||
uv.y = 1.0 - uv.y
|
||||
_uvs.set(index, uv)
|
||||
|
||||
apply_uv()
|
||||
update()
|
||||
|
||||
func rotate_uvs(amount : float) -> void:
|
||||
pass
|
||||
|
||||
func refresh() -> void:
|
||||
if !_mdr:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user