From d762bfc8f1f8f6e41afb0af3b1ba59badd7d26ba Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Sun, 17 Nov 2024 11:41:27 -0700 Subject: [PATCH] Guard rail multimesh error fixes --- levels/debug_level/debug_level.tscn | 2 +- .../highway/{ => guard_rail}/guard_rail.gd | 14 ++++++++- .../highway/{ => guard_rail}/guard_rail.tscn | 29 ++++--------------- .../guard_rail/guard_rail_post_mesh.tres | 19 ++++++++++++ 4 files changed, 39 insertions(+), 25 deletions(-) rename src/props/scenery/highway/{ => guard_rail}/guard_rail.gd (73%) rename src/props/scenery/highway/{ => guard_rail}/guard_rail.tscn (58%) create mode 100644 src/props/scenery/highway/guard_rail/guard_rail_post_mesh.tres diff --git a/levels/debug_level/debug_level.tscn b/levels/debug_level/debug_level.tscn index cbf6702..757f103 100644 --- a/levels/debug_level/debug_level.tscn +++ b/levels/debug_level/debug_level.tscn @@ -20,7 +20,7 @@ [ext_resource type="PackedScene" uid="uid://c7l58wuuahn7w" path="res://src/props/flag/flag.tscn" id="13_6jtao"] [ext_resource type="Texture2D" uid="uid://dj60e8ri2fco" path="res://assets/models/scenery/city/concrete_building_1/concrete_building_1.png" id="14_y7s2h"] [ext_resource type="Texture2D" uid="uid://du3vk5nnksohs" path="res://assets/sprites/particles/sparkle.png" id="16_2m5yu"] -[ext_resource type="PackedScene" uid="uid://nqar1qcun8ax" path="res://src/props/scenery/highway/guard_rail.tscn" id="16_xtxyj"] +[ext_resource type="PackedScene" uid="uid://nqar1qcun8ax" path="res://src/props/scenery/highway/guard_rail/guard_rail.tscn" id="16_xtxyj"] [ext_resource type="PackedScene" uid="uid://d0tcr6uijpym5" path="res://src/props/scenery/highway/highway_road.tscn" id="17_amems"] [ext_resource type="PackedScene" uid="uid://cblsayfgirexr" path="res://src/characters/umineko/umineko.tscn" id="21_ch6qk"] diff --git a/src/props/scenery/highway/guard_rail.gd b/src/props/scenery/highway/guard_rail/guard_rail.gd similarity index 73% rename from src/props/scenery/highway/guard_rail.gd rename to src/props/scenery/highway/guard_rail/guard_rail.gd index d7ed9d2..ccda972 100644 --- a/src/props/scenery/highway/guard_rail.gd +++ b/src/props/scenery/highway/guard_rail/guard_rail.gd @@ -23,9 +23,21 @@ var _dirty := false @onready var post_multi_mesh: MultiMeshInstance3D = $PostMultiMesh +static var multimesh_mesh: Mesh = preload( + "res://src/props/scenery/highway/guard_rail/guard_rail_post_mesh.tres" +) + func _ready() -> void: - post_multi_mesh.multimesh = post_multi_mesh.multimesh.duplicate() + # Set up multimesh + # This is a workaround for an engine bug as of Godot 4.3 + # ref: https://github.com/godotengine/godot/issues/68592 + var multimesh := MultiMesh.new() + multimesh.transform_format = MultiMesh.TRANSFORM_3D + multimesh.instance_count = 0 + multimesh.mesh = multimesh_mesh + + post_multi_mesh.multimesh = multimesh func _update_multimesh() -> void: diff --git a/src/props/scenery/highway/guard_rail.tscn b/src/props/scenery/highway/guard_rail/guard_rail.tscn similarity index 58% rename from src/props/scenery/highway/guard_rail.tscn rename to src/props/scenery/highway/guard_rail/guard_rail.tscn index 14d3979..5562958 100644 --- a/src/props/scenery/highway/guard_rail.tscn +++ b/src/props/scenery/highway/guard_rail/guard_rail.tscn @@ -1,29 +1,12 @@ -[gd_scene load_steps=7 format=3 uid="uid://nqar1qcun8ax"] +[gd_scene load_steps=5 format=3 uid="uid://nqar1qcun8ax"] -[ext_resource type="Script" path="res://src/props/scenery/highway/guard_rail.gd" id="1_imntf"] +[ext_resource type="Script" path="res://src/props/scenery/highway/guard_rail/guard_rail.gd" id="1_imntf"] [ext_resource type="Material" uid="uid://cift6p0wn1oce" path="res://assets/materials/guard_rail.tres" id="2_1s4wy"] +[ext_resource type="PlaneMesh" uid="uid://bdcmgvgpj1e0w" path="res://src/props/scenery/highway/guard_rail/guard_rail_post_mesh.tres" id="3_hha2c"] -[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_fo7j3"] -load_path = "res://.godot/imported/guard_rail_post.png-4447ff881a5916e5281ed251b7beecd0.ctex" - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_k1yjg"] -transparency = 2 -alpha_scissor_threshold = 0.5 -alpha_antialiasing_mode = 0 -albedo_texture = SubResource("CompressedTexture2D_fo7j3") -texture_filter = 4 -texture_repeat = false -billboard_mode = 2 - -[sub_resource type="PlaneMesh" id="PlaneMesh_ko4yv"] -material = SubResource("StandardMaterial3D_k1yjg") -size = Vector2(0.5, 1) -center_offset = Vector3(0, 0.5, 0) -orientation = 2 - -[sub_resource type="MultiMesh" id="MultiMesh_ecm13"] +[sub_resource type="MultiMesh" id="MultiMesh_suiix"] transform_format = 1 -mesh = SubResource("PlaneMesh_ko4yv") +mesh = ExtResource("3_hha2c") [node name="GuardRail" type="Path3D"] script = ExtResource("1_imntf") @@ -59,6 +42,6 @@ path_joined = false material = ExtResource("2_1s4wy") [node name="PostMultiMesh" type="MultiMeshInstance3D" parent="."] -multimesh = SubResource("MultiMesh_ecm13") +multimesh = SubResource("MultiMesh_suiix") [connection signal="curve_changed" from="." to="." method="_on_curve_changed"] diff --git a/src/props/scenery/highway/guard_rail/guard_rail_post_mesh.tres b/src/props/scenery/highway/guard_rail/guard_rail_post_mesh.tres new file mode 100644 index 0000000..ed310b8 --- /dev/null +++ b/src/props/scenery/highway/guard_rail/guard_rail_post_mesh.tres @@ -0,0 +1,19 @@ +[gd_resource type="PlaneMesh" load_steps=3 format=3 uid="uid://bdcmgvgpj1e0w"] + +[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_fo7j3"] +load_path = "res://.godot/imported/guard_rail_post.png-4447ff881a5916e5281ed251b7beecd0.ctex" + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_k1yjg"] +transparency = 2 +alpha_scissor_threshold = 0.5 +alpha_antialiasing_mode = 0 +albedo_texture = SubResource("CompressedTexture2D_fo7j3") +texture_filter = 4 +texture_repeat = false +billboard_mode = 2 + +[resource] +material = SubResource("StandardMaterial3D_k1yjg") +size = Vector2(0.5, 1) +center_offset = Vector3(0, 0.5, 0) +orientation = 2