Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when detecting negative genus #15736

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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