diff options
Diffstat (limited to 'source/blender/draw')
19 files changed, 29 insertions, 38 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c index ef4d88bd521..0d14a0c5f61 100644 --- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c +++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c @@ -62,7 +62,7 @@ static float circle_to_polygon_radius(float sides_count, float theta) cosf(theta - side_angle * floorf((sides_count * theta + M_PI) / (2.0f * M_PI))); } -/* Remap input angle to have homogenous spacing of points along a polygon edge. +/* Remap input angle to have homogeneous spacing of points along a polygon edge. * Expect theta to be in [0..2pi] range. */ static float circle_to_polygon_angle(float sides_count, float theta) { diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index a20fe156eda..7029d015b22 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -613,7 +613,7 @@ void EEVEE_lightprobes_planar_data_from_object(Object *ob, eplanar->clip_edge_y_neg = dot_v3v3(eplanar->clip_vec_y, vec); /* Facing factors */ - float max_angle = max_ff(1e-2f, 1.0f - probe->falloff) * M_PI * 0.5f; + float max_angle = max_ff(1e-2f, 1.0f - probe->falloff) * M_PI_2; float min_angle = 0.0f; eplanar->facing_scale = 1.0f / max_ff(1e-8f, cosf(min_angle) - cosf(max_angle)); eplanar->facing_bias = -min_ff(1.0f - 1e-8f, cosf(max_angle)) * eplanar->facing_scale; diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 0ef78d97a79..874c2815b8b 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -217,7 +217,7 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, float x_rot_matrix[3][3]; DRW_view_viewmat_get(NULL, view_matrix, false); copy_m3_m4(view_rot_matrix, view_matrix); - axis_angle_to_mat3_single(x_rot_matrix, 'X', M_PI / 2.0f); + axis_angle_to_mat3_single(x_rot_matrix, 'X', M_PI_2); mul_m3_m3m3(view_rot_matrix, x_rot_matrix, view_rot_matrix); mul_m3_m3m3(view_rot_matrix, g_data->studiolight_matrix, view_rot_matrix); copy_m3_m3(studiolight_matrix, view_rot_matrix); diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl index 051a08d25e6..d724b4d4609 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl @@ -35,7 +35,7 @@ float circle_to_polygon_radius(float sides_count, float theta) cos(theta - side_angle * floor((sides_count * theta + M_PI) / M_2PI)); } -/* Remap input angle to have homogenous spacing of points along a polygon edge. +/* Remap input angle to have homogeneous spacing of points along a polygon edge. * Expect theta to be in [0..2pi] range. */ float circle_to_polygon_angle(float sides_count, float theta) { diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl index f5c45d147e6..fe1ab395a54 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl @@ -12,7 +12,7 @@ #pragma BLENDER_REQUIRE(common_utiltex_lib.glsl) #pragma BLENDER_REQUIRE(effect_dof_lib.glsl) -/* Mipmapped input buffers, halfres but with padding to ensure mipmap alignement. */ +/* Mipmapped input buffers, halfres but with padding to ensure mipmap alignment. */ uniform sampler2D colorBuffer; uniform sampler2D cocBuffer; diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl index 59564890d7e..b05223e755d 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl @@ -103,7 +103,7 @@ void main() color4 = colors[3] * weights[3]; /* Extend to cover at least the unit circle */ - const float extend = (cos(M_PI / 4.0) + 1.0) * 2.0; + const float extend = (cos(M_PI_4) + 1.0) * 2.0; /* Crappy diagram * ex 1 * | \ diff --git a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl index 8ef39a55921..ce455123987 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl @@ -4,7 +4,7 @@ * Adapted from http://rastergrid.com/blog/2010/10/hierarchical-z-map-based-occlusion-culling/ * * Major simplification has been made since we pad the buffer to always be bigger than input to - * avoid mipmapping misalignement. + * avoid mipmapping misalignment. */ #ifdef LAYERED diff --git a/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl index ba90f5ae531..831ed0a119a 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl @@ -40,7 +40,7 @@ float light_translucent_power_with_falloff(LightData ld, vec3 N, vec4 l_vector) if (ld.l_type >= AREA_RECT) { power = (ld.l_sizex * ld.l_sizey * 4.0 * M_PI) * (1.0 / 80.0); if (ld.l_type == AREA_ELLIPSE) { - power *= M_PI * 0.25; + power *= M_PI_4; } power *= 0.3 * 20.0 * max(0.0, dot(-ld.l_forward, l_vector.xyz / l_vector.w)); /* XXX ad hoc, empirical */ diff --git a/source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl index 9077b414026..7ab532ea0fb 100644 --- a/source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl @@ -16,9 +16,9 @@ out vec4 FragColor; vec3 background_transform_to_world(vec3 viewvec) { vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(viewvec, 1.0) : vec4(0.0, 0.0, 1.0, 1.0); - vec4 co_homogenous = (ProjectionMatrixInverse * v); + vec4 co_homogeneous = (ProjectionMatrixInverse * v); - vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0); + vec4 co = vec4(co_homogeneous.xyz / co_homogeneous.w, 0.0); return (ViewMatrixInverse * co).xyz; } diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c b/source/blender/draw/engines/gpencil/gpencil_draw_data.c index 6c904745709..c3f96ecd0a2 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c @@ -387,7 +387,7 @@ void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob) normalize_m4_m4(mat, ob->obmat); invert_m4(mat); gp_light->type = GP_LIGHT_TYPE_SPOT; - gp_light->spotsize = cosf(M_PI * 0.5f); + gp_light->spotsize = cosf(M_PI_2); gp_light->spotblend = (1.0f - gp_light->spotsize) * 1.0f; } else if (la->type == LA_SUN) { diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl index 36a52e05a4a..b4a26ec8103 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl @@ -442,7 +442,7 @@ void stroke_vertex() if (is_dot) { # ifdef GP_MATERIAL_BUFFER_LEN int alignement = GP_FLAG(m) & GP_STROKE_ALIGNMENT; - /* For one point strokes use object aligment. */ + /* For one point strokes use object alignment. */ if (ma.x == -1 && ma2.x == -1 && alignement == GP_STROKE_ALIGNMENT_STROKE) { alignement = GP_STROKE_ALIGNMENT_OBJECT; } diff --git a/source/blender/draw/engines/image/image_buffer_cache.hh b/source/blender/draw/engines/image/image_buffer_cache.hh index ef11551c879..470e9f225b4 100644 --- a/source/blender/draw/engines/image/image_buffer_cache.hh +++ b/source/blender/draw/engines/image/image_buffer_cache.hh @@ -1,20 +1,5 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2022, Blender Foundation. - */ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2022 Blender Foundation. */ /** \file * \ingroup draw_engine diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.c index 2636d7876d5..b3c0c5da9b5 100644 --- a/source/blender/draw/engines/overlay/overlay_wireframe.c +++ b/source/blender/draw/engines/overlay/overlay_wireframe.c @@ -276,8 +276,12 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, const bool is_sculpt_mode = ((ob->mode & OB_MODE_SCULPT) != 0) && (ob->sculpt != NULL); const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) && !DRW_state_is_image_render(); + const bool is_instance = (ob->base_flag & BASE_FROM_DUPLI); + const bool instance_parent_in_edit_mode = is_instance ? DRW_object_is_in_edit_mode( + DRW_object_get_dupli_parent(ob)) : + false; const bool use_coloring = (use_wire && !is_edit_mode && !is_sculpt_mode && - !has_edit_mesh_cage); + !has_edit_mesh_cage && !instance_parent_in_edit_mode); geom = DRW_cache_object_face_wireframe_get(ob); if (geom || use_sculpt_pbvh) { diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index bf197986687..010f424b9da 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -275,7 +275,7 @@ void workbench_update_world_ubo(WORKBENCH_PrivateData *wpd) copy_v2_v2(wd.viewport_size_inv, DRW_viewport_invert_size_get()); copy_v3_v3(wd.object_outline_color, wpd->shading.object_outline_color); wd.object_outline_color[3] = 1.0f; - wd.ui_scale = G_draw.block.sizePixel; + wd.ui_scale = DRW_state_is_image_render() ? 1.0f : G_draw.block.sizePixel; wd.matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0; workbench_studiolight_data_update(wpd, &wd); diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c index 6b64a9d7f09..58d49cf226e 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.c +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c @@ -31,22 +31,22 @@ static void square_to_circle(float x, float y, float *r, float *T) if (x > -y) { if (x > y) { *r = x; - *T = (M_PI / 4.0f) * (y / x); + *T = M_PI_4 * (y / x); } else { *r = y; - *T = (M_PI / 4.0f) * (2 - (x / y)); + *T = M_PI_4 * (2 - (x / y)); } } else { if (x < y) { *r = -x; - *T = (M_PI / 4.0f) * (4 + (y / x)); + *T = M_PI_4 * (4 + (y / x)); } else { *r = -y; if (y != 0) { - *T = (M_PI / 4.0f) * (6 - (x / y)); + *T = M_PI_4 * (6 - (x / y)); } else { *T = 0.0f; diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index dea3fa9b75a..e84f2c7a327 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -854,6 +854,7 @@ static void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, } mesh_render_data_update_looptris(mr, MR_ITER_LOOPTRI, MR_DATA_LOOPTRI); + mesh_render_data_update_normals(mr, MR_DATA_TAN_LOOP_NOR); mesh_render_data_update_loose_geom(mr, mbc, MR_ITER_LEDGE | MR_ITER_LVERT, MR_DATA_LOOSE_GEOM); DRW_subdivide_loose_geom(subdiv_cache, mbc); diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index df1ac12605a..aea71d965d1 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -340,7 +340,7 @@ bool hair_ensure_procedural_data(Object *object, HairBatchCache *cache = curves_batch_cache_get(curves); *r_hair_cache = &cache->hair; - const int steps = 2; /* TODO: don't hard-code? */ + const int steps = 3; /* TODO: don't hard-code? */ (*r_hair_cache)->final[subdiv].strands_res = 1 << (steps + subdiv); /* Refreshed on combing and simulation. */ diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 2897234f4dc..c7edf003346 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -135,7 +135,7 @@ void DRW_globals_update(void) UI_GetThemeColor4fv(TH_CFRAME, gb->colorCurrentFrame); - /* Metaball */ + /* Meta-ball. */ UI_COLOR_RGBA_FROM_U8(0xA0, 0x30, 0x30, 0xFF, gb->colorMballRadius); UI_COLOR_RGBA_FROM_U8(0xF0, 0xA0, 0xA0, 0xFF, gb->colorMballRadiusSelect); UI_COLOR_RGBA_FROM_U8(0x30, 0xA0, 0x30, 0xFF, gb->colorMballStiffness); diff --git a/source/blender/draw/intern/shaders/common_math_lib.glsl b/source/blender/draw/intern/shaders/common_math_lib.glsl index 479f9cd1827..bc31649fd0f 100644 --- a/source/blender/draw/intern/shaders/common_math_lib.glsl +++ b/source/blender/draw/intern/shaders/common_math_lib.glsl @@ -6,6 +6,7 @@ #define M_PI 3.14159265358979323846 /* pi */ #define M_2PI 6.28318530717958647692 /* 2*pi */ #define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_4 0.78539816339744830962 /* pi/4 */ #define M_1_PI 0.318309886183790671538 /* 1/pi */ #define M_1_2PI 0.159154943091895335768 /* 1/(2*pi) */ #define M_1_PI2 0.101321183642337771443 /* 1/(pi^2) */ @@ -93,7 +94,7 @@ vec2 sqr(vec2 a) { return a * a; } vec3 sqr(vec3 a) { return a * a; } vec4 sqr(vec4 a) { return a * a; } -/* Use manual powers for fixed powers. pow() can have unpredicatble results on some implementations. +/* Use manual powers for fixed powers. pow() can have unpredictable results on some implementations. * (see T87369, T87541) */ float pow6(float x) { return sqr(sqr(x) * x); } float pow8(float x) { return sqr(sqr(sqr(x))); } |