Dev:Source/Modifiers/Stack/ClipPlaneModifier

提供: wiki
< Dev:Source‎ | Modifiers‎ | Stack
2018年6月29日 (金) 02:51時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

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

Clipping faces

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.

  1. quad gets clipped with cuts through opposite edges. Edgecount = 4, Vertcount = 4, DiscardVerts = 2. We have one quad face as result.
  2. 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
  3. quad gets clipped with cuts through neighbouring edges. Edgecount = 4, Vertcount = 4, DiscardVerts = 3. We have one triangle face as result.
  4. triangle gets clipped with cuts through neighbouring edges. Edgecount = 3, Vertcount = 3, DiscardVerts = 1. We have one quad face as result.
  5. triangle gets clipped with cuts through neighbouring edges. Edgecount = 3, Vertcount = 3, DiscardVerts = 2. We have one triangle face as result.

algorithm

  1. Project DerivedMesh into clip plane space.
  2. Tag vertices that get discarded CP_DISCARD
  3. Tag edges
    1. One vertex CP_DISCARD, edge is CP_CUT
    2. Two vertices CP_DISCARD, edge is CP_DISCARD
  4. Tag faces
    1. All vertices CP_DISCARD, face is CP_DISCARD
    2. At least one vertex not CP_DISCARD, at least one CP_DISCARD, face is CP_CUT

roadmap

  • Version 1
    • done
       simple clipping on face level
  • Version 2
    • in progress Inprogress25.jpg 25%
       cut faces and edges nicely
    • to do
       invert (flip clip plane normal)
    • to do
       solid clipping
  • Version 3
    • to do
       implement 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

JesterKing

something to check out -> OpenCSG