Mesh Separation in Houdini: VEX Point Push vs. Boolean Expansion
09 Sep 26 (1d ago)
When resolving collisions, preventing intersections between adjoining parts, or creating clearance tolerances for 3D printing and rigging, you generally have two routes:
- The VEX Approach: Pushing points away along vector offsets dynamically without modifying mesh topology.
- The SOP Approach: Expanding geometry boundaries (via
PolyExpand2D/Extrude/Peak) and running aBoolean SOP.
Here is a breakdown of how the point-push snippet works, why swapping nearpoint for xyzdist gives better surface fidelity, and how the Boolean expansion alternative stacks up.
1. The VEX Method: Distance-Based Push
Your initial snippet calculates the vector from the target back to @P and enforces a minimum safety margin:
// Run over: Points
// Input 0: Geometry to push
// Input 1: Collision obstacle / target mesh
float min_dist = chf("min_distance");
// Locate the nearest point on Input 1
int closest_pt = nearpoint(1, @P);
vector target_pos = point(1, "P", closest_pt);
float current_dist = distance(@P, target_pos);
// Enforce separation if points violate clearance threshold
if (current_dist < min_dist) {
vector push_dir = @P - target_pos;
// Safety guard against zero-length vectors when points overlap exactly
if (length(push_dir) < 0.00001) {
push_dir = set(0, 1, 0);
}
push_dir = normalize(push_dir);
// Project point along push vector to match exact clearance margin
@P = target_pos + (push_dir * min_dist);
}
The Pitfall: nearpoint() vs. xyzdist()
nearpoint() only tests against explicit point indices on the second input. If Input 1 is a low-poly mesh or a box with large flat faces, the points on Input 0 will pull toward the box's corners instead of pushing straight off the flat walls.
To make this push cleanly against the true polygonal surface:
// Run over: Points
float min_dist = chf("min_distance");
int hit_prim;
vector hit_uv;
// Sample the actual closest polygon surface rather than point vertices
float current_dist = xyzdist(1, @P, hit_prim, hit_uv);
if (current_dist < min_dist) {
vector target_pos = primuv(1, "P", hit_prim, hit_uv);
vector push_dir = @P - target_pos;
if (length(push_dir) < 0.00001) {
// Fallback to the surface normal if points overlap perfectly
push_dir = primuv(1, "N", hit_prim, hit_uv);
}
@P = target_pos + (normalize(push_dir) * min_dist);
}
2. The Alternative: Expanding Both & Boolean Cut
What about expanding both objects (e.g., using a Peak SOP or PolyExpand) and using a Boolean SOP to cut and control the intersection angle?
This is a common modeling workflow, but it serves a very different purpose than point pushing.
[Input Geo A] ──> [Peak / Expand] ──┐
├──> [Boolean SOP (Subtract / Union)] ──> [Clean Topology?]
[Input Geo B] ──> [Peak / Expand] ──┘
Advantages of Boolean Expansion
- Exact Geometric Clearance: If you are manufacturing parts or prepping models for 3D printing (where you need an exact 0.4mm tolerance gap between interlocking parts), expanding a cutter geometry and subtracting it with a Boolean guarantees physical clearance.
- Angular Control: You can bevel, chamfer, or draft the cutter's edges before the cut, giving you precise angular control over mating seams.
- Volume-Aware: Unlike simple point offsets, Booleans resolve solid interiors cleanly.
Disadvantages vs. VEX Push
- Topology Destruction: Booleans slice through edges, creating ngons, sliver triangles, and broken UV seams. If your geometry needs deformation rigging or clean subdivision surfaces, Booleans require downstream retopology.
- Performance Overhead: A VEX point push runs virtually instantaneously on hundreds of thousands of points. Boolean operations on dense geometry are computationally heavy and prone to open-edge or coplanar errors.
Comparison: When to Use Which
| Requirement | VEX Surface Push | Boolean Expansion |
|---|---|---|
| Preserve UVs & Topology | Yes (P-only deformation) | No (Slices and generates new vertices) |
| Animation / Deforming Rigs | Yes (Runs real-time per frame) | No (Causes topology jitter frame-to-frame) |
| 3D Printing / Mating Tolerances | Difficult on complex folds | Yes (Exact volumetric subtraction) |
| Performance | Extremely fast (C++ multithreaded) | Slower, memory-intensive |
| Setup Complexity | Single wrangle node | Multi-node chain (Expand $\to$ Boolean $\to$ Clean) |
Use the VEX push when you need soft clearance adjustments, collision avoidance on character meshes, or procedural layout spacing without modifying your point counts. Reserve the Boolean expansion workflow when generating final hard-surface booleans, mold seams, or mechanical clearances where topological purity is secondary to exact solid clearance.