Crash in Mesh.subtract
mgrider opened this issue · 3 comments
mgrider commented
Here's what I'm trying to do: Use Euclid in a ARKit app.
Here's what I did:
- Create a new “Augmented Reality” project in Xcode. (12.5.)
- You’ll need to select
SceneKit
in the “Content Technology” dropdown.
- You’ll need to select
- Add the Euclid as a Swift Package Manager dependency.
- Go to:
File > Swift Packages > Add Package Dependency
- Add
https://github.com/nicklockwood/ShapeScript.git
- Go to:
- Open
ViewController.swift
- add
import Euclid
at the top of the file. - Comment out (or delete) the line of code that creates a new scene from
ship.scn
- Added the following lines in its place (these are from the EuclidExample project):
- add
// Create a new scene
let scene = SCNScene()
// create and add a camera to the scene
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode)
// place the camera
cameraNode.position = SCNVector3(x: 0, y: 0, z: 3)
// create some geometry using Euclid
let start = CFAbsoluteTimeGetCurrent()
let cube = Mesh.cube(size: 0.8, material: UIColor.red)
let sphere = Mesh.sphere(slices: 120, material: UIColor.blue)
let mesh = cube.subtract(sphere)
print("Time:", CFAbsoluteTimeGetCurrent() - start)
print("Polys:", mesh.polygons.count)
// create SCNNode
let geometry = SCNGeometry(mesh)
let node = SCNNode(geometry: geometry)
scene.rootNode.addChildNode(node)
- Provisioning bs...
- Build and run on my device. (iPhone 12 Pro Max)
I get this crash:
The app does build and run in the iPhone 12 Pro Max simulator, with the following in the logs:
2021-06-17 11:53:03.035867-0500 EuclidSKAR[9123:636030] Metal GPU Frame Capture Enabled
2021-06-17 11:53:03.036055-0500 EuclidSKAR[9123:636030] Metal API Validation Enabled
Time: 12.664151072502136
Polys: 3574
2021-06-17 11:53:16.680852-0500 EuclidSKAR[9123:639525] fopen failed for data file: errno = 2 (No such file or directory)
2021-06-17 11:53:16.680957-0500 EuclidSKAR[9123:639525] Errors found! Invalidating cache...
2021-06-17 11:53:16.943133-0500 EuclidSKAR[9123:639525] fopen failed for data file: errno = 2 (No such file or directory)
2021-06-17 11:53:16.943270-0500 EuclidSKAR[9123:639525] Errors found! Invalidating cache...
Interestingly observations:
- The example project does build and run on my phone.
- I get the same error even if I add all the code above in a background thread.
mgrider commented
I just realized that probably this issue would be more relevant over on the Euclid repo than here. Sorry about that. Want me to move it over there?
mgrider commented
I removed the ShapeScript dependency entirely, and re-added Euclid, and now I do get the error in the simulator. I'll re-make this issue on the Euclid repo. Sorry for the confusion.
nicklockwood commented
@mgrider yes please :-)