forked from blender/blender
Cleanup: Reduce use and scope of templates in vertex paint #2
@ -1023,7 +1023,7 @@ static void ccgDM_release(DerivedMesh *dm)
|
|||||||
if (ccgdm->multires.modified_flags) {
|
if (ccgdm->multires.modified_flags) {
|
||||||
/* Check that mmd still exists */
|
/* Check that mmd still exists */
|
||||||
if (!ccgdm->multires.local_mmd &&
|
if (!ccgdm->multires.local_mmd &&
|
||||||
BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0)
|
BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) == -1)
|
||||||
{
|
{
|
||||||
ccgdm->multires.mmd = nullptr;
|
ccgdm->multires.mmd = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -3009,6 +3009,36 @@ static void do_vpaint_brush_blur_loops(bContext *C,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Use rgb^2 color averaging. */
|
||||||
|
Color *col = &color_final;
|
||||||
|
|
||||||
|
color_final.r = Traits::round(sqrtf(Traits::divide_round(blend[0], total_hit_loops)));
|
||||||
|
color_final.g = Traits::round(sqrtf(Traits::divide_round(blend[1], total_hit_loops)));
|
||||||
|
color_final.b = Traits::round(sqrtf(Traits::divide_round(blend[2], total_hit_loops)));
|
||||||
|
color_final.a = Traits::round(sqrtf(Traits::divide_round(blend[3], total_hit_loops)));
|
||||||
|
|
||||||
|
/* For each poly owning this vert,
|
||||||
|
* paint each loop belonging to this vert. */
|
||||||
|
for (const int j : gmap->vert_to_poly[v_index].index_range()) {
|
||||||
|
const int p_index = gmap->vert_to_poly[v_index][j];
|
||||||
|
const int l_index = gmap->vert_to_loop[v_index][j];
|
||||||
|
BLI_assert(ss->corner_verts[l_index] == v_index);
|
||||||
|
if (use_face_sel && !select_poly[p_index]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Color color_orig(0, 0, 0, 0); /* unused when array is nullptr */
|
||||||
|
|
||||||
|
if (previous_color != nullptr) {
|
||||||
|
/* Get the previous loop color */
|
||||||
|
if (isZero(previous_color[l_index])) {
|
||||||
|
previous_color[l_index] = lcol[l_index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (total_hit_loops == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Use rgb^2 color averaging. */
|
/* Use rgb^2 color averaging. */
|
||||||
Color *col = &;
|
Color *col = &;
|
||||||
|
|
||||||
@ -3039,8 +3069,12 @@ static void do_vpaint_brush_blur_loops(bContext *C,
|
|||||||
brush_alpha_pressure * grid_alpha;
|
brush_alpha_pressure * grid_alpha;
|
||||||
/* Mix the new color with the original
|
/* Mix the new color with the original
|
||||||
* based on the brush strength and the curve. */
|
* based on the brush strength and the curve. */
|
||||||
lcol[l_index] = vpaint_blend<Color, Traits>(
|
lcol[l_index] = vpaint_blend<Color, Traits>(vp,
|
||||||
vp, lcol[l_index], color_orig, *col, final_alpha, Traits::range * brush_strength);
|
lcol[l_index],
|
||||||
|
color_orig,
|
||||||
|
*col,
|
||||||
|
final_alpha,
|
||||||
|
Traits::range * brush_strength);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3110,13 +3144,15 @@ static void do_vpaint_brush_blur_verts(bContext *C,
|
|||||||
}
|
}
|
||||||
|
|
||||||
float brush_strength = cache->bstrength;
|
float brush_strength = cache->bstrength;
|
||||||
const float angle_cos = (use_normal && vd.no) ? dot_v3v3(sculpt_normal_frontface, vd.no) :
|
const float angle_cos = (use_normal && vd.no) ?
|
||||||
|
dot_v3v3(sculpt_normal_frontface, vd.no) :
|
||||||
1.0f;
|
1.0f;
|
||||||
if (!test_brush_angle_falloff(
|
if (!test_brush_angle_falloff(
|
||||||
*brush, vpd->normal_angle_precalc, angle_cos, &brush_strength)) {
|
*brush, vpd->normal_angle_precalc, angle_cos, &brush_strength)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
|
const float brush_fade = BKE_brush_curve_strength(
|
||||||
|
brush, sqrtf(test.dist), cache->radius);
|
||||||
|
|
||||||
/* Get the average poly color */
|
/* Get the average poly color */
|
||||||
to_static_color_type(vpd->type, [&](auto dummy) {
|
to_static_color_type(vpd->type, [&](auto dummy) {
|
||||||
@ -3174,8 +3210,12 @@ static void do_vpaint_brush_blur_verts(bContext *C,
|
|||||||
brush_alpha_pressure * grid_alpha;
|
brush_alpha_pressure * grid_alpha;
|
||||||
/* Mix the new color with the original
|
/* Mix the new color with the original
|
||||||
* based on the brush strength and the curve. */
|
* based on the brush strength and the curve. */
|
||||||
lcol[v_index] = vpaint_blend<Color, Traits>(
|
lcol[v_index] = vpaint_blend<Color, Traits>(vp,
|
||||||
vp, lcol[v_index], color_orig, *col, final_alpha, Traits::range * brush_strength);
|
lcol[v_index],
|
||||||
|
color_orig,
|
||||||
|
*col,
|
||||||
|
final_alpha,
|
||||||
|
Traits::range * brush_strength);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3261,13 +3301,15 @@ static void do_vpaint_brush_smear(bContext *C,
|
|||||||
/* Calculate the dot prod. between ray norm on surf and current vert
|
/* Calculate the dot prod. between ray norm on surf and current vert
|
||||||
* (ie splash prevention factor), and only paint front facing verts. */
|
* (ie splash prevention factor), and only paint front facing verts. */
|
||||||
float brush_strength = cache->bstrength;
|
float brush_strength = cache->bstrength;
|
||||||
const float angle_cos = (use_normal && vd.no) ? dot_v3v3(sculpt_normal_frontface, vd.no) :
|
const float angle_cos = (use_normal && vd.no) ?
|
||||||
|
dot_v3v3(sculpt_normal_frontface, vd.no) :
|
||||||
1.0f;
|
1.0f;
|
||||||
if (!test_brush_angle_falloff(
|
if (!test_brush_angle_falloff(
|
||||||
*brush, vpd->normal_angle_precalc, angle_cos, &brush_strength)) {
|
*brush, vpd->normal_angle_precalc, angle_cos, &brush_strength)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
|
const float brush_fade = BKE_brush_curve_strength(
|
||||||
|
brush, sqrtf(test.dist), cache->radius);
|
||||||
|
|
||||||
bool do_color = false;
|
bool do_color = false;
|
||||||
/* Minimum dot product between brush direction and current
|
/* Minimum dot product between brush direction and current
|
||||||
@ -3554,13 +3596,15 @@ static void vpaint_do_draw(bContext *C,
|
|||||||
/* Calc the dot prod. between ray norm on surf and current vert
|
/* Calc the dot prod. between ray norm on surf and current vert
|
||||||
* (ie splash prevention factor), and only paint front facing verts. */
|
* (ie splash prevention factor), and only paint front facing verts. */
|
||||||
float brush_strength = cache->bstrength;
|
float brush_strength = cache->bstrength;
|
||||||
const float angle_cos = (use_normal && vd.no) ? dot_v3v3(sculpt_normal_frontface, vd.no) :
|
const float angle_cos = (use_normal && vd.no) ?
|
||||||
|
dot_v3v3(sculpt_normal_frontface, vd.no) :
|
||||||
1.0f;
|
1.0f;
|
||||||
if (!test_brush_angle_falloff(
|
if (!test_brush_angle_falloff(
|
||||||
*brush, vpd->normal_angle_precalc, angle_cos, &brush_strength)) {
|
*brush, vpd->normal_angle_precalc, angle_cos, &brush_strength)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
|
const float brush_fade = BKE_brush_curve_strength(
|
||||||
|
brush, sqrtf(test.dist), cache->radius);
|
||||||
|
|
||||||
to_static_color_type(vpd->type, [&](auto dummy) {
|
to_static_color_type(vpd->type, [&](auto dummy) {
|
||||||
using Color = decltype(dummy);
|
using Color = decltype(dummy);
|
||||||
@ -3614,8 +3658,8 @@ static void vpaint_do_draw(bContext *C,
|
|||||||
}
|
}
|
||||||
color_orig = previous_color[l_index];
|
color_orig = previous_color[l_index];
|
||||||
}
|
}
|
||||||
const float final_alpha = Traits::frange * brush_fade * brush_strength * tex_alpha *
|
const float final_alpha = Traits::frange * brush_fade * brush_strength *
|
||||||
brush_alpha_pressure * grid_alpha;
|
tex_alpha * brush_alpha_pressure * grid_alpha;
|
||||||
|
|
||||||
/* Mix the new color with the original based on final_alpha. */
|
/* Mix the new color with the original based on final_alpha. */
|
||||||
lcol[l_index] = vpaint_blend<Color, Traits>(vp,
|
lcol[l_index] = vpaint_blend<Color, Traits>(vp,
|
||||||
@ -4078,7 +4122,8 @@ bool BKE_object_attributes_active_color_fill(Object *ob,
|
|||||||
const float fill_color[4],
|
const float fill_color[4],
|
||||||
bool only_selected)
|
bool only_selected)
|
||||||
{
|
{
|
||||||
return paint_object_attributes_active_color_fill_ex(ob, ColorPaint4f(fill_color), only_selected);
|
return paint_object_attributes_active_color_fill_ex(
|
||||||
|
ob, ColorPaint4f(fill_color), only_selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vertex_color_set_exec(bContext *C, wmOperator * /*op*/)
|
static int vertex_color_set_exec(bContext *C, wmOperator * /*op*/)
|
||||||
|
@ -658,7 +658,7 @@ static void rna_ArmatureConstraint_target_remove(
|
|||||||
bArmatureConstraint *acon = static_cast<bArmatureConstraint *>(con->data);
|
bArmatureConstraint *acon = static_cast<bArmatureConstraint *>(con->data);
|
||||||
bConstraintTarget *tgt = static_cast<bConstraintTarget *>(target_ptr->data);
|
bConstraintTarget *tgt = static_cast<bConstraintTarget *>(target_ptr->data);
|
||||||
|
|
||||||
if (BLI_findindex(&acon->targets, tgt) < 0) {
|
if (BLI_findindex(&acon->targets, tgt) == -1) {
|
||||||
BKE_report(reports, RPT_ERROR, "Target is not in the constraint target list");
|
BKE_report(reports, RPT_ERROR, "Target is not in the constraint target list");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1474,8 +1474,9 @@ static Sequence *rna_SeqTimelineChannel_owner_get(Editing *ed, SeqTimelineChanne
|
|||||||
if (seq->type != SEQ_TYPE_META) {
|
if (seq->type != SEQ_TYPE_META) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (BLI_findindex(&seq->channels, channel) >= 0) {
|
if (BLI_findindex(&seq->channels, channel) != -1) {
|
||||||
channel_owner = seq;
|
channel_owner = seq;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +280,8 @@ int seq_get_shown_sequences(const Scene *scene,
|
|||||||
scene, channels, seqbase, timeline_frame, chanshown);
|
scene, channels, seqbase, timeline_frame, chanshown);
|
||||||
const int strip_count = BLI_gset_len(collection->set);
|
const int strip_count = BLI_gset_len(collection->set);
|
||||||
|
|
||||||
if (strip_count > MAXSEQ) {
|
if (UNLIKELY(strip_count > MAXSEQ)) {
|
||||||
|
SEQ_collection_free(collection);
|
||||||
BLI_assert_msg(0, "Too many strips, this shouldn't happen");
|
BLI_assert_msg(0, "Too many strips, this shouldn't happen");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1878,7 +1879,7 @@ static ImBuf *seq_render_strip_stack(const SeqRenderData *context,
|
|||||||
ImBuf *out = NULL;
|
ImBuf *out = NULL;
|
||||||
|
|
||||||
count = seq_get_shown_sequences(
|
count = seq_get_shown_sequences(
|
||||||
context->scene, channels, seqbasep, timeline_frame, chanshown, (Sequence **)&seq_arr);
|
context->scene, channels, seqbasep, timeline_frame, chanshown, seq_arr);
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -377,7 +377,7 @@ ListBase *SEQ_get_seqbase_by_seq(const Scene *scene, Sequence *seq)
|
|||||||
if (seq_meta != NULL) {
|
if (seq_meta != NULL) {
|
||||||
return &seq_meta->seqbase;
|
return &seq_meta->seqbase;
|
||||||
}
|
}
|
||||||
if (BLI_findindex(main_seqbase, seq) >= 0) {
|
if (BLI_findindex(main_seqbase, seq) != -1) {
|
||||||
return main_seqbase;
|
return main_seqbase;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1950,7 +1950,7 @@ void wm_window_delete_removed_timers(wmWindowManager *wm)
|
|||||||
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
|
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
|
||||||
{
|
{
|
||||||
/* Extra security check. */
|
/* Extra security check. */
|
||||||
if (BLI_findindex(&wm->timers, timer) < 0) {
|
if (BLI_findindex(&wm->timers, timer) == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user