Cleanup: style, use braces for draw
This commit is contained in:
@@ -319,31 +319,49 @@ static void eevee_draw_background(void *vedata)
|
||||
/* Debug : Output buffer to view. */
|
||||
switch (G.debug_value) {
|
||||
case 1:
|
||||
if (txl->maxzbuffer) DRW_transform_to_display(txl->maxzbuffer, false, false);
|
||||
if (txl->maxzbuffer) {
|
||||
DRW_transform_to_display(txl->maxzbuffer, false, false);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (effects->ssr_pdf_output) DRW_transform_to_display(effects->ssr_pdf_output, false, false);
|
||||
if (effects->ssr_pdf_output) {
|
||||
DRW_transform_to_display(effects->ssr_pdf_output, false, false);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (effects->ssr_normal_input) DRW_transform_to_display(effects->ssr_normal_input, false, false);
|
||||
if (effects->ssr_normal_input) {
|
||||
DRW_transform_to_display(effects->ssr_normal_input, false, false);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (effects->ssr_specrough_input) DRW_transform_to_display(effects->ssr_specrough_input, false, false);
|
||||
if (effects->ssr_specrough_input) {
|
||||
DRW_transform_to_display(effects->ssr_specrough_input, false, false);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (txl->color_double_buffer) DRW_transform_to_display(txl->color_double_buffer, false, false);
|
||||
if (txl->color_double_buffer) {
|
||||
DRW_transform_to_display(txl->color_double_buffer, false, false);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (effects->gtao_horizons_debug) DRW_transform_to_display(effects->gtao_horizons_debug, false, false);
|
||||
if (effects->gtao_horizons_debug) {
|
||||
DRW_transform_to_display(effects->gtao_horizons_debug, false, false);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (effects->gtao_horizons) DRW_transform_to_display(effects->gtao_horizons, false, false);
|
||||
if (effects->gtao_horizons) {
|
||||
DRW_transform_to_display(effects->gtao_horizons, false, false);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (effects->sss_data) DRW_transform_to_display(effects->sss_data, false, false);
|
||||
if (effects->sss_data) {
|
||||
DRW_transform_to_display(effects->sss_data, false, false);
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (effects->velocity_tx) DRW_transform_to_display(effects->velocity_tx, false, false);
|
||||
if (effects->velocity_tx) {
|
||||
DRW_transform_to_display(effects->velocity_tx, false, false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -222,8 +222,12 @@ static GPUShader *eevee_lights_get_store_sh(int shadow_method, bool high_blur, b
|
||||
|
||||
ds_frag = BLI_dynstr_new();
|
||||
BLI_dynstr_append(ds_frag, (shadow_method == SHADOW_VSM) ? "#define VSM\n" : "#define ESM\n");
|
||||
if (high_blur) BLI_dynstr_append(ds_frag, "#define HIGH_BLUR\n");
|
||||
if (cascade) BLI_dynstr_append(ds_frag, "#define CSM\n");
|
||||
if (high_blur) {
|
||||
BLI_dynstr_append(ds_frag, "#define HIGH_BLUR\n");
|
||||
}
|
||||
if (cascade) {
|
||||
BLI_dynstr_append(ds_frag, "#define CSM\n");
|
||||
}
|
||||
char *define_str = BLI_dynstr_get_cstring(ds_frag);
|
||||
BLI_dynstr_free(ds_frag);
|
||||
|
||||
@@ -444,7 +448,9 @@ void EEVEE_lights_cache_shcaster_material_add(
|
||||
/* TODO / PERF : reuse the same shading group for objects with the same material */
|
||||
DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, psl->shadow_pass);
|
||||
|
||||
if (grp == NULL) return;
|
||||
if (grp == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Grrr needed for correctness but not 99% of the time not needed.
|
||||
* TODO detect when needed? */
|
||||
|
||||
@@ -723,13 +723,27 @@ struct GPUMaterial *EEVEE_material_mesh_get(
|
||||
const void *engine = &DRW_engine_viewport_eevee_type;
|
||||
int options = VAR_MAT_MESH;
|
||||
|
||||
if (use_blend) options |= VAR_MAT_BLEND;
|
||||
if (use_multiply) options |= VAR_MAT_MULT;
|
||||
if (use_refract) options |= VAR_MAT_REFRACT;
|
||||
if (use_sss) options |= VAR_MAT_SSS;
|
||||
if (use_sss && effects->sss_separate_albedo) options |= VAR_MAT_SSSALBED;
|
||||
if (use_translucency) options |= VAR_MAT_TRANSLUC;
|
||||
if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) options |= VAR_MAT_VOLUME;
|
||||
if (use_blend) {
|
||||
options |= VAR_MAT_BLEND;
|
||||
}
|
||||
if (use_multiply) {
|
||||
options |= VAR_MAT_MULT;
|
||||
}
|
||||
if (use_refract) {
|
||||
options |= VAR_MAT_REFRACT;
|
||||
}
|
||||
if (use_sss) {
|
||||
options |= VAR_MAT_SSS;
|
||||
}
|
||||
if (use_sss && effects->sss_separate_albedo) {
|
||||
options |= VAR_MAT_SSSALBED;
|
||||
}
|
||||
if (use_translucency) {
|
||||
options |= VAR_MAT_TRANSLUC;
|
||||
}
|
||||
if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) {
|
||||
options |= VAR_MAT_VOLUME;
|
||||
}
|
||||
|
||||
options |= eevee_material_shadow_option(shadow_method);
|
||||
|
||||
@@ -852,10 +866,18 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_create(
|
||||
ssr_id = (use_ssr) ? 1 : -1;
|
||||
int options = VAR_MAT_MESH;
|
||||
|
||||
if (is_hair) options |= VAR_MAT_HAIR;
|
||||
if (is_flat_normal) options |= VAR_MAT_FLAT;
|
||||
if (use_blend) options |= VAR_MAT_BLEND;
|
||||
if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) options |= VAR_MAT_VOLUME;
|
||||
if (is_hair) {
|
||||
options |= VAR_MAT_HAIR;
|
||||
}
|
||||
if (is_flat_normal) {
|
||||
options |= VAR_MAT_FLAT;
|
||||
}
|
||||
if (use_blend) {
|
||||
options |= VAR_MAT_BLEND;
|
||||
}
|
||||
if (((effects->enabled_effects & EFFECT_VOLUMETRIC) != 0) && use_blend) {
|
||||
options |= VAR_MAT_VOLUME;
|
||||
}
|
||||
|
||||
options |= eevee_material_shadow_option(shadow_method);
|
||||
|
||||
@@ -883,8 +905,12 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(
|
||||
|
||||
BLI_assert(!is_hair || (ob && psys && md));
|
||||
|
||||
if (is_hair) options |= VAR_MAT_HAIR;
|
||||
if (is_flat_normal) options |= VAR_MAT_FLAT;
|
||||
if (is_hair) {
|
||||
options |= VAR_MAT_HAIR;
|
||||
}
|
||||
if (is_flat_normal) {
|
||||
options |= VAR_MAT_FLAT;
|
||||
}
|
||||
|
||||
options |= eevee_material_shadow_option(shadow_method);
|
||||
|
||||
|
||||
@@ -721,8 +721,12 @@ static int gpencil_object_cache_compare_zdepth(const void *a1, const void *a2)
|
||||
{
|
||||
const tGPencilObjectCache *ps1 = a1, *ps2 = a2;
|
||||
|
||||
if (ps1->zdepth < ps2->zdepth) return 1;
|
||||
else if (ps1->zdepth > ps2->zdepth) return -1;
|
||||
if (ps1->zdepth < ps2->zdepth) {
|
||||
return 1;
|
||||
}
|
||||
else if (ps1->zdepth > ps2->zdepth) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -276,8 +276,8 @@ bool studiolight_camera_in_object_shadow(WORKBENCH_PrivateData *wpd, Object *ob,
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
float dst = dot_v2v2(wpd->shadow_near_sides[i], pts[j]);
|
||||
/* Do min max */
|
||||
if (min_dst > dst) min_dst = dst;
|
||||
if (max_dst < dst) max_dst = dst;
|
||||
if (min_dst > dst) { min_dst = dst; }
|
||||
if (max_dst < dst) { max_dst = dst; }
|
||||
}
|
||||
|
||||
if ((wpd->shadow_near_sides[i][2] > max_dst) ||
|
||||
|
||||
@@ -643,10 +643,10 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
|
||||
{
|
||||
if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) {
|
||||
uchar cp[4];
|
||||
if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 80);
|
||||
else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 80);
|
||||
else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 80);
|
||||
else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 80);
|
||||
if (constflag & PCHAN_HAS_TARGET) { rgba_char_args_set((char *)cp, 255, 150, 0, 80); }
|
||||
else if (constflag & PCHAN_HAS_IK) { rgba_char_args_set((char *)cp, 255, 255, 0, 80); }
|
||||
else if (constflag & PCHAN_HAS_SPLINEIK) { rgba_char_args_set((char *)cp, 200, 255, 0, 80); }
|
||||
else if (constflag & PCHAN_HAS_CONST) { rgba_char_args_set((char *)cp, 0, 255, 120, 80); }
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
@@ -726,11 +726,11 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const
|
||||
/* inner part in background color or constraint */
|
||||
if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) {
|
||||
uchar cp[4];
|
||||
if (constflag & PCHAN_HAS_TARGET) rgba_char_args_set((char *)cp, 255, 150, 0, 255);
|
||||
else if (constflag & PCHAN_HAS_IK) rgba_char_args_set((char *)cp, 255, 255, 0, 255);
|
||||
else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 255);
|
||||
else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 255);
|
||||
else if (constflag) UI_GetThemeColor4ubv(TH_BONE_POSE, cp); /* PCHAN_HAS_ACTION */
|
||||
if (constflag & PCHAN_HAS_TARGET) { rgba_char_args_set((char *)cp, 255, 150, 0, 255); }
|
||||
else if (constflag & PCHAN_HAS_IK) { rgba_char_args_set((char *)cp, 255, 255, 0, 255); }
|
||||
else if (constflag & PCHAN_HAS_SPLINEIK) { rgba_char_args_set((char *)cp, 200, 255, 0, 255); }
|
||||
else if (constflag & PCHAN_HAS_CONST) { rgba_char_args_set((char *)cp, 0, 255, 120, 255); }
|
||||
else if (constflag) { UI_GetThemeColor4ubv(TH_BONE_POSE, cp); } /* PCHAN_HAS_ACTION */
|
||||
|
||||
rgb_uchar_to_float(fcolor, cp);
|
||||
}
|
||||
@@ -1656,7 +1656,9 @@ static void pchan_draw_ik_lines(
|
||||
while (parchan->parent) {
|
||||
segcount++;
|
||||
/* FIXME: revise the breaking conditions */
|
||||
if (segcount == data->chainlen || segcount > 255) break; /* 255 is weak */
|
||||
if (segcount == data->chainlen || segcount > 255) {
|
||||
break; /* 255 is weak */
|
||||
}
|
||||
parchan = parchan->parent;
|
||||
}
|
||||
/* Only draw line in case our chain is more than one bone long! */
|
||||
|
||||
@@ -1003,11 +1003,11 @@ int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color
|
||||
theme_id = (active) ? TH_ACTIVE : TH_SELECT;
|
||||
}
|
||||
else {
|
||||
if (ob->type == OB_LAMP) theme_id = TH_LIGHT;
|
||||
else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
|
||||
else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
|
||||
else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
|
||||
else if (ob->type == OB_LIGHTPROBE) theme_id = TH_EMPTY; /* TODO add lightprobe color */
|
||||
if (ob->type == OB_LAMP) { theme_id = TH_LIGHT; }
|
||||
else if (ob->type == OB_SPEAKER) { theme_id = TH_SPEAKER; }
|
||||
else if (ob->type == OB_CAMERA) { theme_id = TH_CAMERA; }
|
||||
else if (ob->type == OB_EMPTY) { theme_id = TH_EMPTY; }
|
||||
else if (ob->type == OB_LIGHTPROBE) { theme_id = TH_EMPTY; } /* TODO add lightprobe color */
|
||||
/* fallback to TH_WIRE */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1179,8 +1179,8 @@ static int pass_shgroup_dist_sort(void *thunk, const void *a, const void *b)
|
||||
const DRWCall *call_a = (DRWCall *)shgrp_a->calls.first;
|
||||
const DRWCall *call_b = (DRWCall *)shgrp_b->calls.first;
|
||||
|
||||
if (call_a == NULL) return -1;
|
||||
if (call_b == NULL) return -1;
|
||||
if (call_a == NULL) { return -1; }
|
||||
if (call_b == NULL) { return -1; }
|
||||
|
||||
float tmp[3];
|
||||
sub_v3_v3v3(tmp, zsortdata->origin, call_a->state->model[3]);
|
||||
@@ -1188,8 +1188,8 @@ static int pass_shgroup_dist_sort(void *thunk, const void *a, const void *b)
|
||||
sub_v3_v3v3(tmp, zsortdata->origin, call_b->state->model[3]);
|
||||
const float b_sq = dot_v3v3(zsortdata->axis, tmp);
|
||||
|
||||
if (a_sq < b_sq) return 1;
|
||||
else if (a_sq > b_sq) return -1;
|
||||
if (a_sq < b_sq) { return 1; }
|
||||
else if (a_sq > b_sq) { return -1; }
|
||||
else {
|
||||
/* If there is a depth prepass put it before */
|
||||
if ((shgrp_a->state_extra & DRW_STATE_WRITE_DEPTH) != 0) {
|
||||
@@ -1198,7 +1198,9 @@ static int pass_shgroup_dist_sort(void *thunk, const void *a, const void *b)
|
||||
else if ((shgrp_b->state_extra & DRW_STATE_WRITE_DEPTH) != 0) {
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1035,7 +1035,9 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
|
||||
bool use_tfeedback = false;
|
||||
|
||||
if (shader_changed) {
|
||||
if (DST.shader) GPU_shader_unbind();
|
||||
if (DST.shader) {
|
||||
GPU_shader_unbind();
|
||||
}
|
||||
GPU_shader_bind(shgroup->shader);
|
||||
DST.shader = shgroup->shader;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,9 @@ void DRW_stats_draw(rcti *rect)
|
||||
DRWTimer *timer_parent = (timer->lvl > 0) ? &DTP.timers[lvl_index[timer->lvl - 1]] : NULL;
|
||||
|
||||
/* Only display a number of lvl at a time */
|
||||
if ((G.debug_value - 21) < timer->lvl) continue;
|
||||
if ((G.debug_value - 21) < timer->lvl) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BLI_assert(timer->lvl < MAX_NESTED_TIMER);
|
||||
lvl_index[timer->lvl] = i;
|
||||
|
||||
@@ -71,11 +71,11 @@ void DRW_edit_mesh_mode_text_measure_stats(
|
||||
|
||||
/* make the precision of the display value proportionate to the gridsize */
|
||||
|
||||
if (grid <= 0.01f) conv_float = "%.6g";
|
||||
else if (grid <= 0.1f) conv_float = "%.5g";
|
||||
else if (grid <= 1.0f) conv_float = "%.4g";
|
||||
else if (grid <= 10.0f) conv_float = "%.3g";
|
||||
else conv_float = "%.2g";
|
||||
if (grid <= 0.01f) { conv_float = "%.6g"; }
|
||||
else if (grid <= 0.1f) { conv_float = "%.5g"; }
|
||||
else if (grid <= 1.0f) { conv_float = "%.4g"; }
|
||||
else if (grid <= 10.0f) { conv_float = "%.3g"; }
|
||||
else { conv_float = "%.2g"; }
|
||||
|
||||
if (v3d->overlay.edit_flag & (V3D_OVERLAY_EDIT_EDGE_LEN | V3D_OVERLAY_EDIT_EDGE_ANG | V3D_OVERLAY_EDIT_INDICES)) {
|
||||
BoundBox bb;
|
||||
|
||||
@@ -172,8 +172,12 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
|
||||
|
||||
float draw_stiffness_radius = ml->rad * atanf(ml->s) / (float)M_PI_2;
|
||||
|
||||
if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) color = col_radius_select;
|
||||
else color = col_radius;
|
||||
if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) {
|
||||
color = col_radius_select;
|
||||
}
|
||||
else {
|
||||
color = col_radius;
|
||||
}
|
||||
|
||||
if (is_select) {
|
||||
DRW_select_load_id(select_id | MBALLSEL_RADIUS);
|
||||
@@ -181,8 +185,12 @@ static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
|
||||
|
||||
DRW_shgroup_call_dynamic_add(group, draw_scale_xform, &ml->rad, color);
|
||||
|
||||
if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) color = col_stiffness_select;
|
||||
else color = col_stiffness;
|
||||
if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) {
|
||||
color = col_stiffness_select;
|
||||
}
|
||||
else {
|
||||
color = col_stiffness;
|
||||
}
|
||||
|
||||
if (is_select) {
|
||||
DRW_select_load_id(select_id | MBALLSEL_STIFF);
|
||||
|
||||
Reference in New Issue
Block a user