Post

Replies

Boosts

Views

Activity

Reply to Adding custom material to sceneReconstruction mesh
@stevecfox Leaving this here in case someone else also wonders this, but coming from the GitHub the 'asSIMD3' is an extension of GeometrySource: extension GeometrySource { @MainActor func asArray<T>(ofType: T.Type) -> [T] { assert(MemoryLayout<T>.stride == stride, "Invalid stride \(MemoryLayout<T>.stride); expected \(stride)") return (0..<self.count).map { buffer.contents().advanced(by: offset + stride * Int($0)).assumingMemoryBound(to: T.self).pointee } } // SIMD3 has the same storage as SIMD4. @MainActor func asSIMD3<T>(ofType: T.Type) -> [SIMD3<T>] { return asArray(ofType: (T, T, T).self).map { .init($0.0, $0.1, $0.2) } } }
Topic: Graphics & Games SubTopic: RealityKit Tags:
Aug ’24
Reply to Adding custom material to sceneReconstruction mesh
@stevecfox Leaving this here in case someone else also wonders this, but coming from the GitHub the 'asSIMD3' is an extension of GeometrySource: extension GeometrySource { @MainActor func asArray<T>(ofType: T.Type) -> [T] { assert(MemoryLayout<T>.stride == stride, "Invalid stride \(MemoryLayout<T>.stride); expected \(stride)") return (0..<self.count).map { buffer.contents().advanced(by: offset + stride * Int($0)).assumingMemoryBound(to: T.self).pointee } } // SIMD3 has the same storage as SIMD4. @MainActor func asSIMD3<T>(ofType: T.Type) -> [SIMD3<T>] { return asArray(ofType: (T, T, T).self).map { .init($0.0, $0.1, $0.2) } } }
Topic: Graphics & Games SubTopic: RealityKit Tags:
Replies
Boosts
Views
Activity
Aug ’24