Apply seams should properly work now in every cases (hopefully).

This commit is contained in:
Relintai 2022-01-19 23:34:04 +01:00
parent 9daff0f907
commit 2d88f4d6b4
2 changed files with 8 additions and 9 deletions

View File

@ -1005,6 +1005,8 @@ static func apply_seam(mdr : MeshDataResource) -> void:
var vertices : PoolVector3Array = arrays[ArrayMesh.ARRAY_VERTEX]
var indices : PoolIntArray = arrays[ArrayMesh.ARRAY_INDEX]
var new_indices : PoolIntArray = PoolIntArray()
new_indices.append_array(indices)
var seams : PoolIntArray = mdr.seams
@ -1062,7 +1064,6 @@ static func apply_seam(mdr : MeshDataResource) -> void:
tri.processed = true
if tri.both_sides_need_cut():
duplicate_verts_indices.push_back(tri.orig_index)
triangle_arrays.push_back([ tri ])
continue
@ -1105,19 +1106,15 @@ static func apply_seam(mdr : MeshDataResource) -> void:
# Skip processing the first strip, so we don't create unused verts
for tind in range(1, triangle_arrays.size()):
var tris : Array = triangle_arrays[tind]
duplicate_verts_indices.push_back(tris[0].orig_index)
#print(tris)
for tri in tris:
indices[tri.index_index] = new_vert_size
new_indices[tri.index_index] = new_vert_size
new_vert_size += 1
#print("----")
arrays[ArrayMesh.ARRAY_INDEX] = indices
arrays[ArrayMesh.ARRAY_INDEX] = new_indices
mdr.array = seam_apply_duplicate_vertices(arrays, duplicate_verts_indices)

View File

@ -3,7 +3,9 @@
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/grass_mossy_albedo.png" type="Texture" id=1]
[sub_resource type="MeshDataResource" id=1]
array = [ PoolVector3Array( -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5 ), PoolVector3Array( 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1 ), null, null, PoolVector2Array( 0.253049, 0.336022, 0.253049, 0.00806455, 0.5, 0.00806452, 0.5, 0.336022, 0.253049, 0.663978, 0.5, 0.991935, 0.253049, 0.991935, 0.5, 0.663978, 0.00609756, 0.336022, 0.993902, 0.336021, 0.746951, 0.336021, 0.746951, 0.663978, 0.00609758, 0.663979, 0.993902, 0.663978 ), null, null, null, PoolIntArray( 0, 1, 2, 2, 3, 0, 4, 5, 6, 4, 7, 5, 3, 10, 11, 11, 7, 3, 0, 12, 8, 0, 4, 12, 9, 13, 11, 11, 10, 9, 0, 7, 4, 0, 3, 7 ) ]
aabb = AABB( -0.5, -0.5, -0.5, 1, 1, 1 )
seams = PoolIntArray( 1, 6, 4, 6, 0, 1, 1, 2, 5, 6, 2, 3, 5, 7 )
[sub_resource type="SpatialMaterial" id=2]
albedo_texture = ExtResource( 1 )