Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-05-30 00:52:37 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-30 14:43:33 +0300
commit596492e639f07b6a0a3f705a0f944dc57f94b7e4 (patch)
tree55f3dfa9ee3ad03c90954bec26f7c85157dc2d1b /source/blender/draw/modes/object_mode.c
parent32a2bfddcb4b0dedbea987ae3e335dc6aecdaed8 (diff)
DRW: Refactor to use object pointer for drawcall by default
This cleans up a bit of duplicated code and some confusion about what was culled and what wasn't. Now everything is culled based on the given object pointer. If the object pointer is NULL there is no culling performed.
Diffstat (limited to 'source/blender/draw/modes/object_mode.c')
-rw-r--r--source/blender/draw/modes/object_mode.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index ed757424444..9f5268500e8 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -1019,7 +1019,7 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
- DRW_shgroup_call(grp, DRW_cache_image_plane_wire_get(), ob->obmat);
+ DRW_shgroup_call_no_cull(grp, DRW_cache_image_plane_wire_get(), ob);
}
if (!BKE_object_empty_image_data_is_visible_in_view3d(ob, rv3d)) {
@@ -1039,7 +1039,7 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
- DRW_shgroup_call(grp, DRW_cache_image_plane_get(), ob->obmat);
+ DRW_shgroup_call_no_cull(grp, DRW_cache_image_plane_get(), ob);
}
}
@@ -1186,8 +1186,6 @@ static void OBJECT_cache_init(void *vedata)
struct GPUBatch *geom = DRW_cache_grid_get();
float grid_line_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f;
- static float mat[4][4];
- unit_m4(mat);
/* Create 3 quads to render ordered transparency Z axis */
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->grid, psl->grid);
@@ -1199,21 +1197,21 @@ static void OBJECT_cache_init(void *vedata)
DRW_shgroup_uniform_float(grp, "gridOneOverLogSubdiv", &e_data.grid_settings[4], 1);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
- DRW_shgroup_call(grp, geom, mat);
+ DRW_shgroup_call(grp, geom, NULL);
grp = DRW_shgroup_create(sh_data->grid, psl->grid);
DRW_shgroup_uniform_int(grp, "gridFlag", &e_data.grid_flag, 1);
DRW_shgroup_uniform_vec3(grp, "planeAxes", e_data.grid_axes, 1);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
- DRW_shgroup_call(grp, geom, mat);
+ DRW_shgroup_call(grp, geom, NULL);
grp = DRW_shgroup_create(sh_data->grid, psl->grid);
DRW_shgroup_uniform_int(grp, "gridFlag", &e_data.zpos_flag, 1);
DRW_shgroup_uniform_vec3(grp, "planeAxes", e_data.zplane_axes, 1);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
- DRW_shgroup_call(grp, geom, mat);
+ DRW_shgroup_call(grp, geom, NULL);
}
for (int i = 0; i < 2; ++i) {
@@ -2071,7 +2069,7 @@ static void camera_view3d_reconstruction(OBJECT_ShadingGroupList *sgl,
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
DRWShadingGroup *shading_group = DRW_shgroup_create(shader, sgl->non_meshes);
DRW_shgroup_uniform_vec4(shading_group, "color", camera_path_color, 1);
- DRW_shgroup_call(shading_group, geom, camera_mat);
+ DRW_shgroup_call_obmat(shading_group, geom, camera_mat);
}
}
}
@@ -2459,7 +2457,7 @@ static void DRW_shgroup_volume_extra(OBJECT_ShadingGroupList *sgl,
DRW_shgroup_uniform_float_copy(grp, "displaySize", sds->vector_scale);
DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth);
DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis);
- DRW_shgroup_call_procedural_lines(grp, line_count, ob->obmat);
+ DRW_shgroup_call_procedural_lines(grp, ob, line_count);
BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(smd));
}
@@ -2561,7 +2559,7 @@ static void DRW_shgroup_lightprobe(OBJECT_Shaders *sh_data,
DRW_shgroup_uniform_vec3(grp, "increment_y", prb_data->increment_y, 1);
DRW_shgroup_uniform_vec3(grp, "increment_z", prb_data->increment_z, 1);
DRW_shgroup_uniform_ivec3(grp, "grid_resolution", &prb->grid_resolution_x, 1);
- DRW_shgroup_call_procedural_points(grp, cell_count, NULL);
+ DRW_shgroup_call_procedural_points(grp, NULL, cell_count);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
@@ -2990,9 +2988,6 @@ static void OBJECT_cache_populate_particles(OBJECT_Shaders *sh_data,
ParticleSettings *part = psys->part;
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
- static float mat[4][4];
- unit_m4(mat);
-
if (draw_as != PART_DRAW_PATH) {
struct GPUBatch *geom = DRW_cache_particles_get_dots(ob, psys);
DRWShadingGroup *shgrp = NULL;
@@ -3010,7 +3005,7 @@ static void OBJECT_cache_populate_particles(OBJECT_Shaders *sh_data,
DRW_shgroup_uniform_float(shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
DRW_shgroup_uniform_float(shgrp, "size", &part->draw_size, 1);
DRW_shgroup_uniform_texture(shgrp, "ramp", G_draw.ramp);
- DRW_shgroup_call(shgrp, geom, mat);
+ DRW_shgroup_call(shgrp, geom, NULL);
break;
case PART_DRAW_CROSS:
shgrp = DRW_shgroup_create(sh_data->part_prim, psl->particle);
@@ -3019,7 +3014,7 @@ static void OBJECT_cache_populate_particles(OBJECT_Shaders *sh_data,
DRW_shgroup_uniform_float(shgrp, "draw_size", &part->draw_size, 1);
DRW_shgroup_uniform_bool_copy(shgrp, "screen_space", false);
shape = DRW_cache_particles_get_prim(PART_DRAW_CROSS);
- DRW_shgroup_call_instances_with_attribs(shgrp, shape, NULL, geom);
+ DRW_shgroup_call_instances_with_attribs(shgrp, NULL, shape, geom);
break;
case PART_DRAW_CIRC:
shape = DRW_cache_particles_get_prim(PART_DRAW_CIRC);
@@ -3028,14 +3023,14 @@ static void OBJECT_cache_populate_particles(OBJECT_Shaders *sh_data,
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
DRW_shgroup_uniform_float(shgrp, "draw_size", &part->draw_size, 1);
DRW_shgroup_uniform_bool_copy(shgrp, "screen_space", true);
- DRW_shgroup_call_instances_with_attribs(shgrp, shape, NULL, geom);
+ DRW_shgroup_call_instances_with_attribs(shgrp, NULL, shape, geom);
break;
case PART_DRAW_AXIS:
shape = DRW_cache_particles_get_prim(PART_DRAW_AXIS);
shgrp = DRW_shgroup_create(sh_data->part_axis, psl->particle);
DRW_shgroup_uniform_float(shgrp, "draw_size", &part->draw_size, 1);
DRW_shgroup_uniform_bool_copy(shgrp, "screen_space", false);
- DRW_shgroup_call_instances_with_attribs(shgrp, shape, NULL, geom);
+ DRW_shgroup_call_instances_with_attribs(shgrp, NULL, shape, geom);
break;
default:
break;
@@ -3191,7 +3186,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
}
if (shgroup && geom) {
- DRW_shgroup_call_object(shgroup, geom, ob);
+ DRW_shgroup_call(shgroup, geom, ob);
}
if (init_duplidata) {
@@ -3203,7 +3198,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
if (dupli_data && !init_duplidata) {
if (dupli_data->extra_shgrp && dupli_data->extra_geom) {
- DRW_shgroup_call_object(dupli_data->extra_shgrp, dupli_data->extra_geom, ob);
+ DRW_shgroup_call(dupli_data->extra_shgrp, dupli_data->extra_geom, ob);
}
}
else {
@@ -3222,7 +3217,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
shgroup = shgroup_theme_id_to_point(sgl, theme_id, ob->base_flag);
- DRW_shgroup_call_object(shgroup, geom, ob);
+ DRW_shgroup_call(shgroup, geom, ob);
}
}
else {
@@ -3240,7 +3235,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
- DRW_shgroup_call_object(shgroup, geom, ob);
+ DRW_shgroup_call(shgroup, geom, ob);
}
}
}
@@ -3258,7 +3253,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
- DRW_shgroup_call_object(shgroup, geom, ob);
+ DRW_shgroup_call(shgroup, geom, ob);
break;
}
case OB_LATTICE: {
@@ -3272,7 +3267,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
}
shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
- DRW_shgroup_call_object(shgroup, geom, ob);
+ DRW_shgroup_call(shgroup, geom, ob);
}
break;
}
@@ -3286,7 +3281,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
- DRW_shgroup_call_object(shgroup, geom, ob);
+ DRW_shgroup_call(shgroup, geom, ob);
}
break;
}
@@ -3364,7 +3359,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
}
shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
- DRW_shgroup_call_object(shgroup, geom, ob);
+ DRW_shgroup_call(shgroup, geom, ob);
}
}
break;