Dev:Source/Modifiers/Stack/ClipPlaneModifier
目次
Clip Plane Modifier
Modifier that allows you to use a control object (plane) to define a clip plane for the modified object.
- reference to a control object
- origin of control object determines clipping plane
- z is plane normal
- everything on negative side is kept (z negative), the rest is discarded. Cut edges where necessary.
- visualisation: currently no specific. Use a plane object.
documentation
cases to check
NOTE cases where vertices/edges lay on the clipping plane are not handled yet
For clipping faces I have identified 5 different cases to check, of which one is special. Three cases for quads and two for triangles. As said, most cases are simple, but one quad case is special, in that the resulting face needs to be split into two faces, since currently Blender doesn't allow faces with more than 4 edges. Cutting a corner from a quad would force it to be a 5-sided face. We'll have to ensure it ends up as a quad and a triangle.
The image shows the cases, 3 quad cases, 2 triangle cases. The normal for the clip plane (dashed line) is on the side, where no 'inset' is drawn. The inset depicts the new face(s) after the clipping procedure.
- quad gets clipped with cuts through opposite edges. Edgecount = 4, Vertcount = 4, DiscardVerts = 2. We have one quad face as result.
- quad gets clipped with cuts through neighbouring edges. Edgecount = 4, Vertcount = 4, DiscardVerts = 1. We get two new faces as result, a quad and a triangle
- quad gets clipped with cuts through neighbouring edges. Edgecount = 4, Vertcount = 4, DiscardVerts = 3. We have one triangle face as result.
- triangle gets clipped with cuts through neighbouring edges. Edgecount = 3, Vertcount = 3, DiscardVerts = 1. We have one quad face as result.
- triangle gets clipped with cuts through neighbouring edges. Edgecount = 3, Vertcount = 3, DiscardVerts = 2. We have one triangle face as result.
algorithm
- Project DerivedMesh into clip plane space.
- Tag vertices that get discarded CP_DISCARD
- Tag edges
- One vertex CP_DISCARD, edge is CP_CUT
- Two vertices CP_DISCARD, edge is CP_DISCARD
- Tag faces
- All vertices CP_DISCARD, face is CP_DISCARD
- At least one vertex not CP_DISCARD, at least one CP_DISCARD, face is CP_CUT
roadmap
- Version 1
- donesimple clipping on face level
- Version 2
- in progress 25%cut faces and edges nicely
- to doinvert (flip clip plane normal)
- to dosolid clipping
- Version 3
- to doimplement for bmesh
questions
- should user be allowed what axis of controlling object is clipping plane normal?
- invert option? (everything on positive side is kept)
patch
- Clip plane modifier Working patch v1, with jagged line. Nicely cut faces and edges is up next. Now also works in edit mode. (Current patch created against r10841).
demos
- version 1 (jagged line)
- While Editing
- Clip plane Animation
- another Clip plane usage
something to check out -> OpenCSG