Skip to content

Commit

Permalink
Add warning when detecting negative genus (#15736)
Browse files Browse the repository at this point in the history
* Add warning when detecting negative genus

* revert unwanted changes

* .

* .
  • Loading branch information
deltakosh authored Oct 24, 2024
1 parent 186edd6 commit 6df1c6b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/dev/core/src/Meshes/csg2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class CSG2 implements IDisposable {

private _process(operation: "difference" | "intersection" | "union", csg: CSG2) {
if (this.numProp !== csg.numProp) {
throw new Error("CSG must have the same number of properties");
throw new Error("CSG must be used with geometries having the same number of properties");
}
return new CSG2(Manifold[operation](this._manifold, csg._manifold), this.numProp, this._vertexStructure);
}
Expand Down Expand Up @@ -301,11 +301,18 @@ export class CSG2 implements IDisposable {
const manifoldMesh = new ManifoldMesh({ numProp: numProp, vertProperties, triVerts, runIndex, runOriginalID });
manifoldMesh.merge();

let returnValue: CSG2;
try {
return new CSG2(new Manifold(manifoldMesh), numProp, structure);
returnValue = new CSG2(new Manifold(manifoldMesh), numProp, structure);
} catch (e) {
throw new Error("Error while creating the CSG: " + e.message);
}

if (returnValue._manifold.genus() < 0) {
throw new Error("Incorrect volume detected. Make sure you are not using a double sided geometry");
}

return returnValue;
}

private static _Construct(data: IVertexDataLike, worldMatrix: Nullable<Matrix>, runIndex?: Uint32Array, runOriginalID?: Uint32Array) {
Expand Down

0 comments on commit 6df1c6b

Please sign in to comment.