[Bf-blender-cvs] [82a36962346] sculpt-dev: sculpt-dev: Improve roll texture mapping mode
Joseph Eagar
noreply at git.blender.org
Wed Oct 19 10:09:00 CEST 2022
Commit: 82a369623460e3e974a9f9fed9dddd0df2b8e4aa
Author: Joseph Eagar
Date: Wed Oct 19 01:07:33 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB82a369623460e3e974a9f9fed9dddd0df2b8e4aa
sculpt-dev: Improve roll texture mapping mode
===================================================================
M release/scripts/startup/bl_ui/properties_paint_common.py
M source/blender/blenlib/BLI_arc_spline.hh
M source/blender/editors/sculpt_paint/paint_intern.h
M source/blender/editors/sculpt_paint/paint_stroke.cc
M source/blender/editors/sculpt_paint/sculpt.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 141be2fa514..6d4b1af20f4 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -760,7 +760,6 @@ class UnifiedPaintPanel:
ch = UnifiedPaintPanel.get_channel(context, brush, prop_name)
if ch is not None:
- print("FOUND CH", ch.idname)
prop_owner = ch
prop_name = "value"
diff --git a/source/blender/blenlib/BLI_arc_spline.hh b/source/blender/blenlib/BLI_arc_spline.hh
index a3c925a0499..4bc1ba9db21 100644
--- a/source/blender/blenlib/BLI_arc_spline.hh
+++ b/source/blender/blenlib/BLI_arc_spline.hh
@@ -546,7 +546,7 @@ template<typename Float, int axes = 2> class BezierSpline {
Float start = s - ds;
Float end = s;
Float mid = (start + end) * 0.5;
- const int binary_steps = 4;
+ const int binary_steps = 10;
for (int j = 0; j < binary_steps; j++) {
Vector dvmid = derivative(mid);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 58c104a9663..871d7de0f84 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -171,6 +171,7 @@ typedef struct PaintStroke {
StrokeDone done;
float spacing;
+ float spacing_raw;
void *debug_draw_handle;
bool original;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.cc b/source/blender/editors/sculpt_paint/paint_stroke.cc
index c837d4f86f1..f4043d6ea8f 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.cc
+++ b/source/blender/editors/sculpt_paint/paint_stroke.cc
@@ -7,10 +7,10 @@
#include "MEM_guardedalloc.h"
+#include "BLI_arc_spline.hh"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rand.h"
-#include "BLI_arc_spline.hh"
#include "BLI_utildefines.h"
#include "PIL_time.h"
@@ -58,14 +58,21 @@ using blender::float3;
static void paint_stroke_add_sample(
const Paint *paint, PaintStroke *stroke, float x, float y, float pressure);
-#define DRAW_DEBUG_VIS
+//#define DRAW_DEBUG_VIS
static int paint_stroke_max_points(const Paint *paint, PaintStroke *stroke)
{
- float s = max_ff(stroke->spacing, 0.05);
+ if (!stroke->has_cubic_stroke) {
+ return 1;
+ }
+
+ float s = max_ff(stroke->spacing_raw, 0.05);
- return stroke->has_cubic_stroke ? 8.0 : 1;
- return stroke->has_cubic_stroke ? (int)(1.0f / s + 4.5f) : 1;
+ int tot = (int)ceilf(1.0f / s) + 2;
+ tot = max_ii(tot, 5);
+
+ // return stroke->has_cubic_stroke ? 8.0 : 1;
+ return tot;
}
static int paint_stroke_max_samples(const Paint *paint, PaintStroke *stroke)
@@ -109,15 +116,6 @@ static void paint_brush_cubic_vis(const bContext *C, ARegion *region, void *user
float t = 0.0f, dt = 1.0f / (float)(steps - 1);
immUniformColor4ub(45, 75, 255, 255);
- immBegin(GPU_PRIM_LINE_STRIP, steps);
-
- for (int i = 0; i < steps; i++, t += dt) {
- float co[3], tan[3];
-
- evaluate_cubic_bezier(ss->cache->world_cubic, t, co, tan);
- immVertex3fv(pos, co);
- }
- immEnd();
immBegin(GPU_PRIM_LINE_STRIP, steps);
@@ -142,17 +140,21 @@ static void paint_brush_cubic_vis(const bContext *C, ARegion *region, void *user
float3 co = stroke->world_spline->evaluate(s);
# endif
+ mul_v3_m4v3(co, ob->obmat, co);
immVertex3fv(pos, co);
}
immEnd();
- immUniformColor4ub(0, 255, 25, 255);
+ immUniformColor4ub(0, 255, 25, 55);
for (int is_points = 0; is_points < 2; is_points++) {
immBegin(is_points ? GPU_PRIM_POINTS : GPU_PRIM_LINE_STRIP, stroke->num_points);
for (int i = 0; i < stroke->num_points; i++) {
int idx = (i + stroke->cur_point) % stroke->num_points;
- immVertex3fv(pos, stroke->points[idx].location);
+ float3 co = stroke->points[idx].location;
+ mul_v3_m4v3(co, ob->obmat, co);
+
+ immVertex3fv(pos, co);
}
immEnd();
}
@@ -472,10 +474,10 @@ void paint_calc_cubic_uv_v3(
PaintStroke *stroke, StrokeCache *cache, const float co[3], float r_out[3], float r_tan[3])
{
float3 tan;
- float3 p = stroke->world_spline->closest_point(co, r_out[0], tan, r_out[1]);
+ float3 p = stroke->world_spline->closest_point(co, r_out[1], tan, r_out[0]);
r_tan = tan;
- r_out[1] = len_v3v3(p, co);
+ r_out[0] = len_v3v3(p, co);
r_out[2] = 0.0f;
float3 vec = p - float3(co);
@@ -484,7 +486,7 @@ void paint_calc_cubic_uv_v3(
cross_v3_v3v3(vec2, vec, tan);
if (dot_v3v3(vec2, cache->view_normal) < 0.0f) {
- r_out[1] = -r_out[1];
+ r_out[0] = -r_out[0];
}
}
@@ -861,25 +863,38 @@ static void paint_brush_stroke_add_step(
PaintStrokePoint *point;
PaintStrokePoint temp;
- paint_stroke_add_point(paint,
- stroke,
- mouse_in,
- mouse_out,
- location,
- ups->pixel_radius,
- pressure,
- stroke->pen_flip,
- stroke->x_tilt,
- stroke->y_tilt);
+ int n = 1;
+ int max_points = paint_stroke_max_points(paint, stroke);
+
+ if (stroke->num_points < max_points) {
+ // n = max_points - stroke->num_points;
+ }
+ for (int i = 0; i < n; i++) {
+ paint_stroke_add_point(paint,
+ stroke,
+ mouse_in,
+ mouse_out,
+ location,
+ ups->pixel_radius,
+ pressure,
+ stroke->pen_flip,
+ stroke->x_tilt,
+ stroke->y_tilt);
+ if (stroke->has_cubic_stroke) {
+ paint_brush_make_cubic(stroke);
+ }
+ }
if (stroke->has_cubic_stroke) {
- if (stroke->num_points < paint_stroke_max_points(paint, stroke)) {
+ // paint_brush_make_cubic(stroke);
+
+ if (stroke->spline->segments.size() < paint_stroke_max_points(paint, stroke)) {
return;
}
- int cur = stroke->cur_point - (paint_stroke_max_points(paint, stroke) >> 1);
+ int cur = stroke->cur_point - (paint_stroke_max_points(paint, stroke) >> 1) - 2;
+ cur = (cur + stroke->num_points) % stroke->num_points;
- paint_brush_make_cubic(stroke);
PaintStrokePoint *p1 = stroke->points + ((cur + stroke->num_points) % stroke->num_points);
PaintStrokePoint *p2 = stroke->points +
((cur - 1 + stroke->num_points) % stroke->num_points);
@@ -1010,6 +1025,8 @@ static float paint_space_stroke_spacing(bContext *C,
else {
spacing = BRUSHSET_GET_FINAL_FLOAT(stroke->brush->channels, sd->channels, spacing, &mapping);
}
+
+ stroke->spacing_raw = spacing * 0.01;
}
else {
spacing = stroke->brush->spacing;
@@ -1017,6 +1034,8 @@ static float paint_space_stroke_spacing(bContext *C,
if (stroke->brush->flag & BRUSH_SPACING_PRESSURE) {
spacing = spacing * (1.5f - spacing_pressure);
}
+
+ stroke->spacing_raw = spacing * 0.01;
}
if (SCULPT_is_cloth_deform_brush(brush)) {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c4277d2c3cc..44f71677573 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4133,14 +4133,12 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
paint_calc_cubic_uv_v3(
ss->cache->stroke, ss->cache, SCULPT_vertex_co_get(ss, vertex), point_3d, tan);
- point_3d[1] = (ss->cache->radius + point_3d[1]) * 0.5f;
-
/* Calc global distance. */
float t1 = ss->cache->last_stroke_distance_t;
- float t2 = point_3d[0] / ss->cache->radius;
+ float t2 = point_3d[1] / ss->cache->radius;
- point_3d[0] = t1 + t2;
- point_3d[0] *= ss->cache->radius;
+ point_3d[1] = t1 + t2;
+ point_3d[1] *= ss->cache->radius;
#if 0
if (SCULPT_has_colors(ss)) {
More information about the Bf-blender-cvs
mailing list