Commit: 7b7cef9863d61c280502e92a38ded2e24b09de4e
Author: Lukas Tönne
Date:   Wed Jun 29 18:02:42 2016 +0200
Branches: strand_gpu
https://developer.blender.org/rB7b7cef9863d61c280502e92a38ded2e24b09de4e

Use plain vertex and curve arrays in Strands data, so that they can be used as 
OpenGL buffers.

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

M       source/blender/blenkernel/BKE_strands.h
M       source/blender/blenkernel/intern/strands.c
M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/writefile.c
M       source/blender/editors/space_view3d/drawstrands.c
M       source/blender/makesdna/DNA_strand_types.h

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

diff --git a/source/blender/blenkernel/BKE_strands.h 
b/source/blender/blenkernel/BKE_strands.h
index 2ecdaf8..dac8548 100644
--- a/source/blender/blenkernel/BKE_strands.h
+++ b/source/blender/blenkernel/BKE_strands.h
@@ -46,16 +46,18 @@ struct Strands *BKE_strands_copy(struct Strands *strands);
 void BKE_strands_free(struct Strands *strands);
 
 struct StrandInfo *BKE_strands_scatter(struct DerivedMesh *scalp, unsigned int 
amount,
-                                       const ControlStrand *controls, unsigned 
int num_controls,
+                                       const StrandCurve *controls, unsigned 
int num_controls,
                                        unsigned int seed);
 
+#if 0
 typedef struct StrandCurveParams {
        struct DerivedMesh *scalp;
        unsigned int max_verts;
 } StrandCurveParams;
 
 struct StrandData *BKE_strand_data_interpolate(struct StrandInfo *strands, 
unsigned int num_strands,
-                                               const ControlStrand *controls, 
struct StrandCurveParams *params);
+                                               const StrandCurve *controls, 
struct StrandCurveParams *params);
 void BKE_strand_data_free(struct StrandData *data);
+#endif
 
 #endif
diff --git a/source/blender/blenkernel/intern/strands.c 
b/source/blender/blenkernel/intern/strands.c
index b86421d..ea4e929 100644
--- a/source/blender/blenkernel/intern/strands.c
+++ b/source/blender/blenkernel/intern/strands.c
@@ -50,8 +50,11 @@ Strands *BKE_strands_copy(Strands *strands)
 {
        Strands *nstrands = MEM_dupallocN(strands);
        
-       if (strands->controls) {
-               nstrands->controls = MEM_dupallocN(strands->controls);
+       if (strands->curves) {
+               nstrands->curves = MEM_dupallocN(strands->curves);
+       }
+       if (strands->verts) {
+               nstrands->verts = MEM_dupallocN(strands->verts);
        }
        
        /* lazy initialized */
@@ -69,7 +72,7 @@ void BKE_strands_free(Strands *strands)
 }
 
 StrandInfo *BKE_strands_scatter(struct DerivedMesh *scalp, unsigned int amount,
-                                const ControlStrand *controls, unsigned int 
num_controls,
+                                const StrandCurve *controls, unsigned int 
num_controls,
                                 unsigned int seed)
 {
        MeshSampleGenerator *gen = BKE_mesh_sample_gen_surface_random(scalp, 
seed);
@@ -100,8 +103,9 @@ StrandInfo *BKE_strands_scatter(struct DerivedMesh *scalp, 
unsigned int amount,
        return strands;
 }
 
+#if 0
 StrandData *BKE_strand_data_interpolate(StrandInfo *strands, unsigned int 
num_strands,
-                                        const ControlStrand *controls, struct 
StrandCurveParams *params)
+                                        const StrandCurve *controls, struct 
StrandCurveParams *params)
 {
        StrandData *data = MEM_callocN(sizeof(StrandData), "strand 
interpolation data");
        StrandInfo *s;
@@ -155,3 +159,4 @@ void BKE_strand_data_free(StrandData *data)
                MEM_freeN(data);
        }
 }
+#endif
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 3f1c736..72d1258 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4308,7 +4308,8 @@ static void direct_link_strands(FileData *fd, Strands 
*strands)
        if (strands == NULL)
                return;
        
-       strands->controls = newdataadr(fd, strands->controls);
+       strands->curves = newdataadr(fd, strands->curves);
+       strands->verts = newdataadr(fd, strands->verts);
        
        /* runtime */
        strands->gpu_strands = NULL;
diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index 5be45c5..e22fe6f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1260,8 +1260,11 @@ static void write_strands(WriteData *wd, Strands 
*strands)
        
        writestruct(wd, DATA, "Strands", 1, strands);
        
-       if (strands->controls) {
-               writestruct(wd, DATA, "ControlStrand", strands->num_controls, 
strands->controls);
+       if (strands->curves) {
+               writestruct(wd, DATA, "StrandCurve", strands->totcurves, 
strands->curves);
+       }
+       if (strands->verts) {
+               writestruct(wd, DATA, "StrandVertex", strands->totverts, 
strands->verts);
        }
 }
 
diff --git a/source/blender/editors/space_view3d/drawstrands.c 
b/source/blender/editors/space_view3d/drawstrands.c
index 51b885c..88a5e3d 100644
--- a/source/blender/editors/space_view3d/drawstrands.c
+++ b/source/blender/editors/space_view3d/drawstrands.c
@@ -60,6 +60,7 @@ void draw_strands(Strands *strands, Object *ob, RegionView3D 
*rv3d)
        GLuint vertex_buffer;
        glGenBuffers(1, &vertex_buffer);
        glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
+       
        const size_t numverts = 4;
        float verts[12] = {
            0.0f, 0.0f, 0.0f,
diff --git a/source/blender/makesdna/DNA_strand_types.h 
b/source/blender/makesdna/DNA_strand_types.h
index 3d07419..e41f7bd 100644
--- a/source/blender/makesdna/DNA_strand_types.h
+++ b/source/blender/makesdna/DNA_strand_types.h
@@ -43,14 +43,15 @@ typedef struct StrandVertex {
 } StrandVertex;
 
 typedef struct StrandCurve {
+       /* Point on the scalp mesh for the root vertex */
+       MeshSample root;
        /* Start of vertex list */
        unsigned int verts_begin;
        /* Number of vertices in the curve */
        unsigned int num_verts;
-       /* Transform to object space */
-       float rootmat[4][4];
 } StrandCurve;
 
+#if 0
 typedef struct StrandData {
        /* Array of vertices */
        StrandVertex *verts;
@@ -62,6 +63,7 @@ typedef struct StrandData {
        /* Total number of curves */
        int totcurves;
 } StrandData;
+#endif
 
 typedef struct StrandInfo {
        /* Sample on the scalp mesh for the root vertex */
@@ -72,17 +74,16 @@ typedef struct StrandInfo {
        float control_weights[4];
 } StrandInfo;
 
-typedef struct ControlStrand {
-       /* Sample on the scalp mesh for the root vertex */
-       MeshSample root;
-       /* Curve in root space */
-       StrandCurve curve;
-} ControlStrand;
-
 typedef struct Strands {
-       ControlStrand *controls;
-       int num_controls;
-       int pad;
+       /* Array of vertices */
+       StrandVertex *verts;
+       /* Array of curves */
+       StrandCurve *curves;
+       
+       /* Total number of vertices */
+       int totverts;
+       /* Total number of curves */
+       int totcurves;
        
        struct GPUStrands *gpu_strands;
 } Strands;

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

Reply via email to