Move the code for the uv unwrapping action from the plugin to the gizmo.

This commit is contained in:
Relintai 2022-01-19 00:17:39 +01:00
parent 0aa0342d3f
commit 1a38232d51
2 changed files with 25 additions and 21 deletions

View File

@ -1024,3 +1024,23 @@ func apply_seam():
_mdr.connect("changed", self, "on_mdr_changed")
on_mdr_changed()
func uv_unwrap() -> void:
if !_mdr:
return
var mdr_arr : Array = _mdr.array
if mdr_arr.size() != ArrayMesh.ARRAY_MAX || mdr_arr[ArrayMesh.ARRAY_VERTEX] == null || mdr_arr[ArrayMesh.ARRAY_VERTEX].size() == 0:
return
var mesh : Array = _mdr.get_array()
var uvs : PoolVector2Array = MeshUtils.uv_unwrap(mesh)
if uvs.size() != mdr_arr[ArrayMesh.ARRAY_VERTEX]:
print("Error: Could not unwrap mesh!")
return
mesh[ArrayMesh.ARRAY_TEX_UV] = uvs
_mdr.set_array(mesh)

View File

@ -132,27 +132,6 @@ func get_mdr() -> MeshDataResource:
return null
func uv_unwrap() -> void:
var mdr : MeshDataResource = null
if current_mesh_data_instance && current_mesh_data_instance.mesh_data:
#current_mesh_data_instance.mesh_data.uv_unwrap()
mdr = current_mesh_data_instance.mesh_data
if !mdr:
return
var mesh : Array = mdr.get_array()
var uvs : PoolVector2Array = MeshUtils.uv_unwrap(mesh)
mesh[ArrayMesh.ARRAY_TEX_UV] = uvs
mdr.set_array(mesh)
if mdr:
mdi_ed_gui.set_mesh_data_resource(mdr)
#func forward_spatial_gui_input(camera, event):
# for g in active_gizmos:
@ -249,3 +228,8 @@ func unmark_seam():
func apply_seam():
for g in active_gizmos:
g.apply_seam()
func uv_unwrap() -> void:
for g in active_gizmos:
g.apply_seam()