Geometry Nodes: Add float solver to mesh boolean node #119294

Merged
Howard Trickey merged 18 commits from howardt/blender:exactboolv2_staging into main 2024-03-14 20:50:06 +01:00
Member

This adds a "Solver" option to the geo boolean node, with the options Exact and Float.
The current geo boolean node only uses the Exact solver. This adds the ability to use the faster original floating point boolean solver. The float solver has issues with coplanar and other coincident geometry, but is generally much faster than the Exact solver, and users have asked for this option (which is available in the Boolean Modifier and edit mode boolean tool).

Like the modifier, the Float solver needs to convert the Mesh to BMesh, do the operation, and then convert back to Mesh. It also has to do it iteratively if more than two operands are supplied.

This is the first of a planned series of commits that will add a new exact boolean solver, based on the Ember paper, as a solver option. Ember will be much faster than the current exact solver, but may still not be as fast as float, and also will not handle some non-volume-enclosing inputs as well as Float, so it is likely tha the Float solver will always remain. We may eventually retire the old Exact Solver, however.

This commit also prepares for more sensible code in the future by doing two things:

  • moves the boolean glue code out of blenkernel and into the geometry module
  • changes the internal enum names for the solvers to better reflect the algorithms used: Fast -> Float, and Exact -> Mesh_Arr (which means "Mesh Arrangments, the name of the paper upon which the current exact solver is based).
This adds a "Solver" option to the geo boolean node, with the options Exact and Float. The current geo boolean node only uses the Exact solver. This adds the ability to use the faster original floating point boolean solver. The float solver has issues with coplanar and other coincident geometry, but is generally much faster than the Exact solver, and users have asked for this option (which is available in the Boolean Modifier and edit mode boolean tool). Like the modifier, the Float solver needs to convert the Mesh to BMesh, do the operation, and then convert back to Mesh. It also has to do it iteratively if more than two operands are supplied. This is the first of a planned series of commits that will add a new exact boolean solver, based on the Ember paper, as a solver option. Ember will be much faster than the current exact solver, but may still not be as fast as float, and also will not handle some non-volume-enclosing inputs as well as Float, so it is likely tha the Float solver will always remain. We may eventually retire the old Exact Solver, however. This commit also prepares for more sensible code in the future by doing two things: - moves the boolean glue code out of blenkernel and into the geometry module - changes the internal enum names for the solvers to better reflect the algorithms used: Fast -> Float, and Exact -> Mesh_Arr (which means "Mesh Arrangments, the name of the paper upon which the current exact solver is based).
Howard Trickey added 6 commits 2024-03-10 20:53:47 +01:00
f23184bcd2 Geometry Nodes: Add float solver to mesh boolean.
Not completely implemented or tested yet.
Also moved mesh boolean stuff from kernel to geometry module.
Also renamed solver enums: Fast ->Float, Exact->Mesh_Arr,
to better reflect the algorithms used and prepare for future
Mesh_Ember solver.
Howard Trickey requested review from Hans Goudey 2024-03-10 20:54:36 +01:00
Hans Goudey requested changes 2024-03-11 15:25:37 +01:00
Hans Goudey left a comment
Member

Great! I think it would be good to move the existing mesh_boolean_convert.cc (which doesn't seem to be removed here BTW?) to the geometry module first in a separate commit with minimal changes so that git history is preserved. Other than that this PR seems reasonable.

Great! I think it would be good to move the existing `mesh_boolean_convert.cc` (which doesn't seem to be removed here BTW?) to the geometry module first in a separate commit with minimal changes so that git history is preserved. Other than that this PR seems reasonable.
@ -0,0 +919,4 @@
BMLoop *(**r_looptris)[3],
int *r_looptris_tot)
{
const int n = meshes.size();
Member

Personally I find this single letter variable name hurts readability below, I had to go check what it was set to, compared to seeing meshes.size() or meshes.index_range() below

Personally I find this single letter variable name hurts readability below, I had to go check what it was set to, compared to seeing `meshes.size()` or `meshes.index_range()` below
Author
Member

changed n to meshes_num and used meshes.index_range() in loops.

changed n to meshes_num and used meshes.index_range() in loops.
HooglyBoogly marked this conversation as resolved
@ -0,0 +1051,4 @@
const float4x4 &target_transform,
Span<Array<short>> material_remaps,
int boolean_mode,
Vector<int> * /* r_intersecting_edges */)
Member

Could just remove this argument i think

Could just remove this argument i think
Author
Member

I think I may want to implement the intersecting edges return at some point (if users complain), so would like to leave this as is for now.

I think I may want to implement the intersecting edges return at some point (if users complain), so would like to leave this as is for now.
HooglyBoogly marked this conversation as resolved
@ -0,0 +1090,4 @@
Array<float4x4> two_transforms = {transforms[0], transforms[1]};
Array<Array<short>> two_remaps = {material_remaps[0], material_remaps[1]};
for (int i = 0; i < nmesh - 1; i++) {
BMesh *bm = mesh_bm_concat(two_meshes.as_span(),
Member

.as_span() should be unnecessary, the conversion from Array to Span can be done implicitly

`.as_span()` should be unnecessary, the conversion from `Array` to `Span` can be done implicitly
Author
Member

You are right, so I removed the .as_span()'s here. (There is an earlier case of a ? : operation where it was needed).

You are right, so I removed the .as_span()'s here. (There is an earlier case of a ? : operation where it was needed).
HooglyBoogly marked this conversation as resolved
@ -0,0 +1116,4 @@
/* Except in the first iteration, two_meshes[0] holds the intermediate
* mesh result from the previous iteraiton. */
Mesh *me = const_cast<Mesh*>(two_meshes[0]);
BKE_mesh_eval_delete(me);
Member

What's going on here with the const cast and BKE_mesh_eval_delete? That seems potentially problematic

What's going on here with the const cast and `BKE_mesh_eval_delete`? That seems potentially problematic
Author
Member

I found a better way to do what I needed to do without requiring the const_cast. The strange code before was there because I was using two_meshes for mixed purposes.

I found a better way to do what I needed to do without requiring the const_cast. The strange code before was there because I was using two_meshes for mixed purposes.
HooglyBoogly marked this conversation as resolved
@ -0,0 +1140,4 @@
return nullptr;
}
Mesh *GEO_mesh_boolean(Span<const Mesh *> meshes,
Member

The GEO_ prefix is a relic of C code with no namespaces. Now this can just be mesh_boolean I guess

The `GEO_` prefix is a relic of C code with no namespaces. Now this can just be `mesh_boolean` I guess
Author
Member

Thanks. I thought I had seen something in the style guide about doing this, but when I looked again, I couldn't find it.

Thanks. I thought I had seen something in the style guide about doing this, but when I looked again, I couldn't find it.
HooglyBoogly marked this conversation as resolved
@ -0,0 +1157,4 @@
material_remaps,
op_params.boolean_mode,
r_intersecting_edges);
break;
Member

break unnecessary after return

`break` unnecessary after `return`
Author
Member

removed the break

removed the break
HooglyBoogly marked this conversation as resolved
@ -0,0 +1169,4 @@
r_intersecting_edges);
break;
default:
BLI_assert(false);
Member

BLI_assert_unreachable()

`BLI_assert_unreachable()`
Author
Member

fixed

fixed
HooglyBoogly marked this conversation as resolved
@ -0,0 +1171,4 @@
default:
BLI_assert(false);
}
return BKE_mesh_new_nomain(0, 0, 0, 0);
Member

Returning null should be okay here IMO

Returning null should be okay here IMO
Author
Member

sure, changed.

sure, changed.
HooglyBoogly marked this conversation as resolved
@ -2660,6 +2660,11 @@ typedef enum GeometryNodeBooleanOperation {
GEO_NODE_BOOLEAN_DIFFERENCE = 2,
} GeometryNodeBooleanOperation;
typedef enum GeometryNodeBooleanSolver {
Member

How about defining this in GEO_mesh_boolean.hh in the boolean namespace as:

enum class Solver {
  Float = 0,
  MeshArr = 1,
};
How about defining this in `GEO_mesh_boolean.hh` in the boolean namespace as: ``` enum class Solver { Float = 0, MeshArr = 1, }; ```
Author
Member

Hmm, somehow I thought everything that was serialized to a .blend file as an enum value needed to be declared in this style in a DNA_.h file. But I guess not. OK, I'll make this change, which I certainly like.

Hmm, somehow I thought everything that was serialized to a .blend file as an enum value needed to be declared in this style in a DNA_<somthing>.h file. But I guess not. OK, I'll make this change, which I certainly like.
Author
Member

Note that it does require some casts to ints now, but that's OK.

Note that it does require some casts to ints now, but that's OK.
HooglyBoogly marked this conversation as resolved
@ -486,3 +481,1 @@
hole_tolerant,
bmd->operation,
nullptr);
const GeometryNodeBooleanOperation op = static_cast<GeometryNodeBooleanOperation>(
Member

Functional style cast (GeometryNodeBooleanOperation(...)) is used for enum casts as well

Functional style cast (`GeometryNodeBooleanOperation(...)`) is used for enum casts as well
Author
Member

fixed

fixed
HooglyBoogly marked this conversation as resolved
Howard Trickey added 2 commits 2024-03-14 03:39:59 +01:00
Howard Trickey added 1 commit 2024-03-14 03:40:53 +01:00
Hans Goudey added 8 commits 2024-03-14 18:07:11 +01:00
Hans Goudey changed title from WIP: Add float solver to geo boolean node to Geometry Nodes: Add float solver to mesh boolean node 2024-03-14 18:07:21 +01:00
Hans Goudey approved these changes 2024-03-14 18:07:58 +01:00
Member

@blender-bot build

@blender-bot build
Howard Trickey added 1 commit 2024-03-14 20:44:20 +01:00
Howard Trickey merged commit e3f030cce6 into main 2024-03-14 20:50:06 +01:00
Howard Trickey deleted branch exactboolv2_staging 2024-03-14 20:50:09 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#119294
No description provided.