[Bf-blender-cvs] [c2491f0] strand_gpu: Use the show_control_strands toggle for switching control hair display on/off.
Lukas Tönne
noreply at git.blender.org
Tue Jul 5 09:57:02 CEST 2016
Commit: c2491f0d8fe076d77e65c1ffbfc3249ad5276ae9
Author: Lukas Tönne
Date: Fri Jul 1 08:58:56 2016 +0200
Branches: strand_gpu
https://developer.blender.org/rBc2491f0d8fe076d77e65c1ffbfc3249ad5276ae9
Use the show_control_strands toggle for switching control hair display on/off.
Also use the basic edge shader for control hairs, the generated GLSL shader is
only needed for drawing render strands.
===================================================================
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/space_view3d/drawstrands.c
M source/blender/editors/space_view3d/view3d_intern.h
M source/blender/gpu/GPU_buffers.h
M source/blender/gpu/intern/gpu_buffers.c
===================================================================
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index b67eff3..e19030d 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -7972,7 +7972,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
StrandsModifierData *smd = (StrandsModifierData *)md;
if (smd->strands && smd->strands->data_final) {
- draw_strands(smd->strands, smd->strands->data_final, ob, rv3d);
+ draw_strands(smd->strands, smd->strands->data_final, ob, rv3d,
+ smd->flag & MOD_STRANDS_SHOW_CONTROL_STRANDS);
}
}
}
diff --git a/source/blender/editors/space_view3d/drawstrands.c b/source/blender/editors/space_view3d/drawstrands.c
index c7b2276..49f6285 100644
--- a/source/blender/editors/space_view3d/drawstrands.c
+++ b/source/blender/editors/space_view3d/drawstrands.c
@@ -52,20 +52,22 @@
#include "view3d_intern.h" // own include
-void draw_strands(Strands *strands, StrandData *data, Object *ob, RegionView3D *rv3d)
+void draw_strands(Strands *strands, StrandData *data, Object *ob, RegionView3D *rv3d,
+ bool show_controls)
{
GPUStrandsShader *gpu_shader = GPU_strand_shader_get(strands);
- GPUDrawStrands *gds;
- GPU_strand_shader_bind_uniforms(gpu_shader, ob->obmat, rv3d->viewmat);
- GPU_strand_shader_bind(gpu_shader, rv3d->viewmat, rv3d->viewinv);
-
- GPU_strands_setup(data);
- gds = data->gpu_buffer;
- if (gds->points && gds->edges) {
- GPU_buffer_draw_elements(gds->edges, GL_LINES, 0, (gds->totverts - gds->totcurves) * 2);
+ if (show_controls) {
+ GPU_strands_setup_control_edges(data);
+ GPUDrawStrands *gds = data->gpu_buffer;
+ if (gds->points && gds->edges) {
+ GPU_buffer_draw_elements(gds->edges, GL_LINES, 0, (gds->totverts - gds->totcurves) * 2);
+ }
+ GPU_buffers_unbind();
}
- GPU_buffers_unbind();
- GPU_strand_shader_unbind(gpu_shader);
+// GPU_strand_shader_bind_uniforms(gpu_shader, ob->obmat, rv3d->viewmat);
+// GPU_strand_shader_bind(gpu_shader, rv3d->viewmat, rv3d->viewinv);
+
+// GPU_strand_shader_unbind(gpu_shader);
}
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 45e9113..1c3b03e 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -288,7 +288,8 @@ ARegion *view3d_has_tools_region(ScrArea *sa);
extern const char *view3d_context_dir[]; /* doc access */
/* drawstrands.c */
-void draw_strands(struct Strands *strands, struct StrandData *data, struct Object *ob, struct RegionView3D *rv3d);
+void draw_strands(struct Strands *strands, struct StrandData *data, struct Object *ob, struct RegionView3D *rv3d,
+ bool show_controls);
/* drawvolume.c */
void draw_smoke_volume(struct SmokeDomainSettings *sds, struct Object *ob,
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index d936570..faccc5e 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -285,7 +285,8 @@ void GPU_free_pbvh_buffer_multires(struct GridCommonGPUBuffer **grid_common_gpu_
/* strands */
-void GPU_strands_setup(struct StrandData *strands);
+void GPU_strands_setup_control_verts(struct StrandData *strands);
+void GPU_strands_setup_control_edges(struct StrandData *strands);
void GPU_strands_buffer_free(struct StrandData *strands);
#endif
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 90930de..a5370bb 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -2282,7 +2282,19 @@ static bool strands_setup_buffer_common(StrandData *strands, GPUBufferType type,
return *buf != NULL;
}
-void GPU_strands_setup(StrandData *strands)
+void GPU_strands_setup_control_verts(StrandData *strands)
+{
+ if (!strands_setup_buffer_common(strands, GPU_BUFFER_VERTEX, false))
+ return;
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glBindBuffer(GL_ARRAY_BUFFER, strands->gpu_buffer->points->id);
+ glVertexPointer(3, GL_FLOAT, 0, NULL);
+
+ GLStates |= (GPU_BUFFER_VERTEX_STATE);
+}
+
+void GPU_strands_setup_control_edges(StrandData *strands)
{
if (!strands_setup_buffer_common(strands, GPU_BUFFER_EDGE, false))
return;
More information about the Bf-blender-cvs
mailing list