Page MenuHome

Curves: Add brush to add curves on surface.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Feb 28 2022, 3:22 PM.

Details

Summary

This adds a prototype for the first brush that can add new curves by painting on a surface. Note that this can only be used when the curves object has a surface object set in the properties panel.

The brush can take a minimum distance into account. This allows distributing curves with a somewhat consistent density.

When this brush is in, we have the basics for creating, deforming and deleting curves. With all that boilerplate out of the way, we can start to focus on the actual behavior of the brushes.

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Feb 28 2022, 3:22 PM
Jacques Lucke (JacquesLucke) created this revision.

Testing this, the main thing I feel I'm missing are a a way to set a specific value for the final density, that isn't dependent on zoom level. I think that would be a much more solid control, especially since it mirrors the real world quite well.

Other than that, a way to decide the final length would be nice. Though I understand it can be interpolated from the surroundings too, it would be nice to have explicit control sometimes.

If you want to look into those suggestions now, or you would prefer to save feedback on functionality for later, that's fine either way I think.

source/blender/blenlib/BLI_hash.hh
151

Is this still necessary? Seems to compile without it.

source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
217–220

I think it would be helpful to have some comments here. For example, some things I had to figure out when reading this code:

  • Why can there be multiple cached KDTrees? Do they each have the same meaning?
  • Which KDTree does cached_kdtrees_size_ correspond to, all of them? It's not the length of the vector, right?
  • It looks like DummyIndex is used to represent curves that existed before the stroke started? It could have a more specific name then.
237

clang tidy complains that this doesn't have override or final annotation. Same with the other functions of the same name in this file actually.

449–451

Isn't using references here "taking address of an rvalue"?

471–472

IMO attribute_math::mix3 would be preferable here, I think it does the same thing. Hrmm, or maybe it replaces interp_weights_tri_v3

Testing this, the main thing I feel I'm missing are a a way to set a specific value for the final density, that isn't dependent on zoom level.

Well, the distance setting isn't dependent on zoom level. I had a density setting first, but found it much less convenient to use. When I picture a density in my head I think e.g. "I want a curve every 2 cm". Computing the corresponding density value from that isn't straight forward.

Other than that, a way to decide the final length would be nice. Though I understand it can be interpolated from the surroundings too, it would be nice to have explicit control sometimes.

Obviously somewhat important in general, but I wouldn't want to add more tool settings for that just yet.

source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
449–451

Well, it's complicated :D
You're right that I shouldn't use references here. However, this still works, because the lifetime of the temporary object is extended by binding it to a reference (also see https://en.cppreference.com/w/cpp/language/lifetime).

For example, I'd like to type "1mm" and get a distribution of human hairs on a head that's somewhat accurate to real life.

In the test above the distance is basically doing what I want, I think.
I don't think the description for the distance property is totally accurate, since it's not just a distance from existing curve roots, but also curve roots newly added during the stroke.

Also, I guess the "Distance" property shouldn't display for brushes that don't use it.

  • Merge branch 'master' into add-curves-brush
  • change distance description
  • only show distance when necessary

For example, I'd like to type "1mm" and get a distribution of human hairs on a head that's somewhat accurate to real life.

Yeah, that is what it should do.

This revision is now accepted and ready to land.Mar 2 2022, 5:09 PM