From 49af17beb8d2aca856ff8e23bac99841d1b45f5b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 7 Jul 2018 02:52:11 +1200 Subject: Fix T55796: Motion Paths are not being drawn as overlay Remove depth testing flags from motion path pass drawing, so that they always appear to draw in "x-ray" style on top of everything, making it easier for animators to see what they're doing. --- source/blender/draw/intern/draw_anim_viz.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c index 42c36ab3662..d19bd54ff5f 100644 --- a/source/blender/draw/intern/draw_anim_viz.c +++ b/source/blender/draw/intern/draw_anim_viz.c @@ -149,12 +149,12 @@ static void MPATH_cache_init(void *vedata) MPATH_PassList *psl = ((MPATH_Data *)vedata)->psl; { - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; + DRWState state = DRW_STATE_WRITE_COLOR; psl->lines = DRW_pass_create("Motionpath Line Pass", state); } { - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_POINT; + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_POINT; psl->points = DRW_pass_create("Motionpath Point Pass", state); } } -- cgit v1.2.3 From a48b52d5466939044589bc332918463eef186ba8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 17:43:53 +0200 Subject: 3D View: support object type visibility/selection Trying to have a single option for this is too likely to be insufficient in some cases. Instead, support object type visibility & selectability per view-port. --- source/blender/draw/intern/draw_manager.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index ea25739e52d..7e40966f9c8 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1274,9 +1274,12 @@ void DRW_draw_render_loop_ex( PROFILE_START(stime); drw_engines_cache_init(); + const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) { - drw_engines_cache_populate(ob); + if ((object_type_exclude_viewport & (1 << ob->type)) == 0) { + drw_engines_cache_populate(ob); + } } DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END; @@ -1557,12 +1560,17 @@ void DRW_render_object_iter( void *vedata, RenderEngine *engine, struct Depsgraph *depsgraph, void (*callback)(void *vedata, Object *ob, RenderEngine *engine, struct Depsgraph *depsgraph)) { + const DRWContextState *draw_ctx = DRW_context_state_get(); + DRW_hair_init(); + const int object_type_exclude_viewport = draw_ctx->v3d->object_type_exclude_viewport; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) { - DST.ob_state = NULL; - callback(vedata, ob, engine, depsgraph); + if ((object_type_exclude_viewport & (1 << ob->type)) == 0) { + DST.ob_state = NULL; + callback(vedata, ob, engine, depsgraph); + } } DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END } @@ -1701,6 +1709,9 @@ void DRW_draw_select_loop( #endif } else { + const int object_type_exclude_select = ( + v3d->object_type_exclude_viewport | v3d->object_type_exclude_select + ); bool filter_exclude = false; DEG_OBJECT_ITER_BEGIN( depsgraph, ob, @@ -1708,8 +1719,9 @@ void DRW_draw_select_loop( DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI) { - if ((ob->base_flag & BASE_SELECTABLE) != 0) { - + if ((ob->base_flag & BASE_SELECTABLE) && + (object_type_exclude_select & (1 << ob->type)) == 0) + { if (object_filter_fn != NULL) { if (ob->base_flag & BASE_FROMDUPLI) { /* pass (use previous filter_exclude value) */ @@ -1880,9 +1892,12 @@ void DRW_draw_depth_loop( { drw_engines_cache_init(); + const int object_type_exclude_viewport = v3d->object_type_exclude_viewport; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) { - drw_engines_cache_populate(ob); + if ((object_type_exclude_viewport & (1 << ob->type)) == 0) { + drw_engines_cache_populate(ob); + } } DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END; -- cgit v1.2.3 From 9d43ed521cd085b91decfcfe9a437a5faa317f14 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 12:47:13 +0200 Subject: Cleanup: abbreviate unsigned types (draw manager) --- source/blender/draw/intern/DRW_render.h | 6 ++--- source/blender/draw/intern/draw_anim_viz.c | 2 +- source/blender/draw/intern/draw_armature.c | 20 +++++++-------- source/blender/draw/intern/draw_cache.c | 12 ++++----- source/blender/draw/intern/draw_cache_impl_mesh.c | 30 +++++++++++----------- .../draw/intern/draw_cache_impl_particles.c | 14 +++++----- source/blender/draw/intern/draw_hair_private.h | 2 +- source/blender/draw/intern/draw_manager.h | 6 ++--- source/blender/draw/intern/draw_manager_text.c | 4 +-- source/blender/draw/intern/draw_manager_text.h | 2 +- source/blender/draw/intern/draw_view.c | 16 ++++++------ 11 files changed, 57 insertions(+), 57 deletions(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index fdb1b87589e..0d443293d04 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -346,9 +346,9 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup); void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]); void DRW_shgroup_call_range_add( DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count); -void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, unsigned int point_count, float (*obmat)[4]); -void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, unsigned int line_count, float (*obmat)[4]); -void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, unsigned int tria_count, float (*obmat)[4]); +void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_count, float (*obmat)[4]); +void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]); +void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]); void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, struct Object *ob); void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, bool bypass_culling); #define DRW_shgroup_call_object_add(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, false) diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c index d19bd54ff5f..e634710980a 100644 --- a/source/blender/draw/intern/draw_anim_viz.c +++ b/source/blender/draw/intern/draw_anim_viz.c @@ -256,7 +256,7 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl, bool show_kf_no = (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) != 0; if ((avs->path_viewflag & (MOTIONPATH_VIEW_FNUMS)) || (show_kf_no && show_keyframes)) { int i; - unsigned char col[4], col_kf[4]; + uchar col[4], col_kf[4]; UI_GetThemeColor3ubv(TH_TEXT_HI, col); UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col_kf); col[3] = col_kf[3] = 255; diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index 3faf8a352b2..9bc8b70b67c 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -514,7 +514,7 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan) } /* This function is for brightening/darkening a given color (like UI_GetThemeColorShade3ubv()) */ -static void cp_shade_color3ub(unsigned char cp[3], const int offset) +static void cp_shade_color3ub(uchar cp[3], const int offset) { int r, g, b; @@ -549,7 +549,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const case PCHAN_COLOR_NORMAL: { if (bcolor) { - unsigned char cp[4] = {255}; + uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { copy_v3_v3_char((char *)cp, bcolor->active); @@ -591,7 +591,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const if (bcolor) { float solid_bcolor[3]; - rgb_uchar_to_float(solid_bcolor, (unsigned char *)bcolor->solid); + rgb_uchar_to_float(solid_bcolor, (uchar *)bcolor->solid); interp_v3_v3v3(fcolor, fcolor, solid_bcolor, 1.0f); } @@ -600,7 +600,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const case PCHAN_COLOR_CONSTS: { if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { - unsigned char cp[4]; + 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); @@ -618,7 +618,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const case PCHAN_COLOR_SPHEREBONE_BASE: { if (bcolor) { - unsigned char cp[4] = {255}; + uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { copy_v3_v3_char((char *)cp, bcolor->active); @@ -649,7 +649,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const case PCHAN_COLOR_SPHEREBONE_END: { if (bcolor) { - unsigned char cp[4] = {255}; + uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { copy_v3_v3_char((char *)cp, bcolor->active); @@ -683,7 +683,7 @@ 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))) { - unsigned char cp[4]; + 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); @@ -695,7 +695,7 @@ static bool set_pchan_color(short colCode, const int boneflag, const short const else { if (bcolor) { const char *cp = bcolor->solid; - rgb_uchar_to_float(fcolor, (unsigned char *)cp); + rgb_uchar_to_float(fcolor, (uchar *)cp); fcolor[3] = 204.f / 255.f; } else { @@ -1588,7 +1588,7 @@ static void draw_armature_edit(Object *ob) /* Draw names of bone */ if (show_text && (arm->flag & ARM_DRAWNAMES)) { - unsigned char color[4]; + uchar color[4]; UI_GetThemeColor4ubv((eBone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, color); float vec[3]; @@ -1702,7 +1702,7 @@ static void draw_armature_pose(Object *ob, const float const_color[4]) /* Draw names of bone */ if (show_text && (arm->flag & ARM_DRAWNAMES)) { - unsigned char color[4]; + uchar color[4]; UI_GetThemeColor4ubv((arm->flag & ARM_POSEMODE) && (bone->flag & BONE_SELECTED) ? TH_TEXT_HI : TH_TEXT, color); float vec[3]; diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index a8d2c2a3642..a6a0472fe86 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2985,7 +2985,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) case PART_DRAW_CROSS: if (!SHC.drw_particle_cross) { static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, axis_id; + static uint pos_id, axis_id; if (format.attrib_ct == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -3032,7 +3032,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) case PART_DRAW_AXIS: if (!SHC.drw_particle_axis) { static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, axis_id; + static uint pos_id, axis_id; if (format.attrib_ct == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -3083,7 +3083,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) int axis = -1; static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, axis_id; + static uint pos_id, axis_id; if (format.attrib_ct == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -3128,8 +3128,8 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) const int vert_ct = segments + 8; const int index_ct = vert_ct + 5; - unsigned char red[3] = {255, 0, 0}; - unsigned char white[3] = {255, 255, 255}; + uchar red[3] = {255, 0, 0}; + uchar white[3] = {255, 255, 255}; static Gwn_VertFormat format = { 0 }; static struct { uint pos, color; } attr_id; @@ -3161,7 +3161,7 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) GWN_indexbuf_add_generic_vert(&elb, 0); if (crosshair_lines) { - unsigned char crosshair_color[3]; + uchar crosshair_color[3]; UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color); GWN_indexbuf_add_primitive_restart(&elb); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index eafcfb007e7..198518cd887 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -116,10 +116,10 @@ typedef struct EdgeAdjacentVerts { } EdgeAdjacentVerts; typedef struct EdgeDrawAttr { - unsigned char v_flag; - unsigned char e_flag; - unsigned char crease; - unsigned char bweight; + uchar v_flag; + uchar e_flag; + uchar crease; + uchar bweight; } EdgeDrawAttr; typedef struct MeshRenderData { @@ -1349,9 +1349,9 @@ enum { * (see gpu_shader_edit_mesh_overlay_geom.glsl) */ }; -static unsigned char mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace *efa) +static uchar mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace *efa) { - unsigned char fflag = 0; + uchar fflag = 0; if (efa == rdata->efa_act) fflag |= VFLAG_FACE_ACTIVE; @@ -1397,10 +1397,10 @@ static void mesh_render_data_edge_flag( } } -static unsigned char mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *eve) +static uchar mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *eve) { - unsigned char vflag = 0; + uchar vflag = 0; /* Current vertex */ if (eve == rdata->eve_act) @@ -1417,8 +1417,8 @@ static void add_overlay_tri( const uint pos_id, const uint vnor_id, const uint lnor_id, const uint data_id, const BMLoop **bm_looptri, const int base_vert_idx) { - unsigned char fflag; - unsigned char vflag; + uchar fflag; + uchar vflag; if (vbo_pos) { /* TODO(sybren): deduplicate this and all the other places it's pasted to in this file. */ @@ -1528,7 +1528,7 @@ static void add_overlay_loose_vert( } if (vbo_data) { - unsigned char vflag[4] = {0, 0, 0, 0}; + uchar vflag[4] = {0, 0, 0, 0}; vflag[0] = mesh_render_data_vertex_flag(rdata, eve); GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx, vflag); } @@ -2886,7 +2886,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( static Gwn_VertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id) { static Gwn_VertFormat format_pos = { 0 }; - static unsigned pos_id; + static uint pos_id; if (format_pos.attrib_ct == 0) { pos_id = GWN_vertformat_attr_add(&format_pos, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2898,7 +2898,7 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno { static Gwn_VertFormat format_nor = { 0 }; static Gwn_VertFormat format_nor_loop = { 0 }; - static unsigned vnor_id, vnor_loop_id, lnor_id; + static uint vnor_id, vnor_loop_id, lnor_id; if (format_nor.attrib_ct == 0) { vnor_id = GWN_vertformat_attr_add(&format_nor, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); vnor_loop_id = GWN_vertformat_attr_add(&format_nor_loop, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); @@ -2918,7 +2918,7 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno static Gwn_VertFormat *edit_mesh_overlay_data_format(uint *r_data_id) { static Gwn_VertFormat format_flag = { 0 }; - static unsigned data_id; + static uint data_id; if (format_flag.attrib_ct == 0) { data_id = GWN_vertformat_attr_add(&format_flag, "data", GWN_COMP_U8, 4, GWN_FETCH_INT); } @@ -3420,7 +3420,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender int j, j_next; for (j = 2, j_next = 0; j_next < 3; j = j_next++) { MEdge *ed = &medge[mloop[mlt->tri[j]].e]; - unsigned int tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v}; + uint tri_edge[2] = {mloop[mlt->tri[j]].v, mloop[mlt->tri[j_next]].v}; if (((ed->v1 == tri_edge[0]) && (ed->v2 == tri_edge[1])) || ((ed->v1 == tri_edge[1]) && (ed->v2 == tri_edge[0]))) diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 28693b47c89..3cf47fb5e25 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -263,7 +263,7 @@ static void ensure_seg_pt_count( } } -static void particle_pack_mcol(MCol *mcol, unsigned short r_scol[3]) +static void particle_pack_mcol(MCol *mcol, ushort r_scol[3]) { /* Convert to linear ushort and swizzle */ r_scol[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[mcol->b]); @@ -573,7 +573,7 @@ static int particle_batch_cache_fill_segments( } for (int k = 0; k < num_col_layers; k++) { /* TODO Put the conversion outside the loop */ - unsigned short scol[4]; + ushort scol[4]; particle_pack_mcol( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], @@ -600,7 +600,7 @@ static int particle_batch_cache_fill_segments( } for (int k = 0; k < num_col_layers; k++) { /* TODO Put the conversion outside the loop */ - unsigned short scol[4]; + ushort scol[4]; particle_pack_mcol( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], @@ -734,7 +734,7 @@ static int particle_batch_cache_fill_strands_data( copy_v2_v2(t_uv, uv[k]); } for (int k = 0; k < num_col_layers; k++) { - unsigned short *scol = (unsigned short *)GWN_vertbuf_raw_step(col_step + k); + ushort *scol = (ushort *)GWN_vertbuf_raw_step(col_step + k); particle_pack_mcol( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], @@ -1196,7 +1196,7 @@ static void particle_batch_cache_ensure_pos( } static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, rot_id, val_id; + static uint pos_id, rot_id, val_id; int i, curr_point; ParticleData *pa; ParticleKey state; @@ -1420,7 +1420,7 @@ static void particle_batch_cache_ensure_edit_inner_pos( } static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, color_id; + static uint pos_id, color_id; GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); @@ -1491,7 +1491,7 @@ static void particle_batch_cache_ensure_edit_tip_pos( } static Gwn_VertFormat format = { 0 }; - static unsigned pos_id, color_id; + static uint pos_id, color_id; GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h index 2e6c9a0d3c1..28993614688 100644 --- a/source/blender/draw/intern/draw_hair_private.h +++ b/source/blender/draw/intern/draw_hair_private.h @@ -31,7 +31,7 @@ #define __DRAW_HAIR_PRIVATE_H__ #define MAX_LAYER_NAME_CT 3 /* u0123456789, u, a0123456789 */ -#define MAX_LAYER_NAME_LEN DECIMAL_DIGITS_BOUND(unsigned int) + 2 +#define MAX_LAYER_NAME_LEN DECIMAL_DIGITS_BOUND(uint) + 2 #define MAX_THICKRES 2 /* see eHairType */ #define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */ diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index e811e9ea8a9..91a30fa45ae 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -106,8 +106,8 @@ typedef struct DRWCallState { DRWCallVisibilityFn *visibility_cb; void *user_data; - unsigned char flag; - unsigned char cache_id; /* Compared with DST.state_cache_id to see if matrices are still valid. */ + uchar flag; + uchar cache_id; /* Compared with DST.state_cache_id to see if matrices are still valid. */ uint16_t matflag; /* Which matrices to compute. */ /* Culling: Using Bounding Sphere for now for faster culling. * Not ideal for planes. */ @@ -308,7 +308,7 @@ typedef struct DRWManager { DRWInstanceData *object_instance_data[MAX_INSTANCE_DATA_SIZE]; /* State of the object being evaluated if already allocated. */ DRWCallState *ob_state; - unsigned char state_cache_id; /* Could be larger but 254 view changes is already a lot! */ + uchar state_cache_id; /* Could be larger but 254 view changes is already a lot! */ /* Rendering state */ GPUShader *shader; diff --git a/source/blender/draw/intern/draw_manager_text.c b/source/blender/draw/intern/draw_manager_text.c index 1f385b958b8..977374a00c5 100644 --- a/source/blender/draw/intern/draw_manager_text.c +++ b/source/blender/draw/intern/draw_manager_text.c @@ -46,7 +46,7 @@ typedef struct ViewCachedString { struct ViewCachedString *next, *prev; float vec[3]; union { - unsigned char ub[4]; + uchar ub[4]; int pack; } col; short sco[2]; @@ -79,7 +79,7 @@ void DRW_text_cache_add( const float co[3], const char *str, const int str_len, short xoffs, short flag, - const unsigned char col[4]) + const uchar col[4]) { int alloc_len; ViewCachedString *vos; diff --git a/source/blender/draw/intern/draw_manager_text.h b/source/blender/draw/intern/draw_manager_text.h index a675a200924..14c33be4cf8 100644 --- a/source/blender/draw/intern/draw_manager_text.h +++ b/source/blender/draw/intern/draw_manager_text.h @@ -34,7 +34,7 @@ void DRW_text_cache_add( const float co[3], const char *str, const int str_len, short xoffs, short flag, - const unsigned char col[4]); + const uchar col[4]); void DRW_text_cache_draw(struct DRWTextStore *dt, struct ARegion *ar); diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 347932619b9..cab796a62d3 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -116,7 +116,7 @@ static int gridline_count(ARegion *ar, double x0, double y0, double dx) static bool drawgrid_draw( ARegion *ar, double x0, double y0, double dx, int skip_mod, - unsigned pos, unsigned col, GLubyte col_value[3]) + uint pos, uint col, GLubyte col_value[3]) { /* skip every skip_mod lines relative to each axis; they will be overlaid by another drawgrid_draw * always skip exact x0 & y0 axes; they will be drawn later in color @@ -220,7 +220,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - unsigned char col[3], col2[3]; + uchar col[3], col2[3]; UI_GetThemeColor3ubv(TH_GRID, col); if (unit->system) { @@ -369,17 +369,17 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) bool show_axis_y = (v3d->gridflag & V3D_SHOW_Y) != 0; bool show_axis_z = (v3d->gridflag & V3D_SHOW_Z) != 0; - unsigned char col_grid[3], col_axis[3]; + uchar col_grid[3], col_axis[3]; glLineWidth(1.0f); UI_GetThemeColor3ubv(TH_GRID, col_grid); if (show_floor) { - const unsigned vertex_ct = 2 * (gridlines * 4 + 2); + const uint vertex_ct = 2 * (gridlines * 4 + 2); const int sublines = v3d->gridsubdiv; - unsigned char col_bg[3], col_grid_emphasise[3], col_grid_light[3]; + uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3]; Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -583,9 +583,9 @@ void DRW_draw_background(void) glDisable(GL_DEPTH_TEST); Gwn_VertFormat *format = immVertexFormat(); - unsigned pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - unsigned char col_hi[3], col_lo[3]; + uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + uchar col_hi[3], col_lo[3]; gpuPushMatrix(); gpuLoadIdentity(); -- cgit v1.2.3 From 392ed710d62ce496491566f9743ad9e66737072a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 12:45:53 +0200 Subject: Cleanup: rename 'ct' to 'len' for size vars --- source/blender/draw/intern/DRW_render.h | 4 +- source/blender/draw/intern/draw_cache.c | 20 +++++----- source/blender/draw/intern/draw_cache_impl_mesh.c | 12 +++--- .../draw/intern/draw_cache_impl_particles.c | 46 +++++++++++----------- source/blender/draw/intern/draw_hair.c | 4 +- source/blender/draw/intern/draw_hair_private.h | 6 +-- source/blender/draw/intern/draw_instance_data.c | 16 ++++---- source/blender/draw/intern/draw_manager_data.c | 4 +- source/blender/draw/intern/draw_manager_exec.c | 6 +-- source/blender/draw/intern/draw_view.c | 42 ++++++++++---------- 10 files changed, 80 insertions(+), 80 deletions(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 0d443293d04..f732082018d 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -346,7 +346,7 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup); void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]); void DRW_shgroup_call_range_add( DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count); -void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_count, float (*obmat)[4]); +void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]); void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]); void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]); void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, struct Object *ob); @@ -496,7 +496,7 @@ void DRW_state_lock(DRWState state); void DRW_state_invert_facing(void); -void DRW_state_clip_planes_count_set(uint plane_ct); +void DRW_state_clip_planes_count_set(uint plane_len); void DRW_state_clip_planes_reset(void); /* Culling, return true if object is inside view frustum. */ diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index a6a0472fe86..5c3546f07a7 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2349,26 +2349,26 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) a = axis + 0.31f; /* Axis name */ - int axis_v_ct; + int axis_v_len; float (*axis_verts)[2]; if (axis == 0) { axis_verts = x_axis_name; - axis_v_ct = X_LEN; + axis_v_len = X_LEN; } else if (axis == 1) { axis_verts = y_axis_name; - axis_v_ct = Y_LEN; + axis_v_len = Y_LEN; } else { axis_verts = z_axis_name; - axis_v_ct = Z_LEN; + axis_v_len = Z_LEN; } /* Axis name shadows */ copy_v3_fl(c, 0.0f); c[axis] = 0.3f; for (int j = 0; j < SHADOW_RES; ++j) { - for (int i = 0; i < axis_v_ct; ++i) { + for (int i = 0; i < axis_v_len; ++i) { float tmp[2]; add_v2_v2v2(tmp, axis_verts[i], axis_name_shadow[j]); set_bone_axis_vert(vbo, attr_id.axis, attr_id.pos, attr_id.col, @@ -2379,7 +2379,7 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) /* Axis name */ copy_v3_fl(c, 0.1f); c[axis] = 1.0f; - for (int i = 0; i < axis_v_ct; ++i) { + for (int i = 0; i < axis_v_len; ++i) { set_bone_axis_vert(vbo, attr_id.axis, attr_id.pos, attr_id.col, &v, &a, axis_verts[i], c); } @@ -3125,8 +3125,8 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) const float f20 = 1.0f; const int segments = 16; - const int vert_ct = segments + 8; - const int index_ct = vert_ct + 5; + const int vert_len = segments + 8; + const int index_len = vert_len + 5; uchar red[3] = {255, 0, 0}; uchar white[3] = {255, 255, 255}; @@ -3139,10 +3139,10 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) } Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, GWN_PRIM_LINE_STRIP, index_ct, vert_ct, true); + GWN_indexbuf_init_ex(&elb, GWN_PRIM_LINE_STRIP, index_len, vert_len, true); Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_ct); + GWN_vertbuf_data_alloc(vbo, vert_len); int v = 0; for (int i = 0; i < segments; ++i) { diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 198518cd887..6c6e2d78206 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -1634,7 +1634,7 @@ typedef struct MeshBatchCache { * set srgb conversion for auto attribs.*/ char *auto_layer_names; int *auto_layer_is_srgb; - int auto_layer_ct; + int auto_layer_len; /* settings to determine if cache is invalid */ bool is_maybe_dirty; @@ -1947,22 +1947,22 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, uint auto_names_len = 0; uint auto_ofs = 0; uint auto_id = 0; - cache->auto_layer_ct = 0; + cache->auto_layer_len = 0; for (uint i = 0; i < uv_len; i++) { const char *attrib_name = mesh_render_data_uv_auto_layer_uuid_get(rdata, i); auto_names_len += strlen(attrib_name) + 2; /* include null terminator and b prefix. */ - cache->auto_layer_ct++; + cache->auto_layer_len++; } for (uint i = 0; i < vcol_len; i++) { if (rdata->cd.layers.auto_vcol[i]) { const char *attrib_name = mesh_render_data_vcol_auto_layer_uuid_get(rdata, i); auto_names_len += strlen(attrib_name) + 2; /* include null terminator and b prefix. */ - cache->auto_layer_ct++; + cache->auto_layer_len++; } } auto_names_len += 1; /* add an ultimate '\0' terminator */ cache->auto_layer_names = MEM_callocN(auto_names_len * sizeof(char), "Auto layer name buf"); - cache->auto_layer_is_srgb = MEM_mallocN(cache->auto_layer_ct * sizeof(int), "Auto layer value buf"); + cache->auto_layer_is_srgb = MEM_mallocN(cache->auto_layer_len * sizeof(int), "Auto layer value buf"); for (uint i = 0; i < uv_len; i++) { /* UV */ @@ -4330,7 +4330,7 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( if (auto_layer_names) { *auto_layer_names = cache->auto_layer_names; *auto_layer_is_srgb = cache->auto_layer_is_srgb; - *auto_layer_count = cache->auto_layer_ct; + *auto_layer_count = cache->auto_layer_len; } return cache->shaded_triangles; diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 3cf47fb5e25..60b367f7b1a 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -66,8 +66,8 @@ static void particle_batch_cache_clear(ParticleSystem *psys); typedef struct ParticlePointCache { Gwn_VertBuf *pos; Gwn_Batch *points; - int elems_count; - int point_count; + int elems_len; + int point_len; } ParticlePointCache; typedef struct ParticleBatchCache { @@ -82,11 +82,11 @@ typedef struct ParticleBatchCache { Gwn_VertBuf *edit_inner_pos; Gwn_Batch *edit_inner_points; - int edit_inner_point_count; + int edit_inner_point_len; Gwn_VertBuf *edit_tip_pos; Gwn_Batch *edit_tip_points; - int edit_tip_point_count; + int edit_tip_point_len; /* Settings to determine if cache is invalid. */ bool is_dirty; @@ -225,9 +225,9 @@ static void count_cache_segment_keys( for (int i = 0; i < num_path_cache_keys; i++) { ParticleCacheKey *path = pathcache[i]; if (path->segments > 0) { - hair_cache->strands_count++; - hair_cache->elems_count += path->segments + 2; - hair_cache->point_count += path->segments + 1; + hair_cache->strands_len++; + hair_cache->elems_len += path->segments + 2; + hair_cache->point_len += path->segments + 1; } } } @@ -243,9 +243,9 @@ static void ensure_seg_pt_count( return; } - hair_cache->strands_count = 0; - hair_cache->elems_count = 0; - hair_cache->point_count = 0; + hair_cache->strands_len = 0; + hair_cache->elems_len = 0; + hair_cache->point_len = 0; if (edit != NULL && edit->pathcache != NULL) { count_cache_segment_keys(edit->pathcache, edit->totcached, hair_cache); @@ -761,7 +761,7 @@ static void particle_batch_cache_ensure_procedural_final_points( /* Create a destination buffer for the tranform feedback. Sized appropriately */ /* Thoses are points! not line segments. */ - GWN_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_count); + GWN_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_len); /* Create vbo immediatly to bind to texture buffer. */ GWN_vertbuf_use(cache->final[subdiv].proc_buf); @@ -814,13 +814,13 @@ static void particle_batch_cache_ensure_procedural_strand_data( /* Strand Data */ cache->proc_strand_buf = GWN_vertbuf_create_with_format(&format_data); - GWN_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_count); + GWN_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len); GWN_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step); /* UV layers */ for (int i = 0; i < cache->num_uv_layers; i++) { cache->proc_uv_buf[i] = GWN_vertbuf_create_with_format(&format_uv); - GWN_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_count); + GWN_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); GWN_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); @@ -836,7 +836,7 @@ static void particle_batch_cache_ensure_procedural_strand_data( /* Vertex colors */ for (int i = 0; i < cache->num_col_layers; i++) { cache->proc_col_buf[i] = GWN_vertbuf_create_with_format(&format_col); - GWN_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_count); + GWN_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); GWN_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); @@ -942,7 +942,7 @@ static void particle_batch_cache_ensure_procedural_indices( int verts_per_hair = cache->final[subdiv].strands_res * thickness_res; /* +1 for primitive restart */ - int element_count = (verts_per_hair + 1) * cache->strands_count; + int element_count = (verts_per_hair + 1) * cache->strands_len; Gwn_PrimType prim_type = (thickness_res == 1) ? GWN_PRIM_LINE_STRIP : GWN_PRIM_TRI_STRIP; static Gwn_VertFormat format = { 0 }; @@ -997,7 +997,7 @@ static void particle_batch_cache_ensure_procedural_pos( uint pos_id = GWN_vertformat_attr_add(&format, "posTime", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); cache->proc_point_buf = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->proc_point_buf, cache->point_count); + GWN_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len); Gwn_VertBufRaw pos_step; GWN_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step); @@ -1109,13 +1109,13 @@ static void particle_batch_cache_ensure_pos_and_seg( } hair_cache->pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_count); + GWN_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); Gwn_IndexBufBuilder elb; GWN_indexbuf_init_ex( &elb, GWN_PRIM_LINE_STRIP, - hair_cache->elems_count, hair_cache->point_count, + hair_cache->elems_len, hair_cache->point_len, true); if (num_uv_layers || num_col_layers) { @@ -1392,11 +1392,11 @@ static void ensure_edit_inner_points_count( if (cache->edit_inner_pos != NULL) { return; } - cache->edit_inner_point_count = 0; + cache->edit_inner_point_len = 0; for (int point_index = 0; point_index < edit->totpoint; point_index++) { const PTCacheEditPoint *point = &edit->points[point_index]; BLI_assert(point->totkey >= 1); - cache->edit_inner_point_count += (point->totkey - 1); + cache->edit_inner_point_len += (point->totkey - 1); } } @@ -1431,7 +1431,7 @@ static void particle_batch_cache_ensure_edit_inner_pos( } cache->edit_inner_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_count); + GWN_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len); float selected_color[4], normal_color[4]; edit_colors_get(edit, selected_color, normal_color); @@ -1479,7 +1479,7 @@ static void ensure_edit_tip_points_count( if (cache->edit_tip_pos != NULL) { return; } - cache->edit_tip_point_count = edit->totpoint; + cache->edit_tip_point_len = edit->totpoint; } static void particle_batch_cache_ensure_edit_tip_pos( @@ -1502,7 +1502,7 @@ static void particle_batch_cache_ensure_edit_tip_pos( } cache->edit_tip_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_count); + GWN_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len); float selected_color[4], normal_color[4]; edit_colors_get(edit, selected_color, normal_color); diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 8320ae55179..6ede573199f 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -137,14 +137,14 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex( /* Transform Feedback subdiv. */ if (need_ft_update) { - int final_points_ct = hair_cache->final[subdiv].strands_res * hair_cache->strands_count; + int final_points_len = hair_cache->final[subdiv].strands_res * hair_cache->strands_len; GPUShader *tf_shader = hair_refine_shader_get(PART_REFINE_CATMULL_ROM); DRWShadingGroup *tf_shgrp = DRW_shgroup_transform_feedback_create(tf_shader, g_tf_pass, hair_cache->final[subdiv].proc_buf); DRW_shgroup_uniform_texture(tf_shgrp, "hairPointBuffer", hair_cache->point_tex); DRW_shgroup_uniform_texture(tf_shgrp, "hairStrandBuffer", hair_cache->strand_tex); DRW_shgroup_uniform_int(tf_shgrp, "hairStrandsRes", &hair_cache->final[subdiv].strands_res, 1); - DRW_shgroup_call_procedural_points_add(tf_shgrp, final_points_ct, NULL); + DRW_shgroup_call_procedural_points_add(tf_shgrp, final_points_len, NULL); } return shgrp; diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h index 28993614688..17acd7e6259 100644 --- a/source/blender/draw/intern/draw_hair_private.h +++ b/source/blender/draw/intern/draw_hair_private.h @@ -76,9 +76,9 @@ typedef struct ParticleHairCache { ParticleHairFinalCache final[MAX_HAIR_SUBDIV]; - int strands_count; - int elems_count; - int point_count; + int strands_len; + int elems_len; + int point_len; } ParticleHairCache; bool particles_ensure_procedural_data( diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index 3e4f812af27..e5b5ec31823 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -213,10 +213,10 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) for (int i = 0; i < batching->alloc_size; i++, bbuf++) { if (bbuf->shgroup != NULL) { realloc_size = i + 1; - uint vert_ct = DRW_shgroup_get_instance_count(bbuf->shgroup); - vert_ct += (vert_ct == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ - if (vert_ct + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_ct) { - uint size = vert_ct + BUFFER_VERTS_CHUNK - 1; + uint vert_len = DRW_shgroup_get_instance_count(bbuf->shgroup); + vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ + if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_ct) { + uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; GWN_vertbuf_data_resize(bbuf->vert, size); } @@ -245,10 +245,10 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) for (int i = 0; i < instancing->alloc_size; i++, ibuf++) { if (ibuf->shgroup != NULL) { realloc_size = i + 1; - uint vert_ct = DRW_shgroup_get_instance_count(ibuf->shgroup); - vert_ct += (vert_ct == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ - if (vert_ct + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_ct) { - uint size = vert_ct + BUFFER_VERTS_CHUNK - 1; + uint vert_len = DRW_shgroup_get_instance_count(ibuf->shgroup); + vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ + if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_ct) { + uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; GWN_vertbuf_data_resize(ibuf->vert, size); } diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index db4e16d362a..2e6079e1661 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -412,9 +412,9 @@ static void drw_shgroup_call_procedural_add_ex( BLI_LINKS_APPEND(&shgroup->calls, call); } -void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_count, float (*obmat)[4]) +void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS, point_count, obmat, NULL); + drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS, point_len, obmat, NULL); } void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]) diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 03692fd9475..5957643d090 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -419,10 +419,10 @@ void DRW_state_invert_facing(void) * and if the shaders have support for it (see usage of gl_ClipDistance). * Be sure to call DRW_state_clip_planes_reset() after you finish drawing. **/ -void DRW_state_clip_planes_count_set(uint plane_ct) +void DRW_state_clip_planes_count_set(uint plane_len) { - BLI_assert(plane_ct <= MAX_CLIP_PLANES); - DST.num_clip_planes = plane_ct; + BLI_assert(plane_len <= MAX_CLIP_PLANES); + DST.num_clip_planes = plane_len; } void DRW_state_clip_planes_reset(void) diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index cab796a62d3..59ae8a918f9 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -79,7 +79,7 @@ void DRW_draw_region_info(void) /* ************************* Grid ************************** */ -static void gridline_range(double x0, double dx, double max, int *r_first, int *r_count) +static void gridline_range(double x0, double dx, double max, int *r_first, int *r_len) { /* determine range of gridlines that appear in this Area -- similar calc but separate ranges for x & y * x0 is gridline 0, the axis in screen space @@ -90,11 +90,11 @@ static void gridline_range(double x0, double dx, double max, int *r_first, int * if (first <= last) { *r_first = first; - *r_count = last - first + 1; + *r_len = last - first + 1; } else { *r_first = 0; - *r_count = 0; + *r_len = 0; } } @@ -104,14 +104,14 @@ static int gridline_count(ARegion *ar, double x0, double y0, double dx) * dx is the frequency, shared by x & y directions * pass in dx of smallest (highest precision) grid we want to draw */ - int first, x_ct, y_ct; + int first, x_len, y_len; - gridline_range(x0, dx, ar->winx, &first, &x_ct); - gridline_range(y0, dx, ar->winy, &first, &y_ct); + gridline_range(x0, dx, ar->winx, &first, &x_len); + gridline_range(y0, dx, ar->winy, &first, &y_len); - int total_ct = x_ct + y_ct; + int total_len = x_len + y_len; - return total_ct; + return total_len; } static bool drawgrid_draw( @@ -129,7 +129,7 @@ static bool drawgrid_draw( const float y_max = (float)ar->winy; int first, ct; - int x_ct = 0, y_ct = 0; /* count of lines actually drawn */ + int x_len = 0, y_len = 0; /* count of lines actually drawn */ int lines_skipped_for_next_unit = 0; /* draw vertical lines */ @@ -143,13 +143,13 @@ static bool drawgrid_draw( continue; } - if (x_ct == 0) + if (x_len == 0) immAttrib3ub(col, col_value[0], col_value[1], col_value[2]); float x = (float)(x0 + i * dx); immVertex2f(pos, x, 0.0f); immVertex2f(pos, x, y_max); - ++x_ct; + ++x_len; } /* draw horizontal lines */ @@ -163,13 +163,13 @@ static bool drawgrid_draw( continue; } - if (x_ct + y_ct == 0) + if (x_len + y_len == 0) immAttrib3ub(col, col_value[0], col_value[1], col_value[2]); float y = (float)(y0 + i * dx); immVertex2f(pos, 0.0f, y); immVertex2f(pos, x_max, y); - ++y_ct; + ++y_len; } return lines_skipped_for_next_unit > 0; @@ -249,11 +249,11 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** *grid_unit = bUnit_GetNameDisplay(usys, i); rv3d->gridview = (float)((scalar * (double)v3d->grid) / (double)unit->scale_length); - int gridline_ct = gridline_count(ar, x, y, dx_scalar); - if (gridline_ct == 0) + int gridline_len = gridline_count(ar, x, y, dx_scalar); + if (gridline_len == 0) goto drawgrid_cleanup; /* nothing to draw */ - immBegin(GWN_PRIM_LINES, gridline_ct * 2); + immBegin(GWN_PRIM_LINES, gridline_len * 2); } float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar); @@ -302,11 +302,11 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } } - int gridline_ct = gridline_count(ar, x, y, dx); - if (gridline_ct == 0) + int gridline_len = gridline_count(ar, x, y, dx); + if (gridline_len == 0) goto drawgrid_cleanup; /* nothing to draw */ - immBegin(GWN_PRIM_LINES, gridline_ct * 2); + immBegin(GWN_PRIM_LINES, gridline_len * 2); if (grids_to_draw == 2) { UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2); @@ -376,7 +376,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) UI_GetThemeColor3ubv(TH_GRID, col_grid); if (show_floor) { - const uint vertex_ct = 2 * (gridlines * 4 + 2); + const uint vertex_len = 2 * (gridlines * 4 + 2); const int sublines = v3d->gridsubdiv; uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3]; @@ -387,7 +387,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_ct); + immBegin(GWN_PRIM_LINES, vertex_len); /* draw normal grid lines */ UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10); -- cgit v1.2.3 From 804205babe212972dd800c5a2f6d9ebfb64feefb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 13:05:41 +0200 Subject: Cleanup: rename 'ct' to 'len' for gawain --- source/blender/draw/intern/draw_cache.c | 100 ++++++++++----------- source/blender/draw/intern/draw_cache_impl_curve.c | 12 +-- .../blender/draw/intern/draw_cache_impl_displist.c | 4 +- .../blender/draw/intern/draw_cache_impl_lattice.c | 2 +- source/blender/draw/intern/draw_cache_impl_mesh.c | 36 ++++---- .../draw/intern/draw_cache_impl_particles.c | 6 +- source/blender/draw/intern/draw_instance_data.c | 4 +- source/blender/draw/intern/draw_manager_data.c | 12 +-- 8 files changed, 88 insertions(+), 88 deletions(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 5c3546f07a7..2251285be74 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -164,7 +164,7 @@ static Gwn_VertBuf *fill_arrows_vbo(const float scale) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -211,7 +211,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -263,7 +263,7 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, uvs; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -291,7 +291,7 @@ Gwn_Batch *DRW_cache_quad_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, uvs; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -344,7 +344,7 @@ Gwn_Batch *DRW_cache_cube_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -369,7 +369,7 @@ Gwn_Batch *DRW_cache_circle_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -400,7 +400,7 @@ Gwn_Batch *DRW_cache_square_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -427,7 +427,7 @@ Gwn_Batch *DRW_cache_single_line_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -452,7 +452,7 @@ Gwn_Batch *DRW_cache_single_line_endpoints_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -476,7 +476,7 @@ Gwn_Batch *DRW_cache_screenspace_circle_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -613,7 +613,7 @@ Gwn_Batch *DRW_cache_plain_axes_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -644,7 +644,7 @@ Gwn_Batch *DRW_cache_single_arrow_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -700,7 +700,7 @@ Gwn_Batch *DRW_cache_empty_cone_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -752,7 +752,7 @@ Gwn_Batch *DRW_cache_axis_names_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* Using 3rd component as axis indicator */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -810,7 +810,7 @@ Gwn_Batch *DRW_cache_image_plane_get(void) const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; static Gwn_VertFormat format = { 0 }; static struct { uint pos, texCoords; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.texCoords = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -831,7 +831,7 @@ Gwn_Batch *DRW_cache_image_plane_wire_get(void) const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); @@ -854,7 +854,7 @@ Gwn_Batch *DRW_cache_field_wind_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -891,7 +891,7 @@ Gwn_Batch *DRW_cache_field_force_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -929,7 +929,7 @@ Gwn_Batch *DRW_cache_field_vortex_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -966,7 +966,7 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1015,7 +1015,7 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1070,7 +1070,7 @@ Gwn_Batch *DRW_cache_lamp_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -1102,7 +1102,7 @@ Gwn_Batch *DRW_cache_lamp_shadows_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -1133,7 +1133,7 @@ Gwn_Batch *DRW_cache_lamp_sunrays_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -1168,7 +1168,7 @@ Gwn_Batch *DRW_cache_lamp_area_square_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1201,7 +1201,7 @@ Gwn_Batch *DRW_cache_lamp_area_disk_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1235,7 +1235,7 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1313,7 +1313,7 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, n1, n2; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -1372,7 +1372,7 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1410,7 +1410,7 @@ Gwn_Batch *DRW_cache_speaker_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1483,7 +1483,7 @@ Gwn_Batch *DRW_cache_lightprobe_cube_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1528,7 +1528,7 @@ Gwn_Batch *DRW_cache_lightprobe_grid_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1581,7 +1581,7 @@ Gwn_Batch *DRW_cache_lightprobe_planar_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1709,7 +1709,7 @@ Gwn_Batch *DRW_cache_bone_octahedral_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor, snor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -1875,7 +1875,7 @@ Gwn_Batch *DRW_cache_bone_box_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor, snor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -1942,7 +1942,7 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -1989,7 +1989,7 @@ Gwn_Batch *DRW_cache_bone_envelope_outline_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos0, pos1, pos2; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.pos2 = GWN_vertformat_attr_add(&format, "pos2", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -2045,7 +2045,7 @@ Gwn_Batch *DRW_cache_bone_point_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2081,7 +2081,7 @@ Gwn_Batch *DRW_cache_bone_point_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -2115,7 +2115,7 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos0, pos1; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -2172,7 +2172,7 @@ Gwn_Batch *DRW_cache_bone_stick_get(void) /* Position Only 2D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, flag; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.flag = GWN_vertformat_attr_add(&format, "flag", GWN_COMP_U32, 1, GWN_FETCH_INT); } @@ -2314,7 +2314,7 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint axis, pos, col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.axis = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); attr_id.pos = GWN_vertformat_attr_add(&format, "screenPos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.col = GWN_vertformat_attr_add(&format, "colorAxis", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -2456,7 +2456,7 @@ Gwn_Batch *DRW_cache_camera_get(void) if (!SHC.drw_camera) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); } @@ -2489,7 +2489,7 @@ Gwn_Batch *DRW_cache_camera_frame_get(void) static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); } @@ -2515,7 +2515,7 @@ Gwn_Batch *DRW_cache_camera_tria_get(void) if (!SHC.drw_camera_tria) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); } @@ -2552,7 +2552,7 @@ Gwn_Batch *DRW_cache_single_vert_get(void) /* Position Only 3D format */ static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2987,7 +2987,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) static Gwn_VertFormat format = { 0 }; static uint pos_id, axis_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -3034,7 +3034,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) static Gwn_VertFormat format = { 0 }; static uint pos_id, axis_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -3085,7 +3085,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) static Gwn_VertFormat format = { 0 }; static uint pos_id, axis_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -3133,7 +3133,7 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) static Gwn_VertFormat format = { 0 }; static struct { uint pos, color; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); attr_id.color = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); } diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 1bf34953dc6..4de1dfd24f5 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -503,7 +503,7 @@ static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, Cur if (cache->wire.verts == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -581,7 +581,7 @@ static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, C if (cache->normal.verts == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -675,7 +675,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) if (cache->overlay.verts == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); @@ -743,7 +743,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); @@ -850,7 +850,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, C EditFont *ef = rdata->text.edit_font; static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -924,7 +924,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, C if (cache->text.cursor == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index 3eecff024a1..8d187af0501 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -122,7 +122,7 @@ Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); @@ -228,7 +228,7 @@ Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(Lis static Gwn_VertFormat shaded_triangles_format = { 0 }; static struct { uint pos, nor, uv; } attr_id; - if (shaded_triangles_format.attrib_ct == 0) { + if (shaded_triangles_format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&shaded_triangles_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&shaded_triangles_format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 6046d9854fb..99dce2d7343 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -507,7 +507,7 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt) if (cache->overlay_verts == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 6c6e2d78206..7a72622cb9e 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -2159,7 +2159,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( static Gwn_VertFormat format = { 0 }; static struct { uint uv; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.uv = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); } @@ -2222,7 +2222,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( if (*r_vbo == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); } @@ -2374,7 +2374,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( if (cache->ed_fcenter_pos_with_nor_and_sel == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.data = GWN_vertformat_attr_add(&format, "norAndFlag", GWN_COMP_I10, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); } @@ -2418,7 +2418,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( if (cache->ed_edge_pos == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2463,7 +2463,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( if (cache->ed_vert_pos == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2513,7 +2513,7 @@ static Gwn_VertBuf *mesh_create_facedot_select_id( { static Gwn_VertFormat format = { 0 }; static struct { uint pos, col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -2561,7 +2561,7 @@ static Gwn_VertBuf *mesh_create_edges_select_id( { static Gwn_VertFormat format = { 0 }; static struct { uint pos, col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -2611,7 +2611,7 @@ static Gwn_VertBuf *mesh_create_verts_select_id( { static Gwn_VertFormat format = { 0 }; static struct { uint pos, col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -2671,7 +2671,7 @@ static Gwn_VertBuf *mesh_create_tri_weights( static Gwn_VertFormat format = { 0 }; static struct { uint col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } @@ -2731,7 +2731,7 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors( static Gwn_VertFormat format = { 0 }; static struct { uint col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); } @@ -2791,7 +2791,7 @@ static Gwn_VertBuf *mesh_create_tri_select_id( static Gwn_VertFormat format = { 0 }; static struct { uint col; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); } @@ -2847,7 +2847,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( if (cache->pos_in_order == NULL) { static Gwn_VertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* Normal is padded so that the vbo can be used as a buffer texture */ attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); @@ -2887,7 +2887,7 @@ static Gwn_VertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id) { static Gwn_VertFormat format_pos = { 0 }; static uint pos_id; - if (format_pos.attrib_ct == 0) { + if (format_pos.attr_len == 0) { pos_id = GWN_vertformat_attr_add(&format_pos, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); } *r_pos_id = pos_id; @@ -2899,7 +2899,7 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno static Gwn_VertFormat format_nor = { 0 }; static Gwn_VertFormat format_nor_loop = { 0 }; static uint vnor_id, vnor_loop_id, lnor_id; - if (format_nor.attrib_ct == 0) { + if (format_nor.attr_len == 0) { vnor_id = GWN_vertformat_attr_add(&format_nor, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); vnor_loop_id = GWN_vertformat_attr_add(&format_nor_loop, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); lnor_id = GWN_vertformat_attr_add(&format_nor_loop, "lnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); @@ -2919,7 +2919,7 @@ static Gwn_VertFormat *edit_mesh_overlay_data_format(uint *r_data_id) { static Gwn_VertFormat format_flag = { 0 }; static uint data_id; - if (format_flag.attrib_ct == 0) { + if (format_flag.attr_len == 0) { data_id = GWN_vertformat_attr_add(&format_flag, "data", GWN_COMP_U8, 4, GWN_FETCH_INT); } *r_data_id = data_id; @@ -3657,7 +3657,7 @@ static Gwn_VertBuf *mesh_create_edge_pos_with_sel( static Gwn_VertFormat format = { 0 }; static struct { uint pos, sel; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.sel = GWN_vertformat_attr_add(&format, "select", GWN_COMP_U8, 1, GWN_FETCH_INT); } @@ -3744,7 +3744,7 @@ static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data( static Gwn_VertFormat format = { 0 }; static struct { uint data; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_I8, 1, GWN_FETCH_INT); } @@ -3997,7 +3997,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) /* create batch from DM */ static Gwn_VertFormat format = { 0 }; static struct { uint pos, n1, n2; } attr_id; - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 60b367f7b1a..df67d34d566 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -1219,7 +1219,7 @@ static void particle_batch_cache_ensure_pos( GWN_VERTBUF_DISCARD_SAFE(point_cache->pos); - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); rot_id = GWN_vertformat_attr_add(&format, "rot", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); @@ -1424,7 +1424,7 @@ static void particle_batch_cache_ensure_edit_inner_pos( GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); @@ -1495,7 +1495,7 @@ static void particle_batch_cache_ensure_edit_tip_pos( GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); - if (format.attrib_ct == 0) { + if (format.attr_len == 0) { /* initialize vertex format */ pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index e5b5ec31823..e322d4780d5 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -215,7 +215,7 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) realloc_size = i + 1; uint vert_len = DRW_shgroup_get_instance_count(bbuf->shgroup); vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ - if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_ct) { + if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_len) { uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; GWN_vertbuf_data_resize(bbuf->vert, size); @@ -247,7 +247,7 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) realloc_size = i + 1; uint vert_len = DRW_shgroup_get_instance_count(ibuf->shgroup); vert_len += (vert_len == 0) ? 1 : 0; /* Do not realloc to 0 size buffer */ - if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_ct) { + if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_len) { uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; GWN_vertbuf_data_resize(ibuf->vert, size); diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 2e6079e1661..c259633982e 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -553,7 +553,7 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at { #ifdef USE_GPU_SELECT if (G.f & G_PICKSEL) { - if (shgroup->instance_count == shgroup->inst_selectid->vertex_ct) { + if (shgroup->instance_count == shgroup->inst_selectid->vertex_len) { GWN_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32); } GWN_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id); @@ -564,7 +564,7 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at UNUSED_VARS_NDEBUG(attr_len); for (int i = 0; i < attr_len; ++i) { - if (shgroup->instance_count == shgroup->instance_vbo->vertex_ct) { + if (shgroup->instance_count == shgroup->instance_vbo->vertex_len) { GWN_vertbuf_data_resize(shgroup->instance_vbo, shgroup->instance_count + 32); } GWN_vertbuf_attr_set(shgroup->instance_vbo, i, shgroup->instance_count, attr[i]); @@ -651,7 +651,7 @@ static void drw_shgroup_instance_init( shgroup->instance_geom = batch; #ifndef NDEBUG - shgroup->attribs_count = format->attrib_ct; + shgroup->attribs_count = format->attr_len; #endif DRW_instancing_buffer_request(DST.idatalist, format, batch, shgroup, @@ -662,7 +662,7 @@ static void drw_shgroup_instance_init( /* Not actually used for rendering but alloced in one chunk. * Plus we don't have to care about ownership. */ static Gwn_VertFormat inst_select_format = {0}; - if (inst_select_format.attrib_ct == 0) { + if (inst_select_format.attr_len == 0) { GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT); } Gwn_Batch *batch_dummy; /* Not used */ @@ -679,7 +679,7 @@ static void drw_shgroup_batching_init( drw_shgroup_init(shgroup, shader); #ifndef NDEBUG - shgroup->attribs_count = (format != NULL) ? format->attrib_ct : 0; + shgroup->attribs_count = (format != NULL) ? format->attr_len : 0; #endif BLI_assert(format != NULL); @@ -698,7 +698,7 @@ static void drw_shgroup_batching_init( if (G.f & G_PICKSEL) { /* Not actually used for rendering but alloced in one chunk. */ static Gwn_VertFormat inst_select_format = {0}; - if (inst_select_format.attrib_ct == 0) { + if (inst_select_format.attr_len == 0) { GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT); } Gwn_Batch *batch; /* Not used */ -- cgit v1.2.3 From 907dd3d34a2f876622da1b4561df939a7d5836e9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 8 Jul 2018 21:15:39 +0200 Subject: Fix crash in lamp preview render Missing NULL check in object type filtering. --- source/blender/draw/intern/draw_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 7e40966f9c8..a1e44e479d4 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1564,7 +1564,7 @@ void DRW_render_object_iter( DRW_hair_init(); - const int object_type_exclude_viewport = draw_ctx->v3d->object_type_exclude_viewport; + const int object_type_exclude_viewport = draw_ctx->v3d ? draw_ctx->v3d->object_type_exclude_viewport : 0; DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob) { if ((object_type_exclude_viewport & (1 << ob->type)) == 0) { -- cgit v1.2.3