Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Engine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
5677AD2B28C1505000BF822C /* simd_float3x3+Extension+Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5677AD2228C1505000BF822C /* simd_float3x3+Extension+Tests.swift */; };
5677AD3128C151CA00BF822C /* XCTest+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5677AD3028C151CA00BF822C /* XCTest+Extension.swift */; };
567F5C3D28A7AC3000AD0A6C /* NSImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567F5C3C28A7AC3000AD0A6C /* NSImage+Extension.swift */; platformFilters = (macos, ); };
56865D8C2EF955B50024896F /* MDLAxisAlignedBoundingBox+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56865D8B2EF955B20024896F /* MDLAxisAlignedBoundingBox+Extension.swift */; };
5686BD9A273C1CD300329FA0 /* PNIStaticBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5686BD99273C1CD300329FA0 /* PNIStaticBuffer.swift */; };
5686BD9D273D78B700329FA0 /* Animation.metal in Sources */ = {isa = PBXBuildFile; fileRef = 5686BD9C273D78B700329FA0 /* Animation.metal */; };
568807462747EEC000C95F55 /* PNSkeleton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568807452747EEC000C95F55 /* PNSkeleton.swift */; };
Expand Down Expand Up @@ -601,6 +602,7 @@
5677AD2628C1505000BF822C /* Array+Extension+Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+Extension+Tests.swift"; sourceTree = "<group>"; };
5677AD3028C151CA00BF822C /* XCTest+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTest+Extension.swift"; sourceTree = "<group>"; };
567F5C3C28A7AC3000AD0A6C /* NSImage+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSImage+Extension.swift"; sourceTree = "<group>"; };
56865D8B2EF955B20024896F /* MDLAxisAlignedBoundingBox+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MDLAxisAlignedBoundingBox+Extension.swift"; sourceTree = "<group>"; };
5686BD99273C1CD300329FA0 /* PNIStaticBuffer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNIStaticBuffer.swift; sourceTree = "<group>"; };
5686BD9B273D78A900329FA0 /* Animation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Animation.h; sourceTree = "<group>"; };
5686BD9C273D78B700329FA0 /* Animation.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = Animation.metal; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2014,6 +2016,7 @@
56D1ED592725F84C00D68EA7 /* ModelIO */ = {
isa = PBXGroup;
children = (
56865D8B2EF955B20024896F /* MDLAxisAlignedBoundingBox+Extension.swift */,
561666812719E2CC000063B1 /* MDLMaterialProperty+Extension.swift */,
561666832719E2CC000063B1 /* MDLTransformComponent+Extension.swift */,
561666862719E2CC000063B1 /* MDLMaterial+Extension.swift */,
Expand Down Expand Up @@ -2550,6 +2553,7 @@
5648531C28C9F26300BA4CC0 /* PNKeyframeAnimation.swift in Sources */,
5688076827483F4600C95F55 /* PNIMaterial.swift in Sources */,
5648532328CA154F00BA4CC0 /* PNISinglePlaySampler.swift in Sources */,
56865D8C2EF955B50024896F /* MDLAxisAlignedBoundingBox+Extension.swift in Sources */,
566795DA274FC561005993D7 /* PNEngine.swift in Sources */,
564DE040284169B9005C2029 /* Comparable+Global.swift in Sources */,
5620C8152754F3B60098D6FA /* PNSpotLight.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Copyright 漏 2025 Mateusz Stomp贸r. All rights reserved.
//

import ModelIO

extension MDLAxisAlignedBoundingBox {
var pnBound: PNBound {
PNBound(min: minBounds, max: maxBounds)
}
}
7 changes: 6 additions & 1 deletion Engine/Core/Import/SceneLoader/PNISceneLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ public final class PNISceneLoader: PNSceneLoader {
return translator.process(asset: asset)
}
public func resource(name: String, extension: String, bundle: Bundle) -> PNScene? {
let resourceRetrieval = psignposter.beginInterval("Resource retrieval")
guard let asset = assetLoader.resource(name: name, extension: `extension`, bundle: bundle) else {
return nil
}
return translator.process(asset: asset)
psignposter.endInterval("Resource retrieval", resourceRetrieval)
let sceneTranslation = psignposter.beginInterval("Scene translation")
let processedScene = translator.process(asset: asset)
psignposter.endInterval("Scene translation", sceneTranslation)
return processedScene
}
public static func `default`(device: MTLDevice) -> PNISceneLoader {
PNISceneLoader(device: device,
Expand Down
11 changes: 4 additions & 7 deletions Engine/Core/Import/Translator/PNISceneTranslator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import PNShared

public final class PNISceneTranslator: PNSceneTranslator {
private let device: MTLDevice
private let interactor = PNIBoundingBoxInteractor.default
private var materialCache = [String: PNMaterial]()
public init(device: MTLDevice) {
self.device = device
Expand All @@ -21,9 +22,7 @@ public final class PNISceneTranslator: PNSceneTranslator {
parent: passedValue)
passedValue?.children.append(node)
return node
} /* else if let object = object as? MDLLight {
fatalError("Not implemented")
} */ else if let object = object as? MDLMesh {
} else if let object = object as? MDLMesh {
guard let mesh = convert(mesh: object) else {
fatalError("Could not convert mesh")
}
Expand Down Expand Up @@ -110,7 +109,6 @@ public final class PNISceneTranslator: PNSceneTranslator {
assert(mesh.vertexBuffers.count == 1,
"Only object that have a single buffer assigned are supported")
let buffer = mesh.vertexBuffers[0].rawData
let bounds = PNIBoundEstimator().bound(vertexBuffer: buffer)
guard let deviceBuffer = device.makeBufferShared(data: buffer) else {
return nil
}
Expand Down Expand Up @@ -138,10 +136,9 @@ public final class PNISceneTranslator: PNSceneTranslator {
material: loadedMaterial)
pieceDescriptions.append(description)
}

}
let interactor = PNIBoundingBoxInteractor.default
return PNMesh(boundingBox: interactor.from(bound: bounds),

return PNMesh(boundingBox: interactor.from(bound: mesh.boundingBox.pnBound),
vertexBuffer: dataBuffer,
pieceDescriptions: pieceDescriptions)
}
Expand Down
Loading