From 2d88f4d6b4a22198bf43c17bb19860d21be3b370 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 19 Jan 2022 23:34:04 +0100 Subject: [PATCH] Apply seams should properly work now in every cases (hopefully). --- .../utilities/mdred_mesh_utils.gd | 15 ++++++--------- game/test_mdr/Spatial.tscn | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/game/addons/mesh_data_resource_editor/utilities/mdred_mesh_utils.gd b/game/addons/mesh_data_resource_editor/utilities/mdred_mesh_utils.gd index a64c5859..1124f5fe 100644 --- a/game/addons/mesh_data_resource_editor/utilities/mdred_mesh_utils.gd +++ b/game/addons/mesh_data_resource_editor/utilities/mdred_mesh_utils.gd @@ -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) diff --git a/game/test_mdr/Spatial.tscn b/game/test_mdr/Spatial.tscn index ebe40e86..b8f700c9 100644 --- a/game/test_mdr/Spatial.tscn +++ b/game/test_mdr/Spatial.tscn @@ -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 )