diff options
author | Luca Rood <dev@lucarood.com> | 2017-05-23 13:32:15 +0300 |
---|---|---|
committer | Luca Rood <dev@lucarood.com> | 2017-05-23 14:52:50 +0300 |
commit | 21857cb08121d1dcf6b5751b00f88ab2ee0be6e1 (patch) | |
tree | 986b432191e0ef308692256f06f4919e94928576 /source/blender | |
parent | b30cefa6505b131a93eb744be874466345b1d0ff (diff) |
Create new shading group for each psys
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 65 |
1 files changed, 24 insertions, 41 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 21f5ad97b3d..9d6810ab966 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -186,12 +186,6 @@ typedef struct OBJECT_PrivateData{ DRWShadingGroup *wire_select; DRWShadingGroup *wire_select_group; DRWShadingGroup *wire_transform; - - /* Particles */ - DRWShadingGroup *part_dot_shgrp; - DRWShadingGroup *part_cross_shgrp; - DRWShadingGroup *part_circle_shgrp; - DRWShadingGroup *part_axis_shgrp; } OBJECT_PrivateData; /* Transient data */ static struct { @@ -990,28 +984,6 @@ static void OBJECT_cache_init(void *vedata) { /* Particle Pass */ psl->particle = DRW_pass_create("Particle Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_POINT | DRW_STATE_BLEND); - - static int screen_space[2] = {0, 1}; - - stl->g_data->part_dot_shgrp = DRW_shgroup_create(e_data.part_dot_sh, psl->particle); - - stl->g_data->part_cross_shgrp = DRW_shgroup_instance_create(e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CROSS)); - DRW_shgroup_uniform_int(stl->g_data->part_cross_shgrp, "screen_space", &screen_space[0], 1); - DRW_shgroup_uniform_float(stl->g_data->part_cross_shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1); - DRW_shgroup_attrib_float(stl->g_data->part_cross_shgrp, "pos", 3); - DRW_shgroup_attrib_float(stl->g_data->part_cross_shgrp, "rot", 4); - - stl->g_data->part_circle_shgrp = DRW_shgroup_instance_create(e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CIRC)); - DRW_shgroup_uniform_int(stl->g_data->part_circle_shgrp, "screen_space", &screen_space[1], 1); - DRW_shgroup_uniform_float(stl->g_data->part_circle_shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1); - DRW_shgroup_attrib_float(stl->g_data->part_circle_shgrp, "pos", 3); - DRW_shgroup_attrib_float(stl->g_data->part_circle_shgrp, "rot", 4); - - stl->g_data->part_axis_shgrp = DRW_shgroup_instance_create(e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_AXIS)); - DRW_shgroup_uniform_int(stl->g_data->part_axis_shgrp, "screen_space", &screen_space[0], 1); - DRW_shgroup_uniform_float(stl->g_data->part_axis_shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1); - DRW_shgroup_attrib_float(stl->g_data->part_axis_shgrp, "pos", 3); - DRW_shgroup_attrib_float(stl->g_data->part_axis_shgrp, "rot", 4); } } @@ -1430,6 +1402,8 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) static float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; static float o_col[4] = {0.5f, 0.5f, 0.5f, 1.0f}; struct Batch *geom = DRW_cache_particles_get_dots(psys); + DRWShadingGroup *shgrp; + static int screen_space[2] = {0, 1}; Material *ma = give_current_material(ob, part->omat); @@ -1443,29 +1417,38 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) switch (draw_as) { case PART_DRAW_DOT: - DRW_shgroup_uniform_vec4(stl->g_data->part_dot_shgrp, "color", col, 1); - DRW_shgroup_uniform_vec4(stl->g_data->part_dot_shgrp, "outlineColor", o_col, 1); - DRW_shgroup_uniform_float(stl->g_data->part_dot_shgrp, "size", &size, 1); - DRW_shgroup_call_add(stl->g_data->part_dot_shgrp, geom, mat); + shgrp = DRW_shgroup_create(e_data.part_dot_sh, psl->particle); + DRW_shgroup_uniform_vec4(shgrp, "color", col, 1); + DRW_shgroup_uniform_vec4(shgrp, "outlineColor", o_col, 1); + DRW_shgroup_uniform_float(shgrp, "size", &size, 1); + DRW_shgroup_call_add(shgrp, geom, mat); break; case PART_DRAW_CROSS: - DRW_shgroup_uniform_vec4(stl->g_data->part_cross_shgrp, "color", col, 1); - DRW_shgroup_uniform_float(stl->g_data->part_cross_shgrp, "draw_size", &size, 1); - DRW_shgroup_instance_batch(stl->g_data->part_cross_shgrp, geom); + shgrp = DRW_shgroup_instance_create(e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CROSS)); + DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1); + DRW_shgroup_uniform_float(shgrp, "draw_size", &size, 1); break; case PART_DRAW_CIRC: - DRW_shgroup_uniform_vec4(stl->g_data->part_circle_shgrp, "color", col, 1); - DRW_shgroup_uniform_float(stl->g_data->part_circle_shgrp, "draw_size", &size, 1); - DRW_shgroup_instance_batch(stl->g_data->part_circle_shgrp, geom); + shgrp = DRW_shgroup_instance_create(e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CIRC)); + DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[1], 1); + DRW_shgroup_uniform_float(shgrp, "draw_size", &size, 1); break; case PART_DRAW_AXIS: - DRW_shgroup_uniform_vec4(stl->g_data->part_axis_shgrp, "color", col, 1); - DRW_shgroup_uniform_float(stl->g_data->part_axis_shgrp, "draw_size", &axis_size, 1); - DRW_shgroup_instance_batch(stl->g_data->part_axis_shgrp, geom); + shgrp = DRW_shgroup_instance_create(e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_AXIS)); + DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1); + DRW_shgroup_uniform_float(shgrp, "draw_size", &axis_size, 1); break; default: break; } + + if (draw_as != PART_DRAW_DOT) { + DRW_shgroup_attrib_float(shgrp, "pos", 3); + DRW_shgroup_attrib_float(shgrp, "rot", 4); + DRW_shgroup_uniform_vec4(shgrp, "color", col, 1); + DRW_shgroup_uniform_float(shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1); + DRW_shgroup_instance_batch(shgrp, geom); + } } } } |