diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2016-07-15 13:51:07 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2016-07-15 13:51:07 +0300 |
commit | 58f732231ff1e3766fff058b5376d853e4aea2fa (patch) | |
tree | 2425c0d90ea93e712c7794842d04808f8ec3e4ae /source/blender/editors/space_view3d | |
parent | 66f8e8734b6066dbe38c25d181de66675de5256a (diff) |
Deduplication of strand drawing functions.
The two variants for object and edit mode are the same, except for
setting the edit data in the parameters.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawstrands.c | 86 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 2 |
3 files changed, 3 insertions, 87 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 3a98c0389f1..ffbb8bcf640 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -7979,7 +7979,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if (ob->mode & OB_MODE_HAIR_EDIT && is_obact) { if (!(dflag & DRAW_PICKING) && scene->obedit == NULL) { - draw_strands_edit(scene, v3d, rv3d, ob, smd); + draw_strands(scene, v3d, rv3d, ob, smd); } } else { diff --git a/source/blender/editors/space_view3d/drawstrands.c b/source/blender/editors/space_view3d/drawstrands.c index 3ebe5dd60e9..cf547769fbb 100644 --- a/source/blender/editors/space_view3d/drawstrands.c +++ b/source/blender/editors/space_view3d/drawstrands.c @@ -116,6 +116,7 @@ void draw_strands(Scene *scene, View3D *UNUSED(v3d), RegionView3D *rv3d, Object *ob, StrandsModifierData *smd) { Strands *strands = smd->strands; + BMEditStrands *edit = smd->edit; bool show_controls = smd->flag & MOD_STRANDS_SHOW_STRANDS; bool show_strands = smd->flag & MOD_STRANDS_SHOW_FIBERS; bool use_geomshader = smd->flag & MOD_STRANDS_USE_GEOMSHADER; @@ -125,6 +126,7 @@ void draw_strands(Scene *scene, View3D *UNUSED(v3d), RegionView3D *rv3d, GPUDrawStrandsParams params = {0}; params.strands = smd->strands; + params.edit = edit; params.root_dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); params.subdiv = smd->subdiv; params.fiber_primitive = get_fiber_primitive(smd->fiber_primitive); @@ -192,87 +194,3 @@ void draw_strands(Scene *scene, View3D *UNUSED(v3d), RegionView3D *rv3d, GPU_strand_shader_unbind(shader); } } - -/*************************/ -/*** Edit Mode Drawing ***/ - -void draw_strands_edit(Scene *scene, View3D *UNUSED(v3d), RegionView3D *rv3d, - Object *ob, StrandsModifierData *smd) -{ - BMEditStrands *edit = smd->edit; - bool show_controls = smd->flag & MOD_STRANDS_SHOW_STRANDS; - bool show_strands = smd->flag & MOD_STRANDS_SHOW_FIBERS; - bool use_geomshader = smd->flag & MOD_STRANDS_USE_GEOMSHADER; - - if (smd->strands == NULL || edit == NULL) - return; - - GPUDrawStrandsParams params = {0}; - params.strands = smd->strands; - params.edit = edit; - params.root_dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - params.subdiv = smd->subdiv; - params.fiber_primitive = get_fiber_primitive(smd->fiber_primitive); - params.effects = get_effects(smd->effects); - params.use_geomshader = use_geomshader; - params.shader_model = get_shader_model(smd->shader_model); - - if (smd->gpu_buffer == NULL) - smd->gpu_buffer = GPU_strands_buffer_create(¶ms); - GPUDrawStrands *buffer = smd->gpu_buffer; - GPUStrandsShader *shader = GPU_strand_shader_get(¶ms); - - if (show_controls) { - GPU_strands_setup_edges(buffer, ¶ms); - if (buffer->strand_points && buffer->strand_edges) { - GPU_buffer_draw_elements(buffer->strand_edges, GL_LINES, 0, buffer->strand_totedges * 2); - } - GPU_buffers_unbind(); - } - - if (show_strands) { - bind_strands_shader(shader, rv3d, ob, smd); - - GPU_strands_setup_fibers(buffer, ¶ms); - if (use_geomshader) { - if (buffer->fibers) { - struct GPUAttrib *attrib; - int num_attrib; - GPU_strand_shader_get_fiber_attributes(shader, &attrib, &num_attrib); - - int elemsize = GPU_attrib_element_size(attrib, num_attrib); - GPU_interleaved_attrib_setup(buffer->fibers, attrib, num_attrib, elemsize, false); - - glDrawArrays(GL_POINTS, 0, buffer->totfibers * elemsize); - - GPU_interleaved_attrib_unbind(); - } - } - else { - if (buffer->fiber_points && buffer->fiber_indices) { - struct GPUAttrib *attrib; - int num_attrib; - GPU_strand_shader_get_fiber_attributes(shader, &attrib, &num_attrib); - - int elemsize = GPU_attrib_element_size(attrib, num_attrib); - GPU_interleaved_attrib_setup(buffer->fiber_points, attrib, num_attrib, elemsize, false); - - switch (params.fiber_primitive) { - case GPU_STRANDS_FIBER_LINE: - GPU_buffer_draw_elements(buffer->fiber_indices, GL_LINES, 0, - buffer->fiber_totelems); - break; - case GPU_STRANDS_FIBER_RIBBON: - GPU_buffer_draw_elements(buffer->fiber_indices, GL_TRIANGLE_STRIP, 0, - buffer->fiber_totelems); - break; - } - - GPU_interleaved_attrib_unbind(); - } - } - GPU_strands_buffer_unbind(); - - GPU_strand_shader_unbind(shader); - } -} diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index ced1b9b6cb4..2cd2d723857 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -289,8 +289,6 @@ extern const char *view3d_context_dir[]; /* doc access */ /* drawstrands.c */ void draw_strands(struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d, struct Object *ob, struct StrandsModifierData *smd); -void draw_strands_edit(struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d, - struct Object *ob, struct StrandsModifierData *smd); /* drawvolume.c */ void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob, |