Commit: fe6a447b24735897b8ee02400c6208e028f2419e
Author: Lukas Tönne
Date:   Fri Jul 1 11:04:47 2016 +0200
Branches: strand_gpu
https://developer.blender.org/rBfe6a447b24735897b8ee02400c6208e028f2419e

Draw render strands as simple point primitives.

The geometry shader will eventually turn these points into full strand curves.

===================================================================

M       release/scripts/startup/bl_ui/properties_data_modifier.py
M       source/blender/blenkernel/intern/strands.c
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
M       source/blender/makesdna/DNA_modifier_types.h
M       source/blender/makesrna/intern/rna_modifier.c
M       source/blender/modifiers/intern/MOD_strands.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index cf5b39e..3c1af94 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -890,6 +890,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col = split.column()
         col.label(text="Display:")
         col.prop(md, "show_control_strands", text="Control Strands")
+        col.prop(md, "show_render_strands", text="Render Strands")
 
     def SUBSURF(self, layout, ob, md):
         layout.row().prop(md, "subdivision_type", expand=True)
diff --git a/source/blender/blenkernel/intern/strands.c 
b/source/blender/blenkernel/intern/strands.c
index aab0d9f..4ad4616 100644
--- a/source/blender/blenkernel/intern/strands.c
+++ b/source/blender/blenkernel/intern/strands.c
@@ -117,7 +117,7 @@ StrandData *BKE_strand_data_calc(Strands *strands, 
DerivedMesh *scalp,
        int i;
        StrandRoot *sroot = roots;
        StrandRootData *root = data->roots;
-       for (i = 0; i < data->totroots; ++i) {
+       for (i = 0; i < data->totroots; ++i, ++sroot, ++root) {
                float nor[3], tang[3];
                BKE_mesh_sample_eval(scalp, &sroot->root, root->co, nor, tang);
                
diff --git a/source/blender/editors/space_view3d/drawobject.c 
b/source/blender/editors/space_view3d/drawobject.c
index e19030d..66f2f38 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -7972,8 +7972,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, 
Base *base, const short
                        StrandsModifierData *smd = (StrandsModifierData *)md;
                        
                        if (smd->strands && smd->strands->data_final) {
+                               bool show_controls = smd->flag & 
MOD_STRANDS_SHOW_CONTROL_STRANDS;
+                               bool show_strands = smd->flag & 
MOD_STRANDS_SHOW_RENDER_STRANDS;
                                draw_strands(smd->strands, 
smd->strands->data_final, ob, rv3d,
-                                            smd->flag & 
MOD_STRANDS_SHOW_CONTROL_STRANDS);
+                                            show_controls, show_strands);
                        }
                }
        }
diff --git a/source/blender/editors/space_view3d/drawstrands.c 
b/source/blender/editors/space_view3d/drawstrands.c
index 49f6285..3c3c3e9 100644
--- a/source/blender/editors/space_view3d/drawstrands.c
+++ b/source/blender/editors/space_view3d/drawstrands.c
@@ -53,21 +53,31 @@
 #include "view3d_intern.h"  // own include
 
 void draw_strands(Strands *strands, StrandData *data, Object *ob, RegionView3D 
*rv3d,
-                  bool show_controls)
+                  bool show_controls, bool show_strands)
 {
        GPUStrandsShader *gpu_shader = GPU_strand_shader_get(strands);
        
        if (show_controls) {
-               GPU_strands_setup_control_edges(data);
+               GPU_strands_setup_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_buffer_draw_elements(gds->edges, GL_LINES, 0,
+                                                (gds->totverts - 
gds->totcurves) * 2);
                }
                GPU_buffers_unbind();
        }
        
-//     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);
+       if (show_strands) {
+//             GPU_strand_shader_bind_uniforms(gpu_shader, ob->obmat, 
rv3d->viewmat);
+//             GPU_strand_shader_bind(gpu_shader, rv3d->viewmat, 
rv3d->viewinv);
+               
+               GPU_strands_setup_verts(data);
+               GPUDrawStrands *gds = data->gpu_buffer;
+               if (gds->points) {
+                       glDrawArrays(GL_POINTS, gds->totverts * 3, 
gds->totroots * 3);
+               }
+               GPU_buffers_unbind();
+               
+//             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 1c3b03e..33a8f8c 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -289,7 +289,7 @@ 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,
-                  bool show_controls);
+                  bool show_controls, bool show_strands);
 
 /* 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 faccc5e..953b112 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -156,6 +156,7 @@ typedef struct GPUDrawStrands {
 
        unsigned int totverts;
        unsigned int totcurves;
+       unsigned int totroots;
 } GPUDrawStrands;
 
 
@@ -285,8 +286,8 @@ void GPU_free_pbvh_buffer_multires(struct 
GridCommonGPUBuffer **grid_common_gpu_
 
 /* strands */
 
