Skip to content

v1.0.2 — Point-cloud rendering pipeline (closes #28)

Choose a tag to compare

@gsdali gsdali released this 09 May 12:08
b6c0e7c

Highlights

Adds a Metal point-sprite rendering pipeline so ViewportBody.vertices can be drawn as visible disc-masked points, gated by a new BodyPrimitiveKind.point discriminator. Closes #28.

This unblocks OCCTMCP's add_scene_primitive(pointCloud) to lift its 256-point cap and switch from sphere-compound synthesis to PointConverter.pointsToBody (already shipped in OCCTSwiftTools v1.0.1).

What's new

ViewportBody

  • New BodyPrimitiveKind enum (.mesh / .point / .wire) — named to avoid collision with the existing pick-result PrimitiveKind (.face/.edge/.vertex).
  • New fields: primitiveKind (default .mesh), pointRadius (default 0.05, world units), vertexColors (default []).
  • boundingBox now falls back to vertices when vertexData is empty, so cloud bodies frame correctly for shadow / CameraState.fit(to:).
  • All defaults preserve full source compatibility — every existing ViewportBody.init call site continues to construct .mesh bodies unchanged.

Renderer

  • visiblePointPipeline added to both ViewportRenderer (live MTKView) and OffscreenRenderer (headless). MSAA, premultiplied-alpha blending.
  • World-space point radius projected to screen pixels via pxPerWorldFactor / clipPosition.w — single formula handles both perspective and orthographic. [[point_size]] clamped to [1, 64] (Apple GPU upper limit).
  • Mesh + wireframe paths skip .point bodies; the new pass walks them once after the main body loop.

Picking

Unchanged. The existing point-sprite pick pass already runs on body.vertices and tags hits with kind=2 — .point bodies are pickable out of the box.

Source compatibility

Change Compatibility
BodyPrimitiveKind enum Additive
ViewportBody.primitiveKind Defaulted to .mesh — additive
ViewportBody.pointRadius Defaulted to 0.05 — additive
ViewportBody.vertexColors Defaulted to [] — additive
_BodyPrimitiveKind re-export Additive
Existing ViewportBody.init parameters Unchanged order

No deprecations. No removals. No required changes for downstream consumers, including the demo app and OCCTMCP.

Pinning

Component Version
OCCTSwift (transitive in demo) 1.0.1
OCCTSwiftTools (demo) 1.0.0
OCCT family 8.0.0 GA
Swift 6.0+
iOS 18+
macOS 15+

Tests

  • 61/61 passing (was 57; +4 new in ViewportPointCloudRenderingTests).
  • Acceptance test: 10k-point cloud renders with verified non-background pixel coverage.
  • Per-vertex colour override + mismatched-length fallback covered.
  • Existing demo smoke + measurement overlay tests unchanged.

Pull request

#29

Issue

Closes #28.