Skip to content

SCMesh is missing textureData after meshing is done #50

@1agora

Description

@1agora

greetings all, perhaps anyone can point me to the right direction on this issue:

  • scanning + viewing works perfectly.
  • SCPointCloud is fine, no issues
  • Mesh is displayed in color and all is well.
  • crashing while OBJZip saving the mesh (or even accessing textureData), which is unexpectedly nil.
  • textureHeight and width is 0
  • SCReconstructionManager.includesColorBuffersInMetadata = true
  • SCReconstructionManager.includesDepthBuffersInMetadata = true

SCMesh:
image

SCMeshTexturing:
image

here is the code:

private func _processMeshTexturingIntoMesh(withPointCloud pointCloud: SCPointCloud,
                                               meshTexturing: SCMeshTexturing,
                                               completion: @escaping ((Result<SCMesh, Error>) -> Void)) {
        meshingProgressView.isHidden = false
        meshingProgressView.setProgress(0, animated: false)
        
        let meshingParameters = SCMeshingParameters()
        meshingParameters.resolution = 5
        meshingParameters.smoothness = 2
        meshingParameters.surfaceTrimmingAmount = 5
        meshingParameters.closed = true
        
        _meshingHelper = SCMeshingHelper(pointCloud: pointCloud, meshTexturing: meshTexturing, meshingParameters: meshingParameters)
        
        _meshingHelper?.processMesh(coloringStrategy: .vertex) { meshingStatus in
            DispatchQueue.main.async {
                switch meshingStatus {
                case .inProgress(let progress):
                    self.meshingProgressView.setProgress(progress, animated: false)
                case .failure(let error):
                    self.meshingProgressView.isHidden = true
                    completion(.failure(error))    // Error is guaranteed to be set for the failure case
                    
                case .success(let mesh):
                    self.meshingProgressView.isHidden = true

                        let zip_url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("Scan.zip")
                        
                        if mesh.writeToOBJZip(atPath: zip_url.path) {
                            print("Mesh ZIP saved.")
                        } 

                        print("🌶🌶🌶 textureData: \(mesh.textureData.count / 1024)kb") // EXC_BAD_ACCESS crash here
                        print("🌶🌶🌶 texCoordData: \(mesh.texCoordData.count / 1024)kb")
                        
                        print("🌶🌶🌶 textureWidth: \(mesh.textureWidth)")
                        print("🌶🌶🌶 textureWidth: \(mesh.textureHeight)")
                        
                    completion(.success(mesh))
                }
            }
        }
    }

and here's the error:

image

what can be the reason? any help greatly appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions