From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

Clipping Brush

Task for now:

Working

When a user clicks on the mesh while selecting clip brush, the brush will clip the region which lies in projection of the brush. For instance, assume the brush as a cylinder with its planar face lying towards the viewer screen or we can say the axis of brush lies normal to system's screen. When a user clicks on the surface of the mesh, the portion of vertices enclosed by that cylinder gets clipped and a plane get create in clipped surface.

How will it work

Initially I was thinking of deleting the vertices that has been enclosed by the cylinder and then create new faces and vertices in the hollow portion that will be created by deleting vertices, to get a closed surface. But deleting vertices from inside sculpt mode is kind of difficult so maybe I will be implementing it in future. For now, I have think of a new method inspired from ZBrush clipping option. There are two part/method to implement this:

Method one

In this, The main task will be to push the enclosed vertices in that cylinder to the surface of the cylinder along the normal to axis of cylinder.

Basic algorithm for this

Assume:

  • test.no = normal from plane of brush i.e. direction of axis of brush.
  • ss = location of center of brush.
  • vd.co = coordinate of single vertex
  • foot = foot of perpendicular of vd.co in axis of brush.
  • length = squared length between vd.co and foot.
  • r = squared radius of brush.

According to vector algebra,
New position of vertex should be [foot + (radius / length)*(vd.co - foot)].
But this will not work as desired because it pushes all vertex towards the curved surface of brush cylinder and this will create a big circular planar region with a circular face in mesh. How to solve it?

  • We will use the mouse dragging direction to define the orientation of vertices just like what rotate brush do. Using this concept, a basic model of clipping brush can be done.
Clip Brush Method One Implemented

// Also, This brush will work only on that portion of mesh, where it meets the empty space in 3dview. Since we are pushing the vertices instead of deleting it, it will be a limitation of the brush for now.

Method Two

In above method of pushing vertices, the problem is about the vertices which lies outside the domain of brush where vertex gets pushed effectively. So, to detect this vertex, I will be finding intersecting point of brush and portion of mesh where it touches space in 3dview plane. Then, this data will be used to check whether vertex should be pushed normally as in method one or distribute it in boundary as per its initially location. We can find this new coordinate by simple geometry. Currently I am trying initial method and later I will use that mouse drag option.
My recent commits implementing this method are commits