diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-05 21:14:00 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-05 21:14:00 +0300 |
commit | 3428ec5984c0b7bac37fa860c660652f822919a9 (patch) | |
tree | c0ca0f2ee4781f823cb658fca1bfbdb9614b010d /intern/cycles | |
parent | 5e8e3c00f2aa8331148c59db40a9ee43ee55438e (diff) | |
parent | e290a0b0568ecfcf47aa55b059de468b2c651e19 (diff) |
Merge branch 'blender2.7'
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/app/cycles_xml.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/blender/blender_mesh.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/render/attribute.cpp | 23 | ||||
-rw-r--r-- | intern/cycles/render/attribute.h | 90 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 2 |
5 files changed, 104 insertions, 23 deletions
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 895a83818df..d4ee284e24b 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -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; } diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index fa61caf2e5b..41fb36c7618 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -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; diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp index 70f75a4b573..0ce30b3bca6 100644 --- a/intern/cycles/render/attribute.cpp +++ b/intern/cycles/render/attribute.cpp @@ -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 diff --git a/intern/cycles/render/attribute.h b/intern/cycles/render/attribute.h index 9a92d98b713..ed9e9fe76d6 100644 --- a/intern/cycles/render/attribute.h +++ b/intern/cycles/render/attribute.h @@ -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); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index fcdfb62785a..b70bad810de 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -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); } } |