From 991f3276822b6d701ba78a2c3c799a0416110284 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 17 Nov 2021 15:31:04 +0100 Subject: [PATCH] Fix 2 errors in mesh_data_resource_editor when a mesh data resource is empty. --- game/addons/mesh_data_resource_editor/MIDGizmo.gd | 3 +++ game/addons/mesh_data_resource_editor/UVEditor.gd | 3 +++ game/test_mdr/Spatial.tscn | 15 +++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 game/test_mdr/Spatial.tscn diff --git a/game/addons/mesh_data_resource_editor/MIDGizmo.gd b/game/addons/mesh_data_resource_editor/MIDGizmo.gd index f85ba1ee..724a6306 100644 --- a/game/addons/mesh_data_resource_editor/MIDGizmo.gd +++ b/game/addons/mesh_data_resource_editor/MIDGizmo.gd @@ -101,6 +101,9 @@ func redraw(): if !mdr: return + if mdr.array.size() != ArrayMesh.ARRAY_MAX: + return + var handles_material : SpatialMaterial = get_plugin().get_material("handles", self) if vertices.size() == 0: diff --git a/game/addons/mesh_data_resource_editor/UVEditor.gd b/game/addons/mesh_data_resource_editor/UVEditor.gd index 7cc9eb0d..7b6e566a 100644 --- a/game/addons/mesh_data_resource_editor/UVEditor.gd +++ b/game/addons/mesh_data_resource_editor/UVEditor.gd @@ -20,6 +20,9 @@ func on_mdr_changed(): func _draw(): if !mesh_data_resource: return + + if mesh_data_resource.array.size() != ArrayMesh.ARRAY_MAX: + return var uvs : PoolVector2Array = mesh_data_resource.array[ArrayMesh.ARRAY_TEX_UV] var indices : PoolIntArray = mesh_data_resource.array[ArrayMesh.ARRAY_INDEX] diff --git a/game/test_mdr/Spatial.tscn b/game/test_mdr/Spatial.tscn new file mode 100644 index 00000000..c47b9662 --- /dev/null +++ b/game/test_mdr/Spatial.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=4 format=2] + +[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] + +[sub_resource type="SpatialMaterial" id=2] +albedo_texture = ExtResource( 1 ) + +[node name="Spatial" type="Spatial"] + +[node name="MeshDataInstance" type="MeshDataInstance" parent="."] +mesh_data = SubResource( 1 ) +texture = ExtResource( 1 ) +material = SubResource( 2 )