Page MenuHome

Stroke world spacing option for sculpt mode
AcceptedPublic

Authored by Pablo Dobarro (pablodp606) on Wed, Aug 7, 6:07 PM.

Details

Summary

With the "Use world spacing" option enabled, the distance to generate a new stroke step is calculated in world space using the cursor position over the mesh. This avoids artifacts when sculpting across curved surfaces.

The main problem with this is that screen space and world space units for the spacing property don't match. Ideally, I would like this conversion to be automatic instead of adding another spacing property for world spacing.
Also, this is using sculpt_stroke_get_location, so it won't work when the PBVH is not available.

Diff Detail

Repository
rB Blender
Branch
brush-world-spacing (branched from master)
Build Status
Buildable 4501
Build 4501: arc lint + arc unit

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Fri, Aug 16, 2:29 PM

For the units, I guess you have two options:

  • Make a separate spacing property that is in world space.
  • At the start of the stroke, compute the world space distance that corresponds to the mouse spacing, and use that for the rest of the stroke.
source/blender/editors/sculpt_paint/paint_stroke.c
97

Less obscure name: last_world_space_position

540–541

Put this test in a utility function, like paint_stroke_use_world_spacing, to avoid duplication.

770

Similarly could use more clear names, p_ prefix doesn't explain much.

785

This is suspicious, I would expect this to be dependent on scene scale and DPI?

This revision now requires changes to proceed.Fri, Aug 16, 2:29 PM
Pablo Dobarro (pablodp606) marked 4 inline comments as done.Fri, Aug 16, 4:58 PM
Pablo Dobarro (pablodp606) edited the summary of this revision. (Show Details)
Pablo Dobarro (pablodp606) updated this revision to Diff 17200.
  • Update for revision, calculate world spacing using brush radius

@Brecht Van Lommel (brecht) The world space distance between brush steps is now calculated as a percentage of the object space brush radius, so when the new cursor is merged, a 100% spacing will produce a new step at the same distance you are seeing in the size of the cursor. This way the spacing property can be shared and the results are similar.

This revision is now accepted and ready to land.Fri, Aug 16, 6:30 PM
  • Fix artifact when the stroke is not over the mesh

@Brecht Van Lommel (brecht) I updated the patch because I found that it was producing some artifacts. I solved some of them, but there is still the limitation of the brush code being 2D based. To get rid of those artifacts, I need to send the interpolated 3D world location of the stroke directly to the paint modes instead of the 2D mouse location. We need to do that at some point to support VR interaction and more advanced brush effects, but I think that should be done in another patch. Can I still commit this?

For the UI, we should really use an enum rather than a toggle. When you disable Use World Spacing, it's not clear which spacing is then used. To avoid these kinds of ambiguities when switching between different modes or types, we use enums.

This is similar to the Radius Unit property:

  • Update UI and naming