Merge branch 'blender2.7'
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 5 Mar 2019 18:14:00 +0000 (19:14 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 5 Mar 2019 18:14:00 +0000 (19:14 +0100)
intern/cycles/app/cycles_xml.cpp
intern/cycles/blender/blender_mesh.cpp
intern/cycles/render/attribute.cpp
intern/cycles/render/attribute.h
intern/cycles/render/nodes.cpp

index 895a838..d4ee284 100644 (file)
@@ -442,7 +442,7 @@ static void xml_read_mesh(const XMLReadState& state, xml_node node)
                if(xml_read_float_array(UV, node, "UV")) {
                        ustring name = ustring("UVMap");
                        Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name);
-                       float3 *fdata = attr->data_float3();
+                       float2 *fdata = attr->data_float2();
 
                        /* loop over the triangles */
                        index_offset = 0;
@@ -456,9 +456,9 @@ static void xml_read_mesh(const XMLReadState& state, xml_node node)
                                        assert(v1*2+1 < (int)UV.size());
                                        assert(v2*2+1 < (int)UV.size());
 
-                                       fdata[0] = make_float3(UV[v0*2], UV[v0*2+1], 0.0);
-                                       fdata[1] = make_float3(UV[v1*2], UV[v1*2+1], 0.0);
-                                       fdata[2] = make_float3(UV[v2*2], UV[v2*2+1], 0.0);
+                                       fdata[0] = make_float2(UV[v0*2], UV[v0*2+1]);
+                                       fdata[1] = make_float2(UV[v1*2], UV[v1*2+1]);
+                                       fdata[2] = make_float2(UV[v2*2], UV[v2*2+1]);
                                        fdata += 3;
                                }
 
index fa61caf..41fb36c 100644 (file)
@@ -430,7 +430,7 @@ static void attr_create_uv_map(Scene *scene,
                                }
                                else {
                                        uv_attr = mesh->attributes.add(uv_name,
-                                                                      TypeDesc::TypePoint,
+                                                                      TypeFloat2,
                                                                       ATTR_ELEMENT_CORNER);
                                }
 
