Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-03-23 20:19:38 +0300
committerJacques Lucke <jacques@blender.org>2022-03-23 20:19:59 +0300
commitd67f9820b8f8376084adf5ad964c580c0944027f (patch)
tree0c3eb60c1d4c8f70a32239c715f1dcec814c677f /source/blender/blenlib/intern/math_geom.c
parent5d38b13e61ff04df6b8b4e52541910167225a18e (diff)
Curves: improve Comb brush
New supported features: * 3D/spherical brush that samples a good position on the curves. * Falloff. The custom falloff curve mapping is not yet available in the ui because that requires some more ui reorganization. This is better done when we have a better understanding of what settings we need exactly. Currently, the depth of the 3d brush is only sampled once per stroke, when first pressing LMB. Sometimes it is expected that the depth of the brush can change within a single brush. However, implementing that in a good way is not straight forward and might need additional options. Therefore that will be handled separately. Some experimentation results are in D14376. Ref T96445. Differential Revision: https://developer.blender.org/D14376
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r--source/blender/blenlib/intern/math_geom.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index bc3ed099fd5..e1ec22063e0 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -294,46 +294,48 @@ float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l
return sqrtf(dist_squared_to_line_segment_v2(p, l1, l2));
}
-void closest_to_line_segment_v2(float r_close[2],
- const float p[2],
- const float l1[2],
- const float l2[2])
+float closest_to_line_segment_v2(float r_close[2],
+ const float p[2],
+ const float l1[2],
+ const float l2[2])
{
float lambda, cp[2];
lambda = closest_to_line_v2(cp, p, l1, l2);
/* flip checks for !finite case (when segment is a point) */
- if (!(lambda > 0.0f)) {
+ if (lambda <= 0.0f) {
copy_v2_v2(r_close, l1);
+ return 0.0f;
}
- else if (!(lambda < 1.0f)) {
+ if (lambda >= 1.0f) {
copy_v2_v2(r_close, l2);
+ return 1.0f;
}
- else {
- copy_v2_v2(r_close, cp);
- }
+ copy_v2_v2(r_close, cp);
+ return lambda;
}
-void closest_to_line_segment_v3(float r_close[3],
- const float p[3],
- const float l1[3],
- const float l2[3])
+float closest_to_line_segment_v3(float r_close[3],
+ const float p[3],
+ const float l1[3],
+ const float l2[3])
{
float lambda, cp[3];
lambda = closest_to_line_v3(cp, p, l1, l2);
/* flip checks for !finite case (when segment is a point) */
- if (!(lambda > 0.0f)) {
+ if (lambda <= 0.0f) {
copy_v3_v3(r_close, l1);
+ return 0.0f;
}
- else if (!(lambda < 1.0f)) {
+ if (lambda >= 1.0f) {
copy_v3_v3(r_close, l2);
+ return 1.0f;
}
- else {
- copy_v3_v3(r_close, cp);
- }
+ copy_v3_v3(r_close, cp);
+ return lambda;
}
void closest_to_plane_v3(float r_close[3], const float plane[4], const float pt[3])