Skip to content

Commit 6efefa6

Browse files
committed
fix crash and small bug
1 parent 90c517a commit 6efefa6

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

mirror-godot-app/prefabs/autoload/zone/collision_shape_generator/collision_shape_generator.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ func generate_shape_for_meshes(body: JBody3D, in_meshes: Array[MeshInstance3D],
7575
if is_concave:
7676
var tms: ConcavePolygonShape3D = mesh.mesh.create_trimesh_shape()
7777
shape = JMeshShape3D.new()
78+
if tms == null:
79+
push_error("invalid physics shape")
80+
continue
7881
shape.faces = tms.get_faces()
7982
else:
8083
var cps: ConvexPolygonShape3D = mesh.mesh.create_convex_shape(false, false)

mirror-godot-app/scripts/net/file_cache.gd

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func try_load_cached_file(cache_key: String) -> Variant:
117117
if not FileAccess.file_exists(file_path):
118118
return null
119119
if Util.path_is_model(file_path):
120-
return TMFileUtil.load_gltf_file_as_node(file_path, Zone.is_host())
120+
return load_gltf_thread_task(file_path)
121121
elif Util.path_is_image(file_path):
122122
return Util.load_image(file_path)
123123
elif Util.path_is_scene(file_path):
@@ -132,12 +132,13 @@ func try_load_cached_file(cache_key: String) -> Variant:
132132
var _cached_pairs = {}
133133

134134
func load_gltf_thread_task(cache_key: String) -> Promise:
135-
for m in _model_load_queue:
136-
if m.key == cache_key:
137-
return m.promise
135+
if _cached_pairs.has(cache_key):
136+
print("Cache found... not loading twice")
137+
return _cached_pairs[cache_key].promise
138138
var pair = KeyPromisePair.new()
139139
pair.key = cache_key
140140
pair.promise = Promise.new()
141+
_cached_pairs[pair.key] = pair
141142

142143
if not cached_file_exists(pair.key):
143144
pair.promise.set_error("File does not exists, cannot load.")
@@ -146,11 +147,19 @@ func load_gltf_thread_task(cache_key: String) -> Promise:
146147
var file_path: String = get_file_path(file_name)
147148

148149
var task_id = WorkerThreadPool.add_task(func():
149-
Thread.set_thread_safety_checks_enabled(false)
150+
# future: we'll pack all the assets to .tscn and dependencies
151+
# it should be faster than packing / repacking things. maybe even .scn files.
152+
# if ResourceLoader.exists(file_path + ".tscn"):
153+
# var node = ResourceLoader.load(file_path + ".tscn").instantiate()
154+
# call_thread_safe("_cached_file_is_loaded", pair, node)
155+
# return
150156
var node = TMFileUtil.load_gltf_file_as_node(file_path, Zone.is_host())
157+
# var scene: PackedScene = PackedScene.new()
158+
# scene.pack(node)
159+
# ResourceSaver.save(scene, file_path + ".tscn")
160+
# print("Path: ", file_path + ".tscn")
151161
call_thread_safe("_cached_file_is_loaded", pair, node)
152162
)
153-
_cached_pairs[task_id]
154163

155164

156165
return pair.promise

0 commit comments

Comments
 (0)