Skip to content

Commit e53c5a6

Browse files
committed
Add path init
1 parent b1e8a42 commit e53c5a6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sources/GateEngine/Resources/CollisionMesh/CollisionMesh.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ extension ResourceManager {
175175
}
176176
}
177177

178+
public extension RawCollisionMesh {
179+
init(path: String, options: CollisionMeshImporterOptions = .none) async throws {
180+
let importer: any CollisionMeshImporter = try await Game.unsafeShared.resourceManager.collisionMeshImporterForPath(path)
181+
self = try await importer.loadCollisionMesh(options: options)
182+
}
183+
}
184+
178185
extension ResourceManager.Cache {
179186
@usableFromInline
180187
struct CollisionMeshKey: Hashable, Sendable, CustomStringConvertible {
@@ -287,8 +294,7 @@ extension ResourceManager {
287294
let path = key.requestedPath
288295

289296
do {
290-
let importer: any CollisionMeshImporter = try await Game.unsafeShared.resourceManager.collisionMeshImporterForPath(path)
291-
let rawCollisionMesh = try await importer.loadCollisionMesh(options: key.collisionMeshOptions)
297+
let rawCollisionMesh = try await RawCollisionMesh(path: path, options: key.collisionMeshOptions)
292298

293299
Task { @MainActor in
294300
if let cache = cache.collisionMeshes[key] {

0 commit comments

Comments
 (0)