Skip to content

Commit 29cd39a

Browse files
committed
Rename SplatScenePoint to SplatPoint and EncodedSplat to EncodedSplatPoint
- Add SplatScenePoint typealiase for backwards compatibility
1 parent 61710a8 commit 29cd39a

23 files changed

+110
-100
lines changed

MetalSplatter/Resources/ShaderCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ typedef struct
7070
Uniforms uniforms[kMaxViewCount];
7171
} UniformsArray;
7272

73-
// Keep in sync with EncodedSplat
73+
// Keep in sync with EncodedSplatPoint
7474
typedef struct
7575
{
7676
packed_float3 position;

MetalSplatter/Sources/EncodedSplat.swift renamed to MetalSplatter/Sources/EncodedSplatPoint.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct PackedRGBHalf4 {
2222
}
2323

2424
// Keep in sync with Shaders.metal : Splat
25-
public struct EncodedSplat {
25+
public struct EncodedSplatPoint {
2626
var position: MTLPackedFloat3
2727
var colorSH0: PackedRGBHalf4 // sh0 color + opacity
2828
var covA: PackedHalf3
@@ -31,8 +31,8 @@ public struct EncodedSplat {
3131

3232
// MARK: - Splat Conversion
3333

34-
extension EncodedSplat {
35-
public init(_ splat: SplatScenePoint) {
34+
extension EncodedSplatPoint {
35+
public init(_ splat: SplatPoint) {
3636
self.init(position: splat.position,
3737
colorSH0: splat.color.sh0,
3838
opacity: splat.opacity.asLinearFloat,
@@ -43,7 +43,7 @@ extension EncodedSplat {
4343
/// Creates a splat with explicit raw SH0 coefficients.
4444
/// - Parameters:
4545
/// - position: World-space position
46-
/// - colorSH0: SH degree-0 coefficients (NOT sRGB color; use `SplatScenePoint.Color.sh0` to convert)
46+
/// - colorSH0: SH degree-0 coefficients (NOT sRGB color; use `SplatPoint.Color.sh0` to convert)
4747
/// - opacity: Linear opacity (0-1)
4848
/// - scale: Linear scale
4949
/// - rotation: Rotation quaternion
@@ -60,3 +60,8 @@ extension EncodedSplat {
6060
covB: PackedHalf3(x: Float16(cov3D[1, 1]), y: Float16(cov3D[1, 2]), z: Float16(cov3D[2, 2])))
6161
}
6262
}
63+
64+
// MARK: - Deprecated
65+
66+
@available(*, deprecated, renamed: "EncodedSplatPoint")
67+
public typealias EncodedSplat = EncodedSplatPoint

MetalSplatter/Sources/SplatChunk+sortByLocality.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension SplatChunk {
6767
}
6868
}
6969

70-
fileprivate extension MetalBuffer where T == EncodedSplat {
70+
fileprivate extension MetalBuffer where T == EncodedSplatPoint {
7171
// Define a bounding box which doesn't quite include all the splats, just most of them
7272
func bounds(withinSigmaMultiple sigmaMultiple: Float) -> (min: SIMD3<Float>, max: SIMD3<Float>) {
7373
var sum = SIMD3<Float>.zero

MetalSplatter/Sources/SplatChunk.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct ChunkID: Hashable, Sendable, Equatable {
1818
/// Created externally and added to a SplatRenderer via `addChunk(_:)`.
1919
public struct SplatChunk: @unchecked Sendable {
2020
/// The splat data buffer
21-
public let splats: MetalBuffer<EncodedSplat>
21+
public let splats: MetalBuffer<EncodedSplatPoint>
2222

2323
/// Optional buffer containing higher-order spherical harmonics coefficients.
2424
/// This is nil for SH degree 0 (view-independent color).
@@ -39,7 +39,7 @@ public struct SplatChunk: @unchecked Sendable {
3939
/// - splats: The Metal buffer containing splat data (with raw SH0 in color field)
4040
/// - shCoefficients: Optional buffer with higher-order SH coefficients (nil for SH0)
4141
/// - shDegree: The spherical harmonics degree for this chunk
42-
public init(splats: MetalBuffer<EncodedSplat>,
42+
public init(splats: MetalBuffer<EncodedSplatPoint>,
4343
shCoefficients: MetalBuffer<Float16>? = nil,
4444
shDegree: SHDegree = .sh0) {
4545
self.splats = splats
@@ -52,16 +52,16 @@ public struct SplatChunk: @unchecked Sendable {
5252
/// - device: Metal device for buffer allocation
5353
/// - points: Array of scene points with SH data
5454
public init(device: MTLDevice,
55-
from points: [SplatScenePoint]) throws {
55+
from points: [SplatPoint]) throws {
5656
// Determine the SH degree from the data
5757
let shDegree = points.first?.color.shDegree ?? .sh0
5858

5959
// Create splat buffer - always stores raw SH0 coefficients
60-
let splatBuffer = try MetalBuffer<EncodedSplat>(device: device, capacity: points.count)
60+
let splatBuffer = try MetalBuffer<EncodedSplatPoint>(device: device, capacity: points.count)
6161
splatBuffer.count = points.count
6262

6363
for (i, point) in points.enumerated() {
64-
splatBuffer.values[i] = EncodedSplat(point)
64+
splatBuffer.values[i] = EncodedSplatPoint(point)
6565
}
6666

6767
// Create SH coefficient buffer if we have higher-order SH

MetalSplatter/Sources/SplatRenderer+Deprecated.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import SplatIO
44

55
/// Deprecated convenience methods and type aliases for backwards compatibility.
66
extension SplatRenderer {
7-
@available(*, deprecated, renamed: "EncodedSplat")
8-
public typealias Splat = EncodedSplat
7+
@available(*, deprecated, renamed: "EncodedSplatPoint")
8+
public typealias Splat = EncodedSplatPoint
99
}
1010

1111
/// Deprecated convenience methods for backwards compatibility.
@@ -23,11 +23,11 @@ extension SplatRenderer {
2323
/// Adds splat points as a new chunk.
2424
/// - Parameter points: The splat points to add
2525
/// - Note: This method creates a single chunk containing all provided splats.
26-
@available(*, deprecated, message: "Use SplatChunk and addChunk(_:) instead. Create a MetalBuffer<EncodedSplat>, wrap in SplatChunk, then call addChunk.")
27-
public func add(_ points: [SplatScenePoint]) async throws {
28-
let buffer = try MetalBuffer<EncodedSplat>(device: device)
26+
@available(*, deprecated, message: "Use SplatChunk and addChunk(_:) instead. Create a MetalBuffer<EncodedSplatPoint>, wrap in SplatChunk, then call addChunk.")
27+
public func add(_ points: [SplatPoint]) async throws {
28+
let buffer = try MetalBuffer<EncodedSplatPoint>(device: device)
2929
try buffer.ensureCapacity(points.count)
30-
buffer.append(points.map { EncodedSplat($0) })
30+
buffer.append(points.map { EncodedSplatPoint($0) })
3131

3232
let chunk = SplatChunk(splats: buffer, shCoefficients: nil, shDegree: .sh0)
3333
await addChunk(chunk)
@@ -37,7 +37,7 @@ extension SplatRenderer {
3737
/// - Parameter point: The splat point to add
3838
/// - Note: This method creates a single chunk containing the provided splat.
3939
@available(*, deprecated, message: "Use SplatChunk and addChunk(_:) instead.")
40-
public func add(_ point: SplatScenePoint) async throws {
40+
public func add(_ point: SplatPoint) async throws {
4141
try await add([point])
4242
}
4343

MetalSplatter/Sources/SplatSorter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Synchronization
55

66
/**
77
SplatSorter creates a sorted list of splat indices across multiple chunks. It is given a reference to
8-
an array of chunk buffers (each a MetalBuffer<EncodedSplat>), which may be periodically updated
8+
an array of chunk buffers (each a MetalBuffer<EncodedSplatPoint>), which may be periodically updated
99
using the exclusive access mechanism described below. On each frame, a renderer provides the latest camera
1010
pose, and then obtains a reference to the latest sorted list of chunked splat indices, which may be one or
1111
more frames out-of-date. After rendering is completed, it explicitly releases this reference. Between
@@ -88,7 +88,7 @@ class SplatSorter: @unchecked Sendable {
8888
/// Represents a chunk for sorting purposes
8989
struct ChunkReference {
9090
let chunkIndex: UInt16
91-
let buffer: MetalBuffer<EncodedSplat>
91+
let buffer: MetalBuffer<EncodedSplatPoint>
9292
}
9393

9494
private struct IndexBuffer {

MetalSplatter/Tests/ChunkTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ final class ChunkTests: XCTestCase {
3838
// MARK: - SplatChunk Tests
3939

4040
func testSplatChunkCreation() throws {
41-
let buffer = try MetalBuffer<EncodedSplat>(device: device)
41+
let buffer = try MetalBuffer<EncodedSplatPoint>(device: device)
4242
let chunk = SplatChunk(splats: buffer)
4343

4444
XCTAssertEqual(chunk.splatCount, 0)
4545
}
4646

4747
func testSplatChunkSplatCount() throws {
48-
let buffer = try MetalBuffer<EncodedSplat>(device: device)
48+
let buffer = try MetalBuffer<EncodedSplatPoint>(device: device)
4949
try buffer.ensureCapacity(5)
5050
for i in 0..<5 {
5151
buffer.append(makeSplat(at: SIMD3<Float>(Float(i), 0, 0)))
@@ -75,8 +75,8 @@ final class ChunkTests: XCTestCase {
7575

7676
// MARK: - Helper Functions
7777

78-
func makeSplat(at position: SIMD3<Float>) -> EncodedSplat {
79-
EncodedSplat(position: position,
78+
func makeSplat(at position: SIMD3<Float>) -> EncodedSplatPoint {
79+
EncodedSplatPoint(position: position,
8080
colorSH0: SIMD3<Float>(1, 1, 1),
8181
opacity: 1.0,
8282
scale: SIMD3<Float>(0.1, 0.1, 0.1),
@@ -107,16 +107,16 @@ final class SplatRendererChunkTests: XCTestCase {
107107
}
108108

109109
func makeChunk(splatCount: Int) throws -> SplatChunk {
110-
let buffer = try MetalBuffer<EncodedSplat>(device: device)
110+
let buffer = try MetalBuffer<EncodedSplatPoint>(device: device)
111111
try buffer.ensureCapacity(splatCount)
112112
for i in 0..<splatCount {
113113
buffer.append(makeSplat(at: SIMD3<Float>(Float(i), 0, 0)))
114114
}
115115
return SplatChunk(splats: buffer)
116116
}
117117

118-
func makeSplat(at position: SIMD3<Float>) -> EncodedSplat {
119-
EncodedSplat(position: position,
118+
func makeSplat(at position: SIMD3<Float>) -> EncodedSplatPoint {
119+
EncodedSplatPoint(position: position,
120120
colorSH0: SIMD3<Float>(1, 1, 1),
121121
opacity: 1.0,
122122
scale: SIMD3<Float>(0.1, 0.1, 0.1),

MetalSplatter/Tests/SplatSorterTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ final class SplatSorterTests: XCTestCase {
77
var device: MTLDevice!
88

99
/// Helper to create a test splat at a given position
10-
func makeSplat(at position: SIMD3<Float>) -> EncodedSplat {
11-
EncodedSplat(position: position,
10+
func makeSplat(at position: SIMD3<Float>) -> EncodedSplatPoint {
11+
EncodedSplatPoint(position: position,
1212
colorSH0: SIMD3<Float>(1, 1, 1),
1313
opacity: 1.0,
1414
scale: SIMD3<Float>(0.1, 0.1, 0.1),
1515
rotation: simd_quatf(ix: 0, iy: 0, iz: 0, r: 1))
1616
}
1717

1818
/// Helper to create a splat buffer with test data
19-
func makeSplatBuffer(positions: [SIMD3<Float>]) throws -> MetalBuffer<EncodedSplat> {
20-
let buffer = try MetalBuffer<EncodedSplat>(device: device)
19+
func makeSplatBuffer(positions: [SIMD3<Float>]) throws -> MetalBuffer<EncodedSplatPoint> {
20+
let buffer = try MetalBuffer<EncodedSplatPoint>(device: device)
2121
try buffer.ensureCapacity(positions.count)
2222
for position in positions {
2323
buffer.append(makeSplat(at: position))
@@ -329,7 +329,7 @@ final class SplatSorterTests: XCTestCase {
329329

330330
func testEmptyChunks() async throws {
331331
let sorter = try SplatSorter(device: device)
332-
let emptyBuffer = try MetalBuffer<EncodedSplat>(device: device)
332+
let emptyBuffer = try MetalBuffer<EncodedSplatPoint>(device: device)
333333
let chunk = SplatSorter.ChunkReference(chunkIndex: 0, buffer: emptyBuffer)
334334

335335
sorter.setChunks([chunk])

SplatConverter/Sources/SplatConverter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct SplatConverter: AsyncParsableCommand {
112112
let outputLabel: String?
113113
var error: Swift.Error?
114114

115-
var points: [SplatScenePoint] = []
115+
var points: [SplatPoint] = []
116116
var currentOffset = 0
117117
var readCount = 0
118118

@@ -130,7 +130,7 @@ struct SplatConverter: AsyncParsableCommand {
130130
self.outputLabel = outputLabel
131131
}
132132

133-
func didRead(points: [SplatIO.SplatScenePoint]) {
133+
func didRead(points: [SplatIO.SplatPoint]) {
134134
readCount += points.count
135135

136136
let newCurrentOffset = currentOffset + points.count

SplatIO/Sources/AutodetectSceneReader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class AutodetectSceneReader: SplatSceneReader {
1111
self.url = url
1212
}
1313

14-
public func read() async throws -> AsyncThrowingStream<[SplatScenePoint], Swift.Error> {
14+
public func read() async throws -> AsyncThrowingStream<[SplatPoint], Swift.Error> {
1515
let reader: SplatSceneReader =
1616
switch SplatFileFormat(for: url) {
1717
case .ply: try SplatPLYSceneReader(url)

0 commit comments

Comments
 (0)