Revision: 58749
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58749
Author:   gdh
Date:     2013-07-30 23:34:52 +0000 (Tue, 30 Jul 2013)
Log Message:
-----------
This commit finishes export.

The problem I was having before is that I was expecting the buffer to be 
expanded in capacity, not in size. I added code that allows me to choose 
between the two if necessary.

After this commit, export is fully working.

Modified Paths:
--------------
    branches/soc-2013-cycles_mblur/intern/cycles/render/attribute.cpp
    branches/soc-2013-cycles_mblur/intern/cycles/render/attribute.h

Modified: branches/soc-2013-cycles_mblur/intern/cycles/render/attribute.cpp
===================================================================
--- branches/soc-2013-cycles_mblur/intern/cycles/render/attribute.cpp   
2013-07-30 20:33:17 UTC (rev 58748)
+++ branches/soc-2013-cycles_mblur/intern/cycles/render/attribute.cpp   
2013-07-30 23:34:52 UTC (rev 58749)
@@ -39,9 +39,14 @@
                type == TypeDesc::TypeNormal);
 }
 
-void Attribute::reserve(int numverts, int numtris, int numsteps, int 
numcurves, int numkeys)
+void Attribute::reserve(int numverts, int numtris, int numsteps, int 
numcurves, int numkeys, bool resize)
 {
-       buffer.resize(buffer_size(numverts, numtris, numsteps, numcurves, 
numkeys), 0);
+       if (resize) {
+               buffer.resize(buffer_size(numverts, numtris, numsteps, 
numcurves, numkeys), 0);
+       }
+       else {
+               buffer.reserve(buffer_size(numverts, numtris, numsteps, 
numcurves, numkeys));
+       }
 }
 
 void Attribute::add(const float& f)
@@ -172,7 +177,7 @@
 {
 }
 
-Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement 
element)
+Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement 
element, bool resize)
 {
        Attribute *attr = find(name);
 
@@ -192,9 +197,9 @@
        
        /* this is weak .. */
        if(triangle_mesh)
-               attr->reserve(triangle_mesh->verts.size(), 
triangle_mesh->triangles.size(), triangle_mesh->mblur_steps, 0, 0);
+               attr->reserve(triangle_mesh->verts.size(), 
triangle_mesh->triangles.size(), triangle_mesh->mblur_steps, 0, 0, resize);
        if(curve_mesh)
-               attr->reserve(0, 0, 0, curve_mesh->curves.size(), 
curve_mesh->curve_keys.size());
+               attr->reserve(0, 0, 0, curve_mesh->curves.size(), 
curve_mesh->curve_keys.size(), resize);
        
        return attr;
 }
@@ -234,37 +239,37 @@
        if(triangle_mesh) {
                switch(std) {
                        case ATTR_STD_VERTEX_NORMAL:
-                               attr = add(name, TypeDesc::TypeNormal, 
ATTR_ELEMENT_VERTEX);
+                               attr = add(name, TypeDesc::TypeNormal, 
ATTR_ELEMENT_VERTEX, true);
                                break;
                        case ATTR_STD_FACE_NORMAL:
-                               attr = add(name, TypeDesc::TypeNormal, 
ATTR_ELEMENT_FACE);
+                               attr = add(name, TypeDesc::TypeNormal, 
ATTR_ELEMENT_FACE, true);
                                break;
                        case ATTR_STD_UV:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CORNER);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CORNER, true);
                                break;
                        case ATTR_STD_UV_TANGENT:
-                               attr = add(name, TypeDesc::TypeVector, 
ATTR_ELEMENT_CORNER);
+                               attr = add(name, TypeDesc::TypeVector, 
ATTR_ELEMENT_CORNER, true);
                                break;
                        case ATTR_STD_UV_TANGENT_SIGN:
