diff options
author | YimingWu <xp8110@outlook.com> | 2020-02-01 05:25:32 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2020-02-01 05:25:32 +0300 |
commit | b47883a990ee68e659a8a8b44729be9b8e0d002f (patch) | |
tree | 24a7733807992fc84445d30b63deaedfe1ab40a1 /source/blender/draw | |
parent | b5abbc40a07041af91dca5d0a4acd8e5f1518c91 (diff) | |
parent | d9ec25844b4ac3143775615469fe69b27105c108 (diff) |
Merge remote-tracking branch 'origin/master' into temp-lanpr-review
Diffstat (limited to 'source/blender/draw')
34 files changed, 380 insertions, 258 deletions
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 9d7fa3d8c74..d35ab996a08 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -121,10 +121,10 @@ set(SRC engines/select/select_engine.c engines/overlay/overlay_antialiasing.c engines/overlay/overlay_armature.c - engines/overlay/overlay_engine.c engines/overlay/overlay_edit_curve.c - engines/overlay/overlay_edit_text.c engines/overlay/overlay_edit_mesh.c + engines/overlay/overlay_edit_text.c + engines/overlay/overlay_engine.c engines/overlay/overlay_extra.c engines/overlay/overlay_facing.c engines/overlay/overlay_grid.c @@ -135,8 +135,8 @@ set(SRC engines/overlay/overlay_outline.c engines/overlay/overlay_paint.c engines/overlay/overlay_particle.c - engines/overlay/overlay_shader.c engines/overlay/overlay_sculpt.c + engines/overlay/overlay_shader.c engines/overlay/overlay_wireframe.c DRW_engine.h diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 67fd441a0b1..d32f93432b8 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -28,12 +28,12 @@ #include "BLI_string_utils.h" #include "DNA_object_force_types.h" -#include "DNA_smoke_types.h" +#include "DNA_fluid_types.h" #include "DNA_world_types.h" #include "BKE_modifier.h" #include "BKE_mesh.h" -#include "BKE_smoke.h" +#include "BKE_fluid.h" #include "ED_screen.h" @@ -63,7 +63,7 @@ static struct { GPUTexture *dummy_scatter; GPUTexture *dummy_transmit; - /* List of all smoke domains rendered within this frame. */ + /* List of all fluid simulation / smoke domains rendered within this frame. */ ListBase smoke_domains; } e_data = {NULL}; /* Engine data */ @@ -390,8 +390,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, Scene *scene, Object *ob) { - const DRWContextState *draw_ctx = DRW_context_state_get(); - static float white[3] = {1.0f, 1.0f, 1.0f}; + static const float white[3] = {1.0f, 1.0f, 1.0f}; float *texcoloc = NULL; float *texcosize = NULL; @@ -430,41 +429,49 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, /* Smoke Simulation */ if (((ob->base_flag & BASE_FROM_DUPLI) == 0) && - (md = modifiers_findByType(ob, eModifierType_Smoke)) && + (md = modifiers_findByType(ob, eModifierType_Fluid)) && (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && - ((SmokeModifierData *)md)->domain != NULL) { - SmokeModifierData *smd = (SmokeModifierData *)md; - SmokeDomainSettings *sds = smd->domain; + ((FluidModifierData *)md)->domain != NULL) { + FluidModifierData *mmd = (FluidModifierData *)md; + FluidDomainSettings *mds = mmd->domain; + + /* Don't try to show liquid domains here. */ + if (!mds->fluid || !(mds->type == FLUID_DOMAIN_TYPE_GAS)) { + return; + } /* Don't show smoke before simulation starts, this could be made an option in the future. */ + /* (sebbas): Always show smoke for manta */ +#if 0 + const DRWContextState *draw_ctx = DRW_context_state_get(); const bool show_smoke = ((int)DEG_get_ctime(draw_ctx->depsgraph) >= - sds->point_cache[0]->startframe); + *mds->point_cache[0]->startframe); +#endif - if (sds->fluid && show_smoke) { - const bool show_highres = BKE_smoke_show_highres(scene, sds); - if (!sds->wt || !show_highres) { - GPU_create_smoke(smd, 0); + if (mds->fluid && (mds->type == FLUID_DOMAIN_TYPE_GAS) /* && show_smoke */) { + if (!(mds->flags & FLUID_DOMAIN_USE_NOISE)) { + GPU_create_smoke(mmd, 0); } - else if (sds->wt && show_highres) { - GPU_create_smoke(smd, 1); + else if (mds->flags & FLUID_DOMAIN_USE_NOISE) { + GPU_create_smoke(mmd, 1); } - BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(smd)); + BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(mmd)); } DRW_shgroup_uniform_texture_ref( - grp, "sampdensity", sds->tex ? &sds->tex : &e_data.dummy_density); + grp, "sampdensity", mds->tex ? &mds->tex : &e_data.dummy_density); DRW_shgroup_uniform_texture_ref( - grp, "sampflame", sds->tex_flame ? &sds->tex_flame : &e_data.dummy_flame); + grp, "sampflame", mds->tex_flame ? &mds->tex_flame : &e_data.dummy_flame); /* Constant Volume color. */ - bool use_constant_color = ((sds->active_fields & SM_ACTIVE_COLORS) == 0 && - (sds->active_fields & SM_ACTIVE_COLOR_SET) != 0); + bool use_constant_color = ((mds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) == 0 && + (mds->active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET) != 0); DRW_shgroup_uniform_vec3( - grp, "volumeColor", (use_constant_color) ? sds->active_color : white, 1); + grp, "volumeColor", (use_constant_color) ? mds->active_color : white, 1); /* Output is such that 0..1 maps to 0..1000K */ - DRW_shgroup_uniform_vec2(grp, "unftemperature", &sds->flame_ignition, 1); + DRW_shgroup_uniform_vec2(grp, "unftemperature", &mds->flame_ignition, 1); } else { DRW_shgroup_uniform_texture(grp, "sampdensity", e_data.dummy_density); @@ -692,8 +699,8 @@ void EEVEE_volumes_free_smoke_textures(void) { /* Free Smoke Textures after rendering */ for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) { - SmokeModifierData *smd = (SmokeModifierData *)link->data; - GPU_free_smoke(smd); + FluidModifierData *mmd = (FluidModifierData *)link->data; + GPU_free_smoke(mmd); } BLI_freelistN(&e_data.smoke_domains); } diff --git a/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl b/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl index 5a738d0f130..35bfb411cb9 100644 --- a/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl @@ -61,4 +61,4 @@ void main() else { fragColor = vec4(1.0, 0.0, 1.0, 1.0); } -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index 7e75edfddf3..4c6ce896ebc 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -1948,9 +1948,12 @@ void gpencil_populate_datablock(GPENCIL_e_data *e_data, bGPdata *gpd = (bGPdata *)ob->data; - const bool main_onion = stl->storage->is_main_onion; + /* If render mode, instead to use view switches, test if the datablock has + * the onion activated for render. */ + const bool render_onion = (gpd && gpd->onion_flag & GP_ONION_GHOST_ALWAYS); + const bool main_onion = (stl->storage->is_render) ? render_onion : stl->storage->is_main_onion; + const bool overlay = (stl->storage->is_render) ? render_onion : stl->storage->is_main_overlay; const bool playing = stl->storage->is_playing; - const bool overlay = stl->storage->is_main_overlay; const bool do_onion = (bool)((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) == 0) && overlay && main_onion && !playing && gpencil_onion_active(gpd); diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index b0fb95380f4..0b77fcad265 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -2354,4 +2354,4 @@ void OVERLAY_pose_draw(OVERLAY_Data *vedata) DRW_draw_pass(psl->armature_ps[1]); } -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/overlay_edit_curve.c b/source/blender/draw/engines/overlay/overlay_edit_curve.c index b39dc39fd47..d9b9fac6b4b 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_curve.c +++ b/source/blender/draw/engines/overlay/overlay_edit_curve.c @@ -129,4 +129,4 @@ void OVERLAY_edit_curve_draw(OVERLAY_Data *vedata) DRW_draw_pass(psl->edit_curve_wire_ps[1]); DRW_draw_pass(psl->edit_curve_handle_ps); -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.c b/source/blender/draw/engines/overlay/overlay_edit_text.c index 0975608a300..72b5ae74255 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_text.c +++ b/source/blender/draw/engines/overlay/overlay_edit_text.c @@ -202,4 +202,4 @@ void OVERLAY_edit_text_draw(OVERLAY_Data *vedata) DRW_draw_pass(psl->edit_text_wire_ps[1]); DRW_draw_pass(psl->edit_text_overlay_ps); -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 06044ff92b3..fe39b8580e3 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -202,9 +202,10 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) const bool draw_bone_selection = (ob->type == OB_MESH) && pd->armature.do_pose_fade_geom && !is_select; const bool draw_extras = - ((pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0) || - /* Show if this is the camera we're looking through since it's useful for selecting. */ - ((draw_ctx->rv3d->persp == RV3D_CAMOB) && ((ID *)draw_ctx->v3d->camera == ob->id.orig_id)); + (!pd->hide_overlays) && + (((pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0) || + /* Show if this is the camera we're looking through since it's useful for selecting. */ + ((draw_ctx->rv3d->persp == RV3D_CAMOB) && ((ID *)draw_ctx->v3d->camera == ob->id.orig_id))); const bool draw_motion_paths = (pd->overlay.flag & V3D_OVERLAY_HIDE_MOTION_PATHS) == 0; diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index f6e3ed4d4de..90ddb9f7476 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -45,7 +45,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_force_types.h" #include "DNA_rigidbody_types.h" -#include "DNA_smoke_types.h" +#include "DNA_fluid_types.h" #include "DEG_depsgraph_query.h" @@ -1410,22 +1410,22 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, Scene *scene, float *color) { - SmokeModifierData *smd = (SmokeModifierData *)md; - SmokeDomainSettings *sds = smd->domain; + FluidModifierData *mmd = (FluidModifierData *)md; + FluidDomainSettings *mds = mmd->domain; /* Don't show smoke before simulation starts, this could be made an option in the future. */ - const bool draw_velocity = (sds->draw_velocity && sds->fluid && - CFRA >= sds->point_cache[0]->startframe); + const bool draw_velocity = (mds->draw_velocity && mds->fluid && + CFRA >= mds->point_cache[0]->startframe); /* Small cube showing voxel size. */ { float min[3]; - madd_v3fl_v3fl_v3fl_v3i(min, sds->p0, sds->cell_size, sds->res_min); + madd_v3fl_v3fl_v3fl_v3i(min, mds->p0, mds->cell_size, mds->res_min); float voxel_cubemat[4][4] = {{0.0f}}; /* scale small cube to voxel size */ - voxel_cubemat[0][0] = 1.0f / (float)sds->base_res[0]; - voxel_cubemat[1][1] = 1.0f / (float)sds->base_res[1]; - voxel_cubemat[2][2] = 1.0f / (float)sds->base_res[2]; + voxel_cubemat[0][0] = 1.0f / (float)mds->base_res[0]; + voxel_cubemat[1][1] = 1.0f / (float)mds->base_res[1]; + voxel_cubemat[2][2] = 1.0f / (float)mds->base_res[2]; voxel_cubemat[3][3] = 1.0f; /* translate small cube to corner */ copy_v3_v3(voxel_cubemat[3], min); @@ -1437,38 +1437,38 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, } if (draw_velocity) { - const bool use_needle = (sds->vector_draw_type == VECTOR_DRAW_NEEDLE); + const bool use_needle = (mds->vector_draw_type == VECTOR_DRAW_NEEDLE); int line_count = (use_needle) ? 6 : 1; int slice_axis = -1; - line_count *= sds->res[0] * sds->res[1] * sds->res[2]; + line_count *= mds->res[0] * mds->res[1] * mds->res[2]; - if (sds->slice_method == MOD_SMOKE_SLICE_AXIS_ALIGNED && - sds->axis_slice_method == AXIS_SLICE_SINGLE) { + if (mds->slice_method == FLUID_DOMAIN_SLICE_AXIS_ALIGNED && + mds->axis_slice_method == AXIS_SLICE_SINGLE) { float viewinv[4][4]; DRW_view_viewmat_get(NULL, viewinv, true); - const int axis = (sds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(viewinv[2]) : - sds->slice_axis - 1; + const int axis = (mds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(viewinv[2]) : + mds->slice_axis - 1; slice_axis = axis; - line_count /= sds->res[axis]; + line_count /= mds->res[axis]; } - GPU_create_smoke_velocity(smd); + GPU_create_smoke_velocity(mmd); GPUShader *sh = OVERLAY_shader_volume_velocity(use_needle); DRWShadingGroup *grp = DRW_shgroup_create(sh, data->psl->extra_ps[0]); - DRW_shgroup_uniform_texture(grp, "velocityX", sds->tex_velocity_x); - DRW_shgroup_uniform_texture(grp, "velocityY", sds->tex_velocity_y); - DRW_shgroup_uniform_texture(grp, "velocityZ", sds->tex_velocity_z); - DRW_shgroup_uniform_float_copy(grp, "displaySize", sds->vector_scale); - DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth); - DRW_shgroup_uniform_vec3_copy(grp, "cellSize", sds->cell_size); - DRW_shgroup_uniform_vec3_copy(grp, "domainOriginOffset", sds->p0); - DRW_shgroup_uniform_ivec3_copy(grp, "adaptiveCellOffset", sds->res_min); + DRW_shgroup_uniform_texture(grp, "velocityX", mds->tex_velocity_x); + DRW_shgroup_uniform_texture(grp, "velocityY", mds->tex_velocity_y); + DRW_shgroup_uniform_texture(grp, "velocityZ", mds->tex_velocity_z); + DRW_shgroup_uniform_float_copy(grp, "displaySize", mds->vector_scale); + DRW_shgroup_uniform_float_copy(grp, "slicePosition", mds->slice_depth); + DRW_shgroup_uniform_vec3_copy(grp, "cellSize", mds->cell_size); + DRW_shgroup_uniform_vec3_copy(grp, "domainOriginOffset", mds->p0); + DRW_shgroup_uniform_ivec3_copy(grp, "adaptiveCellOffset", mds->res_min); DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis); DRW_shgroup_call_procedural_lines(grp, ob, line_count); - BLI_addtail(&data->stl->pd->smoke_domains, BLI_genericNodeN(smd)); + BLI_addtail(&data->stl->pd->smoke_domains, BLI_genericNodeN(mmd)); } } @@ -1482,8 +1482,8 @@ static void OVERLAY_volume_free_smoke_textures(OVERLAY_Data *data) * all viewport in a redraw at least. */ LinkData *link; while ((link = BLI_pophead(&data->stl->pd->smoke_domains))) { - SmokeModifierData *smd = (SmokeModifierData *)link->data; - GPU_free_smoke_velocity(smd); + FluidModifierData *mmd = (FluidModifierData *)link->data; + GPU_free_smoke_velocity(mmd); MEM_freeN(link); } } @@ -1555,9 +1555,9 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) const bool draw_xform = draw_ctx->object_mode == OB_MODE_OBJECT && (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) && (ob->base_flag & BASE_SELECTED) && !is_select_mode; - const bool draw_volume = !from_dupli && (md = modifiers_findByType(ob, eModifierType_Smoke)) && + const bool draw_volume = !from_dupli && (md = modifiers_findByType(ob, eModifierType_Fluid)) && (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && - (((SmokeModifierData *)md)->domain != NULL); + (((FluidModifierData *)md)->domain != NULL); float *color; int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color); diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.c index 71e43b99998..047659fbeee 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.c +++ b/source/blender/draw/engines/overlay/overlay_paint.c @@ -159,23 +159,16 @@ void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob) OVERLAY_PrivateData *pd = vedata->stl->pd; struct GPUBatch *geom = NULL; - const Mesh *me = ob->data; const Mesh *me_orig = DEG_get_original_object(ob)->data; const bool use_wire = (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const bool use_vert_sel = (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; if (pd->paint_surf_grp) { - if (ob->mode == OB_MODE_VERTEX_PAINT) { - if (me->mloopcol == NULL) { - return; - } - geom = DRW_cache_mesh_surface_vertpaint_get(ob); - } - else { + if (ob->mode == OB_MODE_WEIGHT_PAINT) { geom = DRW_cache_mesh_surface_weights_get(ob); + DRW_shgroup_call(pd->paint_surf_grp, geom, ob); } - DRW_shgroup_call(pd->paint_surf_grp, geom, ob); } if (use_face_sel || use_wire) { diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index 9be92e0ab14..996ee845799 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -571,4 +571,4 @@ OVERLAY_InstanceFormats *OVERLAY_shader_instance_formats_get(void); void OVERLAY_shader_free(void); -#endif /* __OVERLAY_PRIVATE_H__ */
\ No newline at end of file +#endif /* __OVERLAY_PRIVATE_H__ */ diff --git a/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl b/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl index 386e6d9e141..4784d420e1d 100644 --- a/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/antialiasing_frag.glsl @@ -147,4 +147,4 @@ void main() fragColor = mix(fragColor, fragColor / fragColor.a, blend); } #endif -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/antialiasing_vert.glsl b/source/blender/draw/engines/overlay/shaders/antialiasing_vert.glsl index 4f3c36c7bd7..8cf8ba121ed 100644 --- a/source/blender/draw/engines/overlay/shaders/antialiasing_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/antialiasing_vert.glsl @@ -8,4 +8,4 @@ void main() float y = float((v & 2) << 1); gl_Position = vec4(x - 1.0, y - 1.0, 1.0, 1.0); uvs = vec2(x, y) * 0.5; -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/extra_frag.glsl b/source/blender/draw/engines/overlay/shaders/extra_frag.glsl index 8a8ae8a9611..a2572f44e70 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_frag.glsl @@ -10,4 +10,4 @@ void main() { fragColor = finalColor; lineOutput = pack_line_data(gl_FragCoord.xy, edgeStart, edgePos); -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/extra_groundline_vert.glsl b/source/blender/draw/engines/overlay/shaders/extra_groundline_vert.glsl index 4b08ea587d4..738f0025f07 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_groundline_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_groundline_vert.glsl @@ -27,4 +27,4 @@ void main() #ifdef USE_WORLD_CLIP_PLANES world_clip_planes_calc_clip_distance(world_pos); #endif -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/extra_loose_point_frag.glsl b/source/blender/draw/engines/overlay/shaders/extra_loose_point_frag.glsl index 8784b6cd73a..c27061f8f97 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_loose_point_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_loose_point_frag.glsl @@ -15,4 +15,4 @@ void main() * the depth and creating mini-spheres. * Disabled as it has performance impact. */ // gl_FragDepth = gl_FragCoord.z + 1e-6 * fac; -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/extra_loose_point_vert.glsl b/source/blender/draw/engines/overlay/shaders/extra_loose_point_vert.glsl index 76a2678a50e..7e31bf966bc 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_loose_point_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_loose_point_vert.glsl @@ -17,4 +17,4 @@ void main() #ifdef USE_WORLD_CLIP_PLANES world_clip_planes_calc_clip_distance(world_pos); #endif -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/extra_point_vert.glsl b/source/blender/draw/engines/overlay/shaders/extra_point_vert.glsl index 14c03248981..537c55cf3f5 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_point_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_point_vert.glsl @@ -27,4 +27,4 @@ void main() #ifdef USE_WORLD_CLIP_PLANES world_clip_planes_calc_clip_distance(world_pos); #endif -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/extra_vert.glsl b/source/blender/draw/engines/overlay/shaders/extra_vert.glsl index a72c5adb691..92db27ea6dd 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_vert.glsl @@ -224,4 +224,4 @@ void main() #ifdef USE_WORLD_CLIP_PLANES world_clip_planes_calc_clip_distance(world_pos); #endif -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/extra_wire_frag.glsl b/source/blender/draw/engines/overlay/shaders/extra_wire_frag.glsl index 7e469aee18d..a2bc13ba443 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_wire_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_wire_frag.glsl @@ -28,4 +28,4 @@ void main() if (fract(dist / dash_width) > dash_factor) { discard; } -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/extra_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/extra_wire_vert.glsl index 933b9d65a5f..97183638a71 100644 --- a/source/blender/draw/engines/overlay/shaders/extra_wire_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/extra_wire_vert.glsl @@ -37,4 +37,4 @@ void main() #ifdef USE_WORLD_CLIP_PLANES world_clip_planes_calc_clip_distance(world_pos); #endif -}
\ No newline at end of file +} diff --git a/source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl b/source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl index 64f88bd74fa..752694301f7 100644 --- a/source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/volume_velocity_vert.glsl @@ -6,11 +6,11 @@ uniform float displaySize = 1.0; uniform float slicePosition; uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */ -/* SmokeDomainSettings.cell_size */ +/* FluidDomainSettings.cell_size */ uniform vec3 cellSize; -/* SmokeDomainSettings.p0 */ +/* FluidDomainSettings.p0 */ uniform vec3 domainOriginOffset; -/* SmokeDomainSettings.res_min */ +/* FluidDomainSettings.res_min */ uniform ivec3 adaptiveCellOffset; flat out vec4 finalColor; diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 8e61750da38..02a3af7fa73 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -34,6 +34,7 @@ #include "BKE_particle.h" #include "DNA_image_types.h" +#include "DNA_fluid_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_node_types.h" @@ -213,16 +214,16 @@ static GPUShader *workbench_cavity_shader_get(bool cavity, bool curvature) static GPUShader *ensure_deferred_prepass_shader(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting, + const WORKBENCH_ColorOverride color_override, eGPUShaderConfig sh_cfg) { WORKBENCH_DEFERRED_Shaders *sh_data = &e_data.sh_data[sh_cfg]; int index = workbench_material_get_prepass_shader_index( - wpd, is_uniform_color, is_hair, is_texture_painting); + wpd, is_uniform_color, is_hair, color_override); if (sh_data->prepass_sh_cache[index] == NULL) { const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg]; char *defines = workbench_material_build_defines( - wpd, is_uniform_color, is_hair, is_texture_painting); + wpd, is_uniform_color, is_hair, color_override); char *prepass_vert = workbench_build_prepass_vert(is_hair); char *prepass_frag = workbench_build_prepass_frag(); sh_data->prepass_sh_cache[index] = GPU_shader_create_from_arrays({ @@ -241,7 +242,8 @@ static GPUShader *ensure_deferred_composite_shader(WORKBENCH_PrivateData *wpd) { int index = workbench_material_get_composite_shader_index(wpd); if (e_data.composite_sh_cache[index] == NULL) { - char *defines = workbench_material_build_defines(wpd, false, false, false); + char *defines = workbench_material_build_defines( + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_OFF); char *composite_frag = workbench_build_composite_frag(wpd); e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines); MEM_freeN(composite_frag); @@ -268,11 +270,18 @@ static GPUShader *ensure_background_shader(WORKBENCH_PrivateData *wpd) static void select_deferred_shaders(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg) { - wpd->prepass_sh = ensure_deferred_prepass_shader(wpd, false, false, false, sh_cfg); - wpd->prepass_hair_sh = ensure_deferred_prepass_shader(wpd, false, true, false, sh_cfg); - wpd->prepass_uniform_sh = ensure_deferred_prepass_shader(wpd, true, false, false, sh_cfg); - wpd->prepass_uniform_hair_sh = ensure_deferred_prepass_shader(wpd, true, true, false, sh_cfg); - wpd->prepass_textured_sh = ensure_deferred_prepass_shader(wpd, false, false, true, sh_cfg); + wpd->prepass_sh = ensure_deferred_prepass_shader( + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_OFF, sh_cfg); + wpd->prepass_hair_sh = ensure_deferred_prepass_shader( + wpd, false, true, WORKBENCH_COLOR_OVERRIDE_OFF, sh_cfg); + wpd->prepass_uniform_sh = ensure_deferred_prepass_shader( + wpd, true, false, WORKBENCH_COLOR_OVERRIDE_OFF, sh_cfg); + wpd->prepass_uniform_hair_sh = ensure_deferred_prepass_shader( + wpd, true, true, WORKBENCH_COLOR_OVERRIDE_OFF, sh_cfg); + wpd->prepass_textured_sh = ensure_deferred_prepass_shader( + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_TEXTURE, sh_cfg); + wpd->prepass_vertex_sh = ensure_deferred_prepass_shader( + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_VERTEX, sh_cfg); wpd->composite_sh = ensure_deferred_composite_shader(wpd); wpd->background_sh = ensure_background_shader(wpd); } @@ -867,6 +876,9 @@ static WORKBENCH_MaterialData *get_or_create_material_data(WORKBENCH_Data *vedat if (color_type == V3D_SHADING_TEXTURE_COLOR) { shader = wpd->prepass_textured_sh; } + if (color_type == V3D_SHADING_VERTEX_COLOR) { + shader = wpd->prepass_vertex_sh; + } material->shgrp = DRW_shgroup_create( shader, (ob->dtx & OB_DRAWXRAY) ? psl->ghost_prepass_pass : psl->prepass_pass); workbench_material_copy(material, &material_template); @@ -963,6 +975,22 @@ static void workbench_cache_populate_texture_paint_mode(WORKBENCH_Data *vedata, } } +static void workbench_cache_populate_vertex_paint_mode(WORKBENCH_Data *vedata, Object *ob) +{ + WORKBENCH_StorageList *stl = vedata->stl; + WORKBENCH_PrivateData *wpd = stl->g_data; + const DRWContextState *draw_ctx = DRW_context_state_get(); + + const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) && + !DRW_state_is_image_render(); + WORKBENCH_MaterialData *material; + + int color_type = workbench_material_determine_color_type(wpd, NULL, ob, use_sculpt_pbvh); + struct GPUBatch *geom = DRW_cache_mesh_surface_vertpaint_get(ob); + material = get_or_create_material_data(vedata, ob, NULL, NULL, NULL, color_type, false); + DRW_shgroup_call(material->shgrp, geom, ob); +} + void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) { WORKBENCH_StorageList *stl = vedata->stl; @@ -981,9 +1009,10 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) ModifierData *md; if (((ob->base_flag & BASE_FROM_DUPLI) == 0) && - (md = modifiers_findByType(ob, eModifierType_Smoke)) && + (md = modifiers_findByType(ob, eModifierType_Fluid)) && (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && - (((SmokeModifierData *)md)->domain != NULL)) { + (((FluidModifierData *)md)->domain != NULL) && + (((FluidModifierData *)md)->domain->type == FLUID_DOMAIN_TYPE_GAS)) { workbench_volume_cache_populate(vedata, scene, ob, md); return; /* Do not draw solid in this case. */ } @@ -1003,14 +1032,22 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) const int materials_len = MAX2(1, ob->totcol); const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; bool has_transp_mat = false; + const WORKBENCH_ColorOverride color_override = workbench_object_color_override_get(ob); const bool use_texture_paint_drawing = !(DRW_state_is_image_render() && draw_ctx->v3d == NULL) && - workbench_is_object_in_texture_paint_mode(ob) && me && - me->mloopuv; + (color_override == WORKBENCH_COLOR_OVERRIDE_TEXTURE) && + me && me->mloopuv; + const bool use_vertex_paint_drawing = !(DRW_state_is_image_render() && + draw_ctx->v3d == NULL) && + (color_override == WORKBENCH_COLOR_OVERRIDE_VERTEX) && + me && me->mloopcol; if (use_texture_paint_drawing) { workbench_cache_populate_texture_paint_mode(vedata, ob); } + else if (use_vertex_paint_drawing) { + workbench_cache_populate_vertex_paint_mode(vedata, ob); + } else if (!use_sculpt_pbvh && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) { /* Draw textured */ struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob); diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index dbd7ebfe0d1..44f43fc7d09 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -33,6 +33,7 @@ #include "BKE_particle.h" #include "DNA_image_types.h" +#include "DNA_fluid_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_node_types.h" @@ -225,16 +226,16 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_ static GPUShader *ensure_forward_accum_shaders(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting, + const WORKBENCH_ColorOverride color_override, eGPUShaderConfig sh_cfg) { WORKBENCH_FORWARD_Shaders *sh_data = &e_data.sh_data[sh_cfg]; int index = workbench_material_get_accum_shader_index( - wpd, is_uniform_color, is_hair, is_texture_painting); + wpd, is_uniform_color, is_hair, color_override); if (sh_data->transparent_accum_sh_cache[index] == NULL) { const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg]; char *defines = workbench_material_build_defines( - wpd, is_uniform_color, is_hair, is_texture_painting); + wpd, is_uniform_color, is_hair, color_override); char *transparent_accum_vert = workbench_build_forward_vert(is_hair); char *transparent_accum_frag = workbench_build_forward_transparent_accum_frag(); sh_data->transparent_accum_sh_cache[index] = GPU_shader_create_from_arrays({ @@ -253,7 +254,8 @@ static GPUShader *ensure_forward_composite_shaders(WORKBENCH_PrivateData *wpd) { int index = OBJECT_OUTLINE_ENABLED(wpd) ? 1 : 0; if (e_data.composite_sh_cache[index] == NULL) { - char *defines = workbench_material_build_defines(wpd, false, false, false); + char *defines = workbench_material_build_defines( + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_OFF); char *composite_frag = workbench_build_forward_composite_frag(); e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines); MEM_freeN(composite_frag); @@ -265,14 +267,18 @@ static GPUShader *ensure_forward_composite_shaders(WORKBENCH_PrivateData *wpd) void workbench_forward_choose_shaders(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg) { wpd->composite_sh = ensure_forward_composite_shaders(wpd); - wpd->transparent_accum_sh = ensure_forward_accum_shaders(wpd, false, false, false, sh_cfg); - wpd->transparent_accum_hair_sh = ensure_forward_accum_shaders(wpd, false, true, false, sh_cfg); + wpd->transparent_accum_sh = ensure_forward_accum_shaders( + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_OFF, sh_cfg); + wpd->transparent_accum_hair_sh = ensure_forward_accum_shaders( + wpd, false, true, WORKBENCH_COLOR_OVERRIDE_OFF, sh_cfg); wpd->transparent_accum_uniform_sh = ensure_forward_accum_shaders( - wpd, true, false, false, sh_cfg); + wpd, true, false, WORKBENCH_COLOR_OVERRIDE_OFF, sh_cfg); wpd->transparent_accum_uniform_hair_sh = ensure_forward_accum_shaders( - wpd, true, true, false, sh_cfg); + wpd, true, true, WORKBENCH_COLOR_OVERRIDE_OFF, sh_cfg); wpd->transparent_accum_textured_sh = ensure_forward_accum_shaders( - wpd, false, false, true, sh_cfg); + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_TEXTURE, sh_cfg); + wpd->transparent_accum_vertex_sh = ensure_forward_accum_shaders( + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_VERTEX, sh_cfg); } void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg) @@ -281,9 +287,12 @@ void workbench_forward_outline_shaders_ensure(WORKBENCH_PrivateData *wpd, eGPUSh if (sh_data->object_outline_sh == NULL) { const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg]; - char *defines = workbench_material_build_defines(wpd, false, false, false); - char *defines_texture = workbench_material_build_defines(wpd, true, false, false); - char *defines_hair = workbench_material_build_defines(wpd, false, true, false); + char *defines = workbench_material_build_defines( + wpd, false, false, WORKBENCH_COLOR_OVERRIDE_OFF); + char *defines_texture = workbench_material_build_defines( + wpd, true, false, WORKBENCH_COLOR_OVERRIDE_OFF); + char *defines_hair = workbench_material_build_defines( + wpd, false, true, WORKBENCH_COLOR_OVERRIDE_OFF); char *forward_vert = workbench_build_forward_vert(false); char *forward_frag = workbench_build_forward_outline_frag(); char *forward_hair_vert = workbench_build_forward_vert(true); @@ -599,6 +608,23 @@ static void workbench_forward_cache_populate_texture_paint_mode(WORKBENCH_Data * } } } +static void workbench_forward_cache_populate_vertex_paint_mode(WORKBENCH_Data *vedata, Object *ob) +{ + WORKBENCH_StorageList *stl = vedata->stl; + WORKBENCH_PrivateData *wpd = stl->g_data; + const DRWContextState *draw_ctx = DRW_context_state_get(); + + const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) && + !DRW_state_is_image_render(); + WORKBENCH_MaterialData *material; + + int color_type = workbench_material_determine_color_type(wpd, NULL, ob, use_sculpt_pbvh); + struct GPUBatch *geom = DRW_cache_mesh_surface_vertpaint_get(ob); + material = workbench_forward_get_or_create_material_data( + vedata, ob, NULL, NULL, NULL, color_type, false); + DRW_shgroup_call(material->shgrp, geom, ob); + DRW_shgroup_call(material->shgrp_object_outline, geom, ob); +} void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) { @@ -618,9 +644,10 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) ModifierData *md; if (((ob->base_flag & BASE_FROM_DUPLI) == 0) && - (md = modifiers_findByType(ob, eModifierType_Smoke)) && + (md = modifiers_findByType(ob, eModifierType_Fluid)) && (modifier_isEnabled(scene, md, eModifierMode_Realtime)) && - (((SmokeModifierData *)md)->domain != NULL)) { + (((FluidModifierData *)md)->domain != NULL) && + (((FluidModifierData *)md)->domain->type == FLUID_DOMAIN_TYPE_GAS)) { workbench_volume_cache_populate(vedata, scene, ob, md); return; /* Do not draw solid in this case. */ } @@ -638,14 +665,22 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) !DRW_state_is_image_render(); const int materials_len = MAX2(1, ob->totcol); const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; + const WORKBENCH_ColorOverride color_override = workbench_object_color_override_get(ob); const bool use_texture_paint_drawing = !(DRW_state_is_image_render() && draw_ctx->v3d == NULL) && - workbench_is_object_in_texture_paint_mode(ob) && me && - me->mloopuv; + (color_override == WORKBENCH_COLOR_OVERRIDE_TEXTURE) && + me && me->mloopuv; + const bool use_vertex_paint_drawing = !(DRW_state_is_image_render() && + draw_ctx->v3d == NULL) && + (color_override == WORKBENCH_COLOR_OVERRIDE_VERTEX) && + me && me->mloopcol; if (use_texture_paint_drawing) { workbench_forward_cache_populate_texture_paint_mode(vedata, ob); } + else if (use_vertex_paint_drawing) { + workbench_forward_cache_populate_vertex_paint_mode(vedata, ob); + } else if (!use_sculpt_pbvh && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) { struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob); for (int i = 0; i < materials_len; i++) { diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 28abed96b48..16fcda54253 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -85,16 +85,26 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting) + const WORKBENCH_ColorOverride color_override) { char *str = NULL; bool use_textures = (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) && !is_uniform_color; bool use_vertex_colors = (wpd->shading.color_type == V3D_SHADING_VERTEX_COLOR) && !is_uniform_color; - if (is_texture_painting) { - use_textures = true; - use_vertex_colors = false; + switch (color_override) { + case WORKBENCH_COLOR_OVERRIDE_TEXTURE: + use_textures = true; + use_vertex_colors = false; + is_hair = false; + break; + case WORKBENCH_COLOR_OVERRIDE_VERTEX: + use_textures = false; + use_vertex_colors = true; + is_hair = false; + break; + case WORKBENCH_COLOR_OVERRIDE_OFF: + break; } DynStr *ds = BLI_dynstr_new(); @@ -201,15 +211,25 @@ int workbench_material_get_composite_shader_index(WORKBENCH_PrivateData *wpd) int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting) + const WORKBENCH_ColorOverride color_override) { bool use_textures = (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) && !is_uniform_color; bool use_vertex_colors = (wpd->shading.color_type == V3D_SHADING_VERTEX_COLOR) && !is_uniform_color; - if (is_texture_painting) { - use_textures = true; - use_vertex_colors = false; + + switch (color_override) { + case WORKBENCH_COLOR_OVERRIDE_TEXTURE: + use_textures = true; + use_vertex_colors = false; + break; + case WORKBENCH_COLOR_OVERRIDE_VERTEX: + use_textures = false; + use_vertex_colors = true; + break; + case WORKBENCH_COLOR_OVERRIDE_OFF: + break; } + /* NOTE: change MAX_PREPASS_SHADERS accordingly when modifying this function. */ int index = 0; SET_FLAG_FROM_TEST(index, is_hair, 1 << 0); @@ -226,15 +246,25 @@ int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd, int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting) + const WORKBENCH_ColorOverride color_override) { bool use_textures = (wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR) && !is_uniform_color; bool use_vertex_colors = (wpd->shading.color_type == V3D_SHADING_VERTEX_COLOR) && !is_uniform_color; - if (is_texture_painting) { - use_textures = true; - use_vertex_colors = false; - is_hair = false; + + switch (color_override) { + case WORKBENCH_COLOR_OVERRIDE_TEXTURE: + use_textures = true; + use_vertex_colors = false; + is_hair = false; + break; + case WORKBENCH_COLOR_OVERRIDE_VERTEX: + use_textures = false; + use_vertex_colors = true; + is_hair = false; + break; + case WORKBENCH_COLOR_OVERRIDE_OFF: + break; } /* NOTE: change MAX_ACCUM_SHADERS accordingly when modifying this function. */ @@ -267,12 +297,25 @@ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, color_type = V3D_SHADING_OBJECT_COLOR; } - /* Force V3D_SHADING_TEXTURE_COLOR for active object when in texture painting - * no matter the shading color that the user has chosen, when there is no - * texture we will render the object with the error color */ - if (workbench_is_object_in_texture_paint_mode(ob)) { - color_type = ima ? V3D_SHADING_TEXTURE_COLOR : V3D_SHADING_ERROR_COLOR; + switch (workbench_object_color_override_get(ob)) { + /* Force V3D_SHADING_TEXTURE_COLOR for active object when in texture painting + * no matter the shading color that the user has chosen, when there is no + * texture we will render the object with the error color */ + case WORKBENCH_COLOR_OVERRIDE_TEXTURE: + color_type = ima ? V3D_SHADING_TEXTURE_COLOR : V3D_SHADING_ERROR_COLOR; + break; + + /* Force V3D_SHADING_VERTEX_COLOR for active object when in vertex painting + * no matter the shading color that the user has chosen, when there is no + * vertex color we will render the object with the error color */ + case WORKBENCH_COLOR_OVERRIDE_VERTEX: + color_type = V3D_SHADING_VERTEX_COLOR; + break; + + case WORKBENCH_COLOR_OVERRIDE_OFF: + break; } + return color_type; } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 9fcd9651f94..7c774ca7490 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -207,6 +207,7 @@ typedef struct WORKBENCH_PrivateData { struct GPUShader *prepass_uniform_sh; struct GPUShader *prepass_uniform_hair_sh; struct GPUShader *prepass_textured_sh; + struct GPUShader *prepass_vertex_sh; struct GPUShader *composite_sh; struct GPUShader *background_sh; struct GPUShader *transparent_accum_sh; @@ -214,6 +215,7 @@ typedef struct WORKBENCH_PrivateData { struct GPUShader *transparent_accum_uniform_sh; struct GPUShader *transparent_accum_uniform_hair_sh; struct GPUShader *transparent_accum_textured_sh; + struct GPUShader *transparent_accum_vertex_sh; View3DShading shading; StudioLight *studio_light; const UserDef *preferences; @@ -318,6 +320,15 @@ typedef struct WORKBENCH_WorldData { struct GPUUniformBuffer *world_ubo; } WORKBENCH_WorldData; +/* Enumeration containing override options for base color rendering. + * This is used to during painting to force the base color to show what you are + * painting using the selected lighting model. */ +typedef enum WORKBENCH_ColorOverride { + WORKBENCH_COLOR_OVERRIDE_OFF = 0, + WORKBENCH_COLOR_OVERRIDE_TEXTURE = CTX_MODE_PAINT_TEXTURE, + WORKBENCH_COLOR_OVERRIDE_VERTEX = CTX_MODE_PAINT_VERTEX, +} WORKBENCH_ColorOverride; + /* inline helper functions */ BLI_INLINE bool workbench_is_specular_highlight_enabled(WORKBENCH_PrivateData *wpd) { @@ -375,23 +386,35 @@ BLI_INLINE bool workbench_is_in_texture_paint_mode(void) return draw_ctx->object_mode == OB_MODE_TEXTURE_PAINT; } -/** Is texture paint mode active for the given object */ -BLI_INLINE bool workbench_is_object_in_texture_paint_mode(Object *ob) +/** Is vertex paint mode enabled (globally) */ +BLI_INLINE bool workbench_is_in_vertex_paint_mode(void) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + return draw_ctx->object_mode == OB_MODE_VERTEX_PAINT; +} + +/* Must the `View3DShading.color_type` be overriden for the given object. */ +BLI_INLINE WORKBENCH_ColorOverride workbench_object_color_override_get(Object *ob) { const DRWContextState *draw_ctx = DRW_context_state_get(); if (ob->type == OB_MESH && (draw_ctx->obact == ob)) { const enum eContextObjectMode mode = CTX_data_mode_enum_ex( draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode); - return (mode == CTX_MODE_PAINT_TEXTURE); + if (mode == CTX_MODE_PAINT_TEXTURE) { + return WORKBENCH_COLOR_OVERRIDE_TEXTURE; + } + else if (mode == CTX_MODE_PAINT_VERTEX) { + return WORKBENCH_COLOR_OVERRIDE_VERTEX; + } } - return false; + return WORKBENCH_COLOR_OVERRIDE_OFF; } BLI_INLINE bool workbench_is_matdata_pass_enabled(WORKBENCH_PrivateData *wpd) { return (wpd->shading.color_type != V3D_SHADING_SINGLE_COLOR || MATCAP_ENABLED(wpd)) || - workbench_is_in_texture_paint_mode(); + workbench_is_in_texture_paint_mode() || workbench_is_in_vertex_paint_mode(); } /** @@ -409,7 +432,7 @@ BLI_INLINE eGPUTextureFormat workbench_color_texture_format(const WORKBENCH_Priv TEXTURE_DRAWING_ENABLED(wpd)) { result = GPU_RGBA16F; } - else if (VERTEX_COLORS_ENABLED(wpd)) { + else if (workbench_is_in_vertex_paint_mode() || VERTEX_COLORS_ENABLED(wpd)) { result = GPU_RGBA16; } else { @@ -493,7 +516,7 @@ void workbench_material_get_image_and_mat( char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting); + const WORKBENCH_ColorOverride color_override); void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, @@ -504,11 +527,11 @@ int workbench_material_get_composite_shader_index(WORKBENCH_PrivateData *wpd); int workbench_material_get_prepass_shader_index(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting); + const WORKBENCH_ColorOverride color_override); int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting); + const WORKBENCH_ColorOverride color_override); void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material, diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index 23f0898c138..2f7296fb40f 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -23,7 +23,7 @@ #include "workbench_private.h" #include "BKE_object.h" -#include "BKE_smoke.h" +#include "BKE_fluid.h" #include "BLI_rand.h" #include "BLI_dynstr.h" @@ -31,7 +31,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_force_types.h" -#include "DNA_smoke_types.h" +#include "DNA_fluid_types.h" #include "GPU_draw.h" @@ -119,57 +119,56 @@ void workbench_volume_cache_init(WORKBENCH_Data *vedata) } void workbench_volume_cache_populate(WORKBENCH_Data *vedata, - Scene *scene, + Scene *UNUSED(scene), Object *ob, ModifierData *md) { - SmokeModifierData *smd = (SmokeModifierData *)md; - SmokeDomainSettings *sds = smd->domain; + FluidModifierData *mmd = (FluidModifierData *)md; + FluidDomainSettings *mds = mmd->domain; WORKBENCH_PrivateData *wpd = vedata->stl->g_data; WORKBENCH_EffectInfo *effect_info = vedata->stl->effects; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); DRWShadingGroup *grp = NULL; - /* Don't show smoke before simulation starts, this could be made an option in the future. */ - if (!sds->fluid || CFRA < sds->point_cache[0]->startframe) { + /* Don't try to show liquid domains here */ + if (!mds->fluid || !(mds->type == FLUID_DOMAIN_TYPE_GAS)) { return; } wpd->volumes_do = true; - const bool show_highres = BKE_smoke_show_highres(scene, sds); - if (sds->use_coba) { - GPU_create_smoke_coba_field(smd); + if (mds->use_coba) { + GPU_create_smoke_coba_field(mmd); } - else if (!sds->wt || !show_highres) { - GPU_create_smoke(smd, 0); + else if (!(mds->flags & FLUID_DOMAIN_USE_NOISE)) { + GPU_create_smoke(mmd, 0); } - else if (sds->wt && show_highres) { - GPU_create_smoke(smd, 1); + else if (mds->flags & FLUID_DOMAIN_USE_NOISE) { + GPU_create_smoke(mmd, 1); } - if ((!sds->use_coba && sds->tex == NULL) || (sds->use_coba && sds->tex_field == NULL)) { + if ((!mds->use_coba && mds->tex == NULL) || (mds->use_coba && mds->tex_field == NULL)) { return; } - const bool use_slice = (sds->slice_method == MOD_SMOKE_SLICE_AXIS_ALIGNED && - sds->axis_slice_method == AXIS_SLICE_SINGLE); - const bool cubic_interp = (sds->interp_method == VOLUME_INTERP_CUBIC); - GPUShader *sh = volume_shader_get(use_slice, sds->use_coba, cubic_interp); + const bool use_slice = (mds->slice_method == FLUID_DOMAIN_SLICE_AXIS_ALIGNED && + mds->axis_slice_method == AXIS_SLICE_SINGLE); + const bool cubic_interp = (mds->interp_method == VOLUME_INTERP_CUBIC); + GPUShader *sh = volume_shader_get(use_slice, mds->use_coba, cubic_interp); if (use_slice) { float invviewmat[4][4]; DRW_view_viewmat_get(NULL, invviewmat, true); - const int axis = (sds->slice_axis == SLICE_AXIS_AUTO) ? + const int axis = (mds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(invviewmat[2]) : - sds->slice_axis - 1; + mds->slice_axis - 1; float dim[3]; BKE_object_dimensions_get(ob, dim); /* 0.05f to achieve somewhat the same opacity as the full view. */ float step_length = max_ff(1e-16f, dim[axis] * 0.05f); grp = DRW_shgroup_create(sh, vedata->psl->volume_pass); - DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth); + DRW_shgroup_uniform_float_copy(grp, "slicePosition", mds->slice_depth); DRW_shgroup_uniform_int_copy(grp, "sliceAxis", axis); DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); DRW_shgroup_state_disable(grp, DRW_STATE_CULL_FRONT); @@ -178,8 +177,8 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, double noise_ofs; BLI_halton_1d(3, 0.0, effect_info->jitter_index, &noise_ofs); float dim[3], step_length, max_slice; - float slice_ct[3] = {sds->res[0], sds->res[1], sds->res[2]}; - mul_v3_fl(slice_ct, max_ff(0.001f, sds->slice_per_voxel)); + float slice_ct[3] = {mds->res[0], mds->res[1], mds->res[2]}; + mul_v3_fl(slice_ct, max_ff(0.001f, mds->slice_per_voxel)); max_slice = max_fff(slice_ct[0], slice_ct[1], slice_ct[2]); BKE_object_dimensions_get(ob, dim); invert_v3(slice_ct); @@ -194,25 +193,25 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, DRW_shgroup_state_enable(grp, DRW_STATE_CULL_FRONT); } - if (sds->use_coba) { - DRW_shgroup_uniform_texture(grp, "densityTexture", sds->tex_field); - DRW_shgroup_uniform_texture(grp, "transferTexture", sds->tex_coba); + if (mds->use_coba) { + DRW_shgroup_uniform_texture(grp, "densityTexture", mds->tex_field); + DRW_shgroup_uniform_texture(grp, "transferTexture", mds->tex_coba); } else { static float white[3] = {1.0f, 1.0f, 1.0f}; - bool use_constant_color = ((sds->active_fields & SM_ACTIVE_COLORS) == 0 && - (sds->active_fields & SM_ACTIVE_COLOR_SET) != 0); - DRW_shgroup_uniform_texture(grp, "densityTexture", sds->tex); - DRW_shgroup_uniform_texture(grp, "shadowTexture", sds->tex_shadow); + bool use_constant_color = ((mds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) == 0 && + (mds->active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET) != 0); + DRW_shgroup_uniform_texture(grp, "densityTexture", mds->tex); + DRW_shgroup_uniform_texture(grp, "shadowTexture", mds->tex_shadow); DRW_shgroup_uniform_texture( - grp, "flameTexture", (sds->tex_flame) ? sds->tex_flame : e_data.dummy_tex); + grp, "flameTexture", (mds->tex_flame) ? mds->tex_flame : e_data.dummy_tex); DRW_shgroup_uniform_texture( - grp, "flameColorTexture", (sds->tex_flame) ? sds->tex_flame_coba : e_data.dummy_coba_tex); + grp, "flameColorTexture", (mds->tex_flame) ? mds->tex_flame_coba : e_data.dummy_coba_tex); DRW_shgroup_uniform_vec3( - grp, "activeColor", (use_constant_color) ? sds->active_color : white, 1); + grp, "activeColor", (use_constant_color) ? mds->active_color : white, 1); } DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); - DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * sds->display_thickness); + DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * mds->display_thickness); if (use_slice) { DRW_shgroup_call(grp, DRW_cache_quad_get(), ob); @@ -221,7 +220,7 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, DRW_shgroup_call(grp, DRW_cache_cube_get(), ob); } - BLI_addtail(&wpd->smoke_domains, BLI_genericNodeN(smd)); + BLI_addtail(&wpd->smoke_domains, BLI_genericNodeN(mmd)); } void workbench_volume_smoke_textures_free(WORKBENCH_PrivateData *wpd) @@ -233,8 +232,8 @@ void workbench_volume_smoke_textures_free(WORKBENCH_PrivateData *wpd) * modifier is not used for display. We should share them for * all viewport in a redraw at least. */ for (LinkData *link = wpd->smoke_domains.first; link; link = link->next) { - SmokeModifierData *smd = (SmokeModifierData *)link->data; - GPU_free_smoke(smd); + FluidModifierData *mmd = (FluidModifierData *)link->data; + GPU_free_smoke(mmd); } BLI_freelistN(&wpd->smoke_domains); } diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 90b5e08f994..69135f8ade3 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -68,6 +68,12 @@ typedef struct Vert { int class; } Vert; +typedef struct VertShaded { + float pos[3]; + int class; + float nor[3]; +} VertShaded; + /* Batch's only (free'd as an array) */ static struct DRWShapeCache { GPUBatch *drw_procedural_verts; @@ -471,7 +477,7 @@ static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lo float x = sinf(lat) * cosf(lon); float y = cosf(lat); float z = sinf(lat) * sinf(lon); - GPU_vertbuf_vert_set(vbo, *v_ofs, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED}); + GPU_vertbuf_vert_set(vbo, *v_ofs, &(VertShaded){{x, y, z}, VCLASS_EMPTY_SCALED, {x, y, z}}); (*v_ofs)++; } @@ -482,6 +488,8 @@ GPUBatch *DRW_cache_sphere_get(void) const int lon_res = 24; GPUVertFormat format = extra_vert_format(); + GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); int v_len = (lat_res - 1) * lon_res * 6; GPU_vertbuf_data_alloc(vbo, v_len); diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index 7d0cb7c7076..4bd0aac1ecc 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -2721,7 +2721,7 @@ static void *extract_stretch_area_init(const MeshRenderData *mr, void *buf) { static GPUVertFormat format = {0}; if (format.attr_len == 0) { - GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_U16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); + GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); } GPUVertBuf *vbo = buf; @@ -2788,7 +2788,7 @@ static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void * /* Convert in place to avoid an extra allocation */ uint16_t *poly_stretch = (uint16_t *)area_ratio; for (int p = 0; p < mr->poly_len; p++) { - poly_stretch[p] = area_ratio[p] * 65534.0f; + poly_stretch[p] = area_ratio[p] * SHRT_MAX; } /* Copy face data for each loop. */ diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index a486eb6ba77..97afb5e6aa4 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -23,10 +23,8 @@ #ifndef __DRAW_COMMON_H__ #define __DRAW_COMMON_H__ -struct DRWCallBuffer; struct DRWPass; struct DRWShadingGroup; -struct GPUBatch; struct GPUMaterial; struct ModifierData; struct Object; diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index cc3af48e4fe..b580ad21652 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2472,6 +2472,9 @@ void DRW_draw_depth_loop(struct Depsgraph *depsgraph, /* Get list of enabled engines */ { + /* Required by `DRW_state_draw_support()` */ + DST.draw_ctx.v3d = v3d; + drw_engines_enable_basic(); if (DRW_state_draw_support()) { drw_engines_enable_overlays(); diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 83b764317a9..98474c81209 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -1416,53 +1416,19 @@ static void draw_frustum_boundbox_calc(const float (*viewinv)[4], } } -static void draw_frustum_culling_planes_calc(const BoundBox *bbox, float (*frustum_planes)[4]) +static void draw_frustum_culling_planes_calc(const float (*persmat)[4], float (*frustum_planes)[4]) { - /* TODO See if planes_from_projmat cannot do the job. */ + planes_from_projmat(persmat, + frustum_planes[0], + frustum_planes[5], + frustum_planes[3], + frustum_planes[1], + frustum_planes[4], + frustum_planes[2]); - /* Compute clip planes using the world space frustum corners. */ + /* Normalize. */ for (int p = 0; p < 6; p++) { - int q, r, s; - switch (p) { - case 0: - q = 1; - r = 2; - s = 3; - break; /* -X */ - case 1: - q = 0; - r = 4; - s = 5; - break; /* -Y */ - case 2: - q = 1; - r = 5; - s = 6; - break; /* +Z (far) */ - case 3: - q = 2; - r = 6; - s = 7; - break; /* +Y */ - case 4: - q = 0; - r = 3; - s = 7; - break; /* -Z (near) */ - default: - q = 4; - r = 7; - s = 6; - break; /* +X */ - } - - normal_quad_v3(frustum_planes[p], bbox->vec[p], bbox->vec[q], bbox->vec[r], bbox->vec[s]); - /* Increase precision and use the mean of all 4 corners. */ - frustum_planes[p][3] = -dot_v3v3(frustum_planes[p], bbox->vec[p]); - frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[q]); - frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[r]); - frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[s]); - frustum_planes[p][3] *= 0.25f; + frustum_planes[p][3] /= normalize_v3(frustum_planes[p]); } } @@ -1720,7 +1686,7 @@ void DRW_view_update(DRWView *view, } draw_frustum_boundbox_calc(viewinv, winmat, &view->frustum_corners); - draw_frustum_culling_planes_calc(&view->frustum_corners, view->frustum_planes); + draw_frustum_culling_planes_calc(view->storage.persmat, view->frustum_planes); draw_frustum_bound_sphere_calc( &view->frustum_corners, viewinv, winmat, wininv, &view->frustum_bsphere); diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c index 9462a0d8072..47fafbdcbd8 100644 --- a/source/blender/draw/intern/draw_manager_text.c +++ b/source/blender/draw/intern/draw_manager_text.c @@ -213,14 +213,23 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar, float grid = unit->system ? unit->scale_length : v3d->grid; const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0; const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0; - /* when 2 edge-info options are enabled, space apart */ - const bool do_edge_textpair = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) && - (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG); - const short edge_texpair_sep = (short)(5.0f * U.dpi_fac); float clip_planes[4][4]; /* allow for displaying shape keys and deform mods */ BMIter iter; + /* when 2 or more edge-info options are enabled, space apart */ + short edge_tex_count = 0; + if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) { + edge_tex_count += 1; + } + if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG) { + edge_tex_count += 1; + } + if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) && (em->selectmode & SCE_SELECT_EDGE)) { + edge_tex_count += 1; + } + const short edge_tex_sep = (short)((edge_tex_count - 1) * 5.0f * U.dpi_fac); + /* make the precision of the display value proportionate to the gridsize */ if (grid <= 0.01f) { @@ -285,14 +294,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar, numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2)); } - DRW_text_cache_add(dt, - vmid, - numstr, - numstr_len, - 0, - (do_edge_textpair) ? edge_texpair_sep : 0, - txt_flag, - col); + DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, edge_tex_sep, txt_flag, col); } } } @@ -347,14 +349,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar, (is_rad) ? angle : RAD2DEGF(angle), (is_rad) ? "r" : "°"); - DRW_text_cache_add(dt, - vmid, - numstr, - numstr_len, - 0, - (do_edge_textpair) ? -edge_texpair_sep : 0, - txt_flag, - col); + DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, -edge_tex_sep, txt_flag, col); } } } @@ -494,6 +489,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar, if (em->selectmode & SCE_SELECT_EDGE) { BMEdge *e; + const bool use_edge_tex_sep = (edge_tex_count == 2); + const bool use_edge_tex_len = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN); + BM_ITER_MESH_INDEX (e, &iter, em->bm, BM_EDGES_OF_MESH, i) { if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { float v1_clip[3], v2_clip[3]; @@ -506,7 +504,15 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar, mul_m4_v3(ob->obmat, vmid); numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i); - DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, 0, txt_flag, col); + DRW_text_cache_add( + dt, + vmid, + numstr, + numstr_len, + 0, + (use_edge_tex_sep) ? (use_edge_tex_len) ? -edge_tex_sep : edge_tex_sep : 0, + txt_flag, + col); } } } @@ -526,4 +532,4 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar, } } } -}
\ No newline at end of file +} diff --git a/source/blender/draw/intern/draw_manager_text.h b/source/blender/draw/intern/draw_manager_text.h index a8eb45ee8f5..393645e614a 100644 --- a/source/blender/draw/intern/draw_manager_text.h +++ b/source/blender/draw/intern/draw_manager_text.h @@ -23,11 +23,11 @@ #ifndef __DRAW_MANAGER_TEXT_H__ #define __DRAW_MANAGER_TEXT_H__ -struct DRWTextStore; struct ARegion; -struct View3D; +struct DRWTextStore; struct Object; struct UnitSettings; +struct View3D; struct DRWTextStore *DRW_text_cache_create(void); void DRW_text_cache_destroy(struct DRWTextStore *dt); |