-void GPU_strands_setup_control_verts(struct StrandData *strands);
-void GPU_strands_setup_control_edges(struct StrandData *strands);
+void GPU_strands_setup_verts(struct StrandData *strands);
+void GPU_strands_setup_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 a5370bb..2a5a735 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -2126,10 +2126,11 @@ static size_t 
gpu_strands_buffer_size_from_type(StrandData *strands, GPUBufferTy
        const int components = gpu_buffer_type_settings[type].num_components;
        const int totverts = strands->gpu_buffer->totverts;
        const int totcurves = strands->gpu_buffer->totcurves;
+       const int totroots = strands->gpu_buffer->totroots;
        
        switch (type) {
                case GPU_BUFFER_VERTEX:
-                       return sizeof(float) * components * totverts;
+                       return sizeof(float) * components * (totverts + 
totroots);
                case GPU_BUFFER_NORMAL:
                        return sizeof(short) * components * 0;
                case GPU_BUFFER_COLOR:
@@ -2155,18 +2156,26 @@ static GPUDrawStrands *strands_buffer_create(StrandData 
*strands)
        
        gsb->totverts = strands->totverts;
        gsb->totcurves = strands->totcurves;
+       gsb->totroots = strands->totroots;
        
        return gsb;
 }
 
 static void strands_copy_vertex_buffer(StrandData *strands, float (*varray)[3])
 {
-       int totverts = strands->totverts, v;
+       int totverts = strands->totverts, totroots = strands->totroots, v;
        
+       /* control strand vertices */
        StrandVertexData *vert = strands->verts;
        for (v = 0; v < totverts; ++v, ++vert) {
                copy_v3_v3(*varray++, vert->co);
        }
+       
+       /* strand root points */
+       StrandRootData *root = strands->roots;
+       for (v = 0; v < totroots; ++v, ++root) {
+               copy_v3_v3(*varray++, root->co);
+       }
 }
 
 static void strands_copy_edge_buffer(StrandData *strands, unsigned int 
(*varray)[2])
@@ -2282,7 +2291,7 @@ static bool strands_setup_buffer_common(StrandData 
*strands, GPUBufferType type,
        return *buf != NULL;
 }
 
-void GPU_strands_setup_control_verts(StrandData *strands)
+void GPU_strands_setup_verts(StrandData *strands)
 {
        if (!strands_setup_buffer_common(strands, GPU_BUFFER_VERTEX, false))
                return;
@@ -2294,7 +2303,7 @@ void GPU_strands_setup_control_verts(StrandData *strands)
        GLStates |= (GPU_BUFFER_VERTEX_STATE);
 }
 
-void GPU_strands_setup_control_edges(StrandData *strands)
+void GPU_strands_setup_edges(StrandData *strands)
 {
        if (!strands_setup_buffer_common(strands, GPU_BUFFER_EDGE, false))
                return;
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 241433a..0fe2255 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1560,6 +1560,7 @@ typedef struct StrandsModifierData {
 /* StrandsModifierData.flag */
 enum {
        MOD_STRANDS_SHOW_CONTROL_STRANDS = (1 << 0),
+       MOD_STRANDS_SHOW_RENDER_STRANDS = (1 << 1),
 };
 
 #endif  /* __DNA_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index f9058f8..f003ea4 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4698,6 +4698,12 @@ static void rna_def_modifier_strands(BlenderRNA *brna)
        RNA_def_property_boolean_default(prop, true);
        RNA_def_property_ui_text(prop, "Show Control Strands", "Show control 
strand curves");
        RNA_def_property_update(prop, 0, "rna_Modifier_update");
+       
+       prop = RNA_def_property(srna, "show_render_strands", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 
MOD_STRANDS_SHOW_RENDER_STRANDS);
+       RNA_def_property_boolean_default(prop, true);
+       RNA_def_property_ui_text(prop, "Show Render Strands", "Show render 
strand curves");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 void RNA_def_modifier(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_strands.c 
b/source/blender/modifiers/intern/MOD_strands.c
index 2d97c5a..6eaf56a 100644
--- a/source/blender/modifiers/intern/MOD_strands.c
+++ b/source/blender/modifiers/intern/MOD_strands.c
@@ -59,7 +59,8 @@ static void initData(ModifierData *md)
        smd->num_roots = 0;
        smd->roots = NULL;
        
-       smd->flag |= MOD_STRANDS_SHOW_CONTROL_STRANDS;
+       smd->flag |= MOD_STRANDS_SHOW_CONTROL_STRANDS |
+                    MOD_STRANDS_SHOW_RENDER_STRANDS;
 }
 
 static void copyData(ModifierData *md, ModifierData *target)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to