mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-08 01:49:35 +01:00
Moved some of the new helper methods to the mesh utils script.
This commit is contained in:
parent
272e34a06a
commit
25c71e2c14
@ -947,56 +947,6 @@ func get_all_index_pairs_for_edge(edge : int) -> PoolIntArray:
|
||||
|
||||
return ret
|
||||
|
||||
func order_seam_indices(arr : PoolIntArray) -> PoolIntArray:
|
||||
var ret : PoolIntArray = PoolIntArray()
|
||||
|
||||
if arr.size() == 0:
|
||||
return ret
|
||||
|
||||
for i in range(0, arr.size(), 2):
|
||||
var index0 : int = arr[i]
|
||||
var index1 : int = arr[i + 1]
|
||||
|
||||
if index0 > index1:
|
||||
var t : int = index1
|
||||
index1 = index0
|
||||
index0 = t
|
||||
|
||||
ret.push_back(index0)
|
||||
ret.push_back(index1)
|
||||
|
||||
return ret
|
||||
|
||||
func has_seam(index0 : int, index1 : int) -> bool:
|
||||
var seams : PoolIntArray = _mdr.seams
|
||||
|
||||
for i in range(0, seams.size(), 2):
|
||||
if seams[i] == index0 && seams[i + 1] == index1:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func add_seam(index0 : int, index1 : int) -> void:
|
||||
if has_seam(index0, index1):
|
||||
return
|
||||
|
||||
var seams : PoolIntArray = _mdr.seams
|
||||
seams.push_back(index0)
|
||||
seams.push_back(index1)
|
||||
_mdr.seams = seams
|
||||
|
||||
func remove_seam(index0 : int, index1 : int) -> void:
|
||||
if !has_seam(index0, index1):
|
||||
return
|
||||
|
||||
var seams : PoolIntArray = _mdr.seams
|
||||
|
||||
for i in range(0, seams.size(), 2):
|
||||
if seams[i] == index0 && seams[i + 1] == index1:
|
||||
seams.remove(i)
|
||||
seams.remove(i)
|
||||
_mdr.seams = seams
|
||||
return
|
||||
|
||||
func mark_seam():
|
||||
if !_mdr:
|
||||
@ -1011,12 +961,12 @@ func mark_seam():
|
||||
_mdr.disconnect("changed", self, "on_mdr_changed")
|
||||
|
||||
for se in _selected_points:
|
||||
var eis : PoolIntArray = order_seam_indices(get_first_index_pair_for_edge(se))
|
||||
var eis : PoolIntArray = MDRMeshUtils.order_seam_indices(get_first_index_pair_for_edge(se))
|
||||
|
||||
if eis.size() == 0:
|
||||
continue
|
||||
|
||||
add_seam(eis[0], eis[1])
|
||||
MDRMeshUtils.add_seam(_mdr, eis[0], eis[1])
|
||||
|
||||
_mdr.connect("changed", self, "on_mdr_changed")
|
||||
on_mdr_changed()
|
||||
@ -1036,12 +986,12 @@ func unmark_seam():
|
||||
_mdr.disconnect("changed", self, "on_mdr_changed")
|
||||
|
||||
for se in _selected_points:
|
||||
var eis : PoolIntArray = order_seam_indices(get_all_index_pairs_for_edge(se))
|
||||
var eis : PoolIntArray = MDRMeshUtils.order_seam_indices(get_all_index_pairs_for_edge(se))
|
||||
|
||||
if eis.size() == 0:
|
||||
continue
|
||||
|
||||
remove_seam(eis[0], eis[1])
|
||||
MDRMeshUtils.remove_seam(_mdr, eis[0], eis[1])
|
||||
|
||||
_mdr.connect("changed", self, "on_mdr_changed")
|
||||
on_mdr_changed()
|
||||
|
@ -652,3 +652,54 @@ static func generate_tangents(mdr : MeshDataResource) -> void:
|
||||
st.generate_tangents()
|
||||
|
||||
mdr.array = st.commit_to_arrays()
|
||||
|
||||
static func order_seam_indices(arr : PoolIntArray) -> PoolIntArray:
|
||||
var ret : PoolIntArray = PoolIntArray()
|
||||
|
||||
if arr.size() == 0:
|
||||
return ret
|
||||
|
||||
for i in range(0, arr.size(), 2):
|
||||
var index0 : int = arr[i]
|
||||
var index1 : int = arr[i + 1]
|
||||
|
||||
if index0 > index1:
|
||||
var t : int = index1
|
||||
index1 = index0
|
||||
index0 = t
|
||||
|
||||
ret.push_back(index0)
|
||||
ret.push_back(index1)
|
||||
|
||||
return ret
|
||||
|
||||
static func has_seam(mdr : MeshDataResource, index0 : int, index1 : int) -> bool:
|
||||
var seams : PoolIntArray = mdr.seams
|
||||
|
||||
for i in range(0, seams.size(), 2):
|
||||
if seams[i] == index0 && seams[i + 1] == index1:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
static func add_seam(mdr : MeshDataResource, index0 : int, index1 : int) -> void:
|
||||
if has_seam(mdr, index0, index1):
|
||||
return
|
||||
|
||||
var seams : PoolIntArray = mdr.seams
|
||||
seams.push_back(index0)
|
||||
seams.push_back(index1)
|
||||
mdr.seams = seams
|
||||
|
||||
static func remove_seam(mdr : MeshDataResource, index0 : int, index1 : int) -> void:
|
||||
if !has_seam(mdr, index0, index1):
|
||||
return
|
||||
|
||||
var seams : PoolIntArray = mdr.seams
|
||||
|
||||
for i in range(0, seams.size(), 2):
|
||||
if seams[i] == index0 && seams[i + 1] == index1:
|
||||
seams.remove(i)
|
||||
seams.remove(i)
|
||||
mdr.seams = seams
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user