Cleanup: vertex painting variable use
authorCampbell Barton <ideasman42@gmail.com>
Thu, 14 Feb 2019 02:06:03 +0000 (13:06 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 14 Feb 2019 02:08:49 +0000 (13:08 +1100)
Assign to local variables when setting up passes,
avoids mix-up between similarly named struct members.

source/blender/draw/modes/paint_vertex_mode.c
source/blender/draw/modes/paint_weight_mode.c

index 2e9c65e..51eeacd 100644 (file)
@@ -144,64 +144,69 @@ static void PAINT_VERTEX_cache_init(void *vedata)
 
        {
                /* Create a pass */
-               psl->vcolor_faces = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Vert Color Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY);
-
-               stl->g_data->fvcolor_shgrp = DRW_shgroup_create(sh_data->vcolor_face, psl->vcolor_faces);
-               DRW_shgroup_uniform_float_copy(stl->g_data->fvcolor_shgrp, "white_factor", 1.0f - v3d->overlay.vertex_paint_mode_opacity);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->vcolor_face, pass);
+               DRW_shgroup_uniform_float_copy(shgrp, "white_factor", 1.0f - v3d->overlay.vertex_paint_mode_opacity);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->fvcolor_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->vcolor_faces = pass;
+               stl->g_data->fvcolor_shgrp = shgrp;
        }
 
        {
-               psl->wire_overlay = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Wire Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
-
-               stl->g_data->lwire_shgrp = DRW_shgroup_create(sh_data->wire_overlay, psl->wire_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->lwire_shgrp, "globalsBlock", G_draw.block_ubo);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->wire_overlay, pass);
+               DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->lwire_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->wire_overlay = pass;
+               stl->g_data->lwire_shgrp = shgrp;
        }
 
        {
-               psl->wire_select_overlay = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Wire Mask Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
-
-               stl->g_data->lwire_select_shgrp = DRW_shgroup_create(sh_data->wire_select_overlay, psl->wire_select_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->lwire_select_shgrp, "globalsBlock", G_draw.block_ubo);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->wire_select_overlay, pass);
+               DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->lwire_select_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->wire_select_overlay = pass;
+               stl->g_data->lwire_select_shgrp = shgrp;
        }
 
        {
-               psl->face_select_overlay = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Face Mask Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND);
-
-               stl->g_data->face_select_shgrp = DRW_shgroup_create(sh_data->face_select_overlay, psl->face_select_overlay);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->face_select_overlay, pass);
                static float col[4] = {1.0f, 1.0f, 1.0f, 0.2f};
-               DRW_shgroup_uniform_vec4(stl->g_data->face_select_shgrp, "color", col, 1);
+               DRW_shgroup_uniform_vec4(shgrp, "color", col, 1);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->face_select_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->face_select_overlay = pass;
+               stl->g_data->face_select_shgrp = shgrp;
        }
 
        {
-               psl->vert_select_overlay = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Vert Mask Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
-
-               stl->g_data->vert_select_shgrp = DRW_shgroup_create(sh_data->vert_select_overlay, psl->vert_select_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->vert_select_shgrp, "globalsBlock", G_draw.block_ubo);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->vert_select_overlay, pass);
+               DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->vert_select_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->vert_select_overlay = pass;
+               stl->g_data->vert_select_shgrp = shgrp;
        }
 }
 
index af34214..42c46f6 100644 (file)
@@ -146,70 +146,72 @@ static void PAINT_WEIGHT_cache_init(void *vedata)
 
        {
                /* Create a pass */
-               psl->weight_faces = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Weight Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY);
-
-               stl->g_data->fweights_shgrp = DRW_shgroup_create(sh_data->weight_face, psl->weight_faces);
-
-               DRW_shgroup_uniform_bool_copy(stl->g_data->fweights_shgrp, "drawContours", (v3d->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0);
-
-               DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "opacity", &v3d->overlay.weight_paint_mode_opacity, 1);
-               DRW_shgroup_uniform_texture(stl->g_data->fweights_shgrp, "colorramp", G_draw.weight_ramp);
-               DRW_shgroup_uniform_block(stl->g_data->fweights_shgrp, "globalsBlock", G_draw.block_ubo);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->weight_face, pass);
+               DRW_shgroup_uniform_bool_copy(shgrp, "drawContours", (v3d->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0);
+               DRW_shgroup_uniform_float(shgrp, "opacity", &v3d->overlay.weight_paint_mode_opacity, 1);
+               DRW_shgroup_uniform_texture(shgrp, "colorramp", G_draw.weight_ramp);
+               DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->fweights_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->weight_faces = pass;
+               stl->g_data->fweights_shgrp = shgrp;
        }
 
        {
-               psl->wire_overlay = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Wire Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
-
-               stl->g_data->lwire_shgrp = DRW_shgroup_create(sh_data->wire_overlay, psl->wire_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->lwire_shgrp, "globalsBlock", G_draw.block_ubo);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->wire_overlay, pass);
+               DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->lwire_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->wire_overlay = pass;
+               stl->g_data->lwire_shgrp = shgrp;
        }
 
        {
-               psl->wire_select_overlay = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Wire Mask Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
-
-               stl->g_data->lwire_select_shgrp = DRW_shgroup_create(sh_data->wire_select_overlay, psl->wire_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->lwire_select_shgrp, "globalsBlock", G_draw.block_ubo);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->wire_select_overlay, pass);
+               DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->lwire_select_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->wire_select_overlay = pass;
+               stl->g_data->lwire_select_shgrp = shgrp;
        }
 
        {
-               psl->face_select_overlay = DRW_pass_create(
+               static float col[4] = {1.0f, 1.0f, 1.0f, 0.2f};
+               DRWPass *pass = DRW_pass_create(
                        "Face Mask Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND);
-
-               stl->g_data->face_shgrp = DRW_shgroup_create(sh_data->face_select_overlay, psl->face_select_overlay);
-
-               static float col[4] = {1.0f, 1.0f, 1.0f, 0.2f};
-               DRW_shgroup_uniform_vec4(stl->g_data->face_shgrp, "color", col, 1);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->face_select_overlay, pass);
+               DRW_shgroup_uniform_vec4(shgrp, "color", col, 1);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->face_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->face_select_overlay = pass;
+               stl->g_data->face_shgrp = shgrp;
        }
 
        {
-               psl->vert_select_overlay = DRW_pass_create(
+               DRWPass *pass = DRW_pass_create(
                        "Vert Mask Pass",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
-
-               stl->g_data->vert_select_shgrp = DRW_shgroup_create(sh_data->vert_select_overlay, psl->vert_select_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->vert_select_shgrp, "globalsBlock", G_draw.block_ubo);
+               DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->vert_select_overlay, pass);
+               DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
                if (rv3d->rflag & RV3D_CLIPPING) {
-                       DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->vert_select_shgrp, rv3d);
+                       DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
                }
+               psl->vert_select_overlay = pass;
+               stl->g_data->vert_select_shgrp = shgrp;
        }
 }