-                               attr = add(name, TypeDesc::TypeFloat, 
ATTR_ELEMENT_CORNER);
+                               attr = add(name, TypeDesc::TypeFloat, 
ATTR_ELEMENT_CORNER, true);
                                break;
                        case ATTR_STD_GENERATED:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX, true);
                                break;
                        case ATTR_STD_POSITION_UNDEFORMED:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX, true);
                                break;
                        case ATTR_STD_POSITION_UNDISPLACED:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX, true);
                                break;
                        case ATTR_STD_MOTION_PRE:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX, true);
                                break;
                        case ATTR_STD_MOTION_POST:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX, true);
                                break;
                        case ATTR_STD_DMOTION:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX_STEPS);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_VERTEX_STEPS, false);
                                break;
                        default:
                                assert(0);
@@ -274,22 +279,22 @@
        else if(curve_mesh) {
                switch(std) {
                        case ATTR_STD_UV:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CURVE);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CURVE, true);
                                break;
                        case ATTR_STD_GENERATED:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CURVE);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CURVE, true);
                                break;
                        case ATTR_STD_MOTION_PRE:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CURVE_KEY);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CURVE_KEY, true);
                                break;
                        case ATTR_STD_MOTION_POST:
-                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CURVE_KEY);
+                               attr = add(name, TypeDesc::TypePoint, 
ATTR_ELEMENT_CURVE_KEY, true);
                                break;
                        case ATTR_STD_CURVE_TANGENT:
-                               attr = add(name, TypeDesc::TypeVector, 
ATTR_ELEMENT_CURVE_KEY);
+                               attr = add(name, TypeDesc::TypeVector, 
ATTR_ELEMENT_CURVE_KEY, true);
                                break;
                        case ATTR_STD_CURVE_INTERCEPT:
-                               attr = add(name, TypeDesc::TypeFloat, 
ATTR_ELEMENT_CURVE_KEY);
+                               attr = add(name, TypeDesc::TypeFloat, 
ATTR_ELEMENT_CURVE_KEY, true);
                                break;
                        default:
                                assert(0);
@@ -339,9 +344,9 @@
 {
        foreach(Attribute& attr, attributes) {
                if(triangle_mesh)
-                       attr.reserve(triangle_mesh->verts.size(), 
triangle_mesh->triangles.size(), triangle_mesh->mblur_steps, 0, 0);
+                       attr.reserve(triangle_mesh->verts.size(), 
triangle_mesh->triangles.size(), triangle_mesh->mblur_steps, 0, 0, true);
                if(curve_mesh)
-                       attr.reserve(0, 0, 0, curve_mesh->curves.size(), 
curve_mesh->curve_keys.size());
+                       attr.reserve(0, 0, 0, curve_mesh->curves.size(), 
curve_mesh->curve_keys.size(), true);
        }
 }
 

Modified: branches/soc-2013-cycles_mblur/intern/cycles/render/attribute.h
===================================================================
--- branches/soc-2013-cycles_mblur/intern/cycles/render/attribute.h     
2013-07-30 20:33:17 UTC (rev 58748)
+++ branches/soc-2013-cycles_mblur/intern/cycles/render/attribute.h     
2013-07-30 23:34:52 UTC (rev 58749)
@@ -50,7 +50,7 @@
 
        Attribute() {}
        void set(ustring name, TypeDesc type, AttributeElement element);
-       void reserve(int numverts, int numfaces, int numsteps, int numcurves, 
int numkeys);
+       void reserve(int numverts, int numfaces, int numsteps, int numcurves, 
int numkeys, bool resize);
 
        size_t data_sizeof() const;
        size_t element_size(int numverts, int numfaces, int numsteps, int 
numcurves, int numkeys) const;
@@ -84,7 +84,7 @@
        AttributeSet();
        ~AttributeSet();
 
-       Attribute *add(ustring name, TypeDesc type, AttributeElement element);
+       Attribute *add(ustring name, TypeDesc type, AttributeElement element, 
bool resize = true);
        Attribute *find(ustring name) const;
        void remove(ustring name);
 

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

Reply via email to