@@ -509,7 +509,7 @@ static void attr_create_subd_uv_map(Scene *scene,
                                if(active_render)
                                        uv_attr = mesh->subd_attributes.add(uv_std, uv_name);
                                else
-                                       uv_attr = mesh->subd_attributes.add(uv_name, TypeDesc::TypePoint, ATTR_ELEMENT_CORNER);
+                                       uv_attr = mesh->subd_attributes.add(uv_name, TypeFloat2, ATTR_ELEMENT_CORNER);
 
                                if(subdivide_uvs) {
                                        uv_attr->flags |= ATTR_SUBDIVIDED;
index 70f75a4..0ce30b3 100644 (file)
@@ -69,6 +69,8 @@ void Attribute::resize(size_t num_elements)
 
 void Attribute::add(const float& f)
 {
+       assert(data_sizeof() == sizeof(float));
+
        char *data = (char*)&f;
        size_t size = sizeof(f);
 
@@ -78,6 +80,19 @@ void Attribute::add(const float& f)
 
 void Attribute::add(const uchar4& f)
 {
+       assert(data_sizeof() == sizeof(uchar4));
+
+       char *data = (char*)&f;
+       size_t size = sizeof(f);
+
+       for(size_t i = 0; i < size; i++)
+               buffer.push_back(data[i]);
+}
+
+void Attribute::add(const float2& f)
+{
+       assert(data_sizeof() == sizeof(float2));
+
        char *data = (char*)&f;
        size_t size = sizeof(f);
 
@@ -87,6 +102,8 @@ void Attribute::add(const uchar4& f)
 
 void Attribute::add(const float3& f)
 {
+       assert(data_sizeof() == sizeof(float3));
+
        char *data = (char*)&f;
        size_t size = sizeof(f);
 
@@ -96,6 +113,8 @@ void Attribute::add(const float3& f)
 
 void Attribute::add(const Transform& f)
 {
+       assert(data_sizeof() == sizeof(Transform));
+
        char *data = (char*)&f;
        size_t size = sizeof(f);
 
@@ -105,6 +124,8 @@ void Attribute::add(const Transform& f)
 
 void Attribute::add(const VoxelAttribute& f)
 {
+       assert(data_sizeof() == sizeof(VoxelAttribute));
+
        char *data = (char*)&f;
        size_t size = sizeof(f);
 
@@ -128,6 +149,8 @@ size_t Attribute::data_sizeof() const
                return sizeof(uchar4);
        else if(type == TypeDesc::TypeFloat)
                return sizeof(float);
+       else if(type == TypeFloat2)
+               return sizeof(float2);
        else if(type == TypeDesc::TypeMatrix)
                return sizeof(Transform);
        else
index 9a92d98..ed9e9fe 100644 (file)
@@ -66,22 +66,80 @@ public:
        size_t element_size(Mesh *mesh, AttributePrimitive prim) const;
        size_t buffer_size(Mesh *mesh, AttributePrimitive prim) const;
 
-       char *data() { return (buffer.size())? &buffer[0]: NULL; };
-       float2 *data_float2() { return (float2*)data(); }
-       float3 *data_float3() { return (float3*)data(); }
-       float4 *data_float4() { return (float4*)data(); }
-       float *data_float() { return (float*)data(); }
-       uchar4 *data_uchar4() { return (uchar4*)data(); }
-       Transform *data_transform() { return (Transform*)data(); }
-       VoxelAttribute *data_voxel()  { return ( VoxelAttribute*)data(); }
-
-       const char *data() const { return (buffer.size())? &buffer[0]: NULL; }
-       const float2 *data_float2() const { return (const float2*)data(); }
-       const float3 *data_float3() const { return (const float3*)data(); }
-       const float4 *data_float4() const { return (const float4*)data(); }
-       const float *data_float() const { return (const float*)data(); }
-       const Transform *data_transform() const { return (const Transform*)data(); }
-       const VoxelAttribute *data_voxel() const { return (const VoxelAttribute*)data(); }
+       char *data()
+       {
+               return (buffer.size())? &buffer[0]: NULL;
+       }
+       float2 *data_float2()
+       {
+               assert(data_sizeof() == sizeof(float2));
+               return (float2*)data();
+       }
+       float3 *data_float3()
+       {
+               assert(data_sizeof() == sizeof(float3));
+               return (float3*)data();
+       }
+       float4 *data_float4()
+       {
+               assert(data_sizeof() == sizeof(float4));
+               return (float4*)data();
+       }
+       float *data_float()
+       {
+               assert(data_sizeof() == sizeof(float));
+               return (float*)data();
+       }
+       uchar4 *data_uchar4()
+       {
+               assert(data_sizeof() == sizeof(uchar4));
+               return (uchar4*)data();
+       }
+       Transform *data_transform()
+       {
+               assert(data_sizeof() == sizeof(Transform));
+               return (Transform*)data();
+       }
+       VoxelAttribute *data_voxel()
+       {
+               assert(data_sizeof() == sizeof(VoxelAttribute));
+               return ( VoxelAttribute*)data();
+       }
+
+       const char *data() const
+       {
+               return (buffer.size())? &buffer[0]: NULL;
+       }
+       const float2 *data_float2() const
+       {
+               assert(data_sizeof() == sizeof(float2));
+               return (const float2*)data();
+       }
+       const float3 *data_float3() const
+       {
+               assert(data_sizeof() == sizeof(float3));
+               return (const float3*)data();
+       }
+       const float4 *data_float4() const
+       {
+               assert(data_sizeof() == sizeof(float4));
+               return (const float4*)data();
+       }
+       const float *data_float() const
+       {
+               assert(data_sizeof() == sizeof(float));
+               return (const float*)data();
+       }
+       const Transform *data_transform() const
+       {
+               assert(data_sizeof() == sizeof(Transform));
+               return (const Transform*)data();
+       }
+       const VoxelAttribute *data_voxel() const
+       {
+               assert(data_sizeof() == sizeof(VoxelAttribute));
+               return (const VoxelAttribute*)data();
+       }
 
        void zero_data(void* dst);
        void add_with_weight(void* dst, void* src, float weight);
index fcdfb62..b70bad8 100644 (file)
@@ -3480,7 +3480,7 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler)
                }
                else {
                        int attr = compiler.attribute(ATTR_STD_UV);
-                       compiler.add_node(attr_node, attr, compiler.stack_assign(out), NODE_ATTR_FLOAT2);
+                       compiler.add_node(attr_node, attr, compiler.stack_assign(out), NODE_ATTR_FLOAT3);
                }
        }