Fix 2 errors in mesh_data_resource_editor when a mesh data resource is empty.

This commit is contained in:
Relintai 2021-11-17 15:31:04 +01:00
parent 19820f1522
commit 991f327682
3 changed files with 21 additions and 0 deletions

View File

@ -101,6 +101,9 @@ func redraw():
if !mdr: if !mdr:
return return
if mdr.array.size() != ArrayMesh.ARRAY_MAX:
return
var handles_material : SpatialMaterial = get_plugin().get_material("handles", self) var handles_material : SpatialMaterial = get_plugin().get_material("handles", self)
if vertices.size() == 0: if vertices.size() == 0:

View File

@ -20,6 +20,9 @@ func on_mdr_changed():
func _draw(): func _draw():
if !mesh_data_resource: if !mesh_data_resource:
return return
if mesh_data_resource.array.size() != ArrayMesh.ARRAY_MAX:
return
var uvs : PoolVector2Array = mesh_data_resource.array[ArrayMesh.ARRAY_TEX_UV] var uvs : PoolVector2Array = mesh_data_resource.array[ArrayMesh.ARRAY_TEX_UV]
var indices : PoolIntArray = mesh_data_resource.array[ArrayMesh.ARRAY_INDEX] var indices : PoolIntArray = mesh_data_resource.array[ArrayMesh.ARRAY_INDEX]

View File

@ -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 )