Merge branch 'blender2.7'
This commit is contained in:
@@ -442,7 +442,7 @@ static void xml_read_mesh(const XMLReadState& state, xml_node node)
|
|||||||
if(xml_read_float_array(UV, node, "UV")) {
|
if(xml_read_float_array(UV, node, "UV")) {
|
||||||
ustring name = ustring("UVMap");
|
ustring name = ustring("UVMap");
|
||||||
Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name);
|
Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name);
|
||||||
float3 *fdata = attr->data_float3();
|
float2 *fdata = attr->data_float2();
|
||||||
|
|
||||||
/* loop over the triangles */
|
/* loop over the triangles */
|
||||||
index_offset = 0;
|
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(v1*2+1 < (int)UV.size());
|
||||||
assert(v2*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[0] = make_float2(UV[v0*2], UV[v0*2+1]);
|
||||||
fdata[1] = make_float3(UV[v1*2], UV[v1*2+1], 0.0);
|
fdata[1] = make_float2(UV[v1*2], UV[v1*2+1]);
|
||||||
fdata[2] = make_float3(UV[v2*2], UV[v2*2+1], 0.0);
|
fdata[2] = make_float2(UV[v2*2], UV[v2*2+1]);
|
||||||
fdata += 3;
|
fdata += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -430,7 +430,7 @@ static void attr_create_uv_map(Scene *scene,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uv_attr = mesh->attributes.add(uv_name,
|
uv_attr = mesh->attributes.add(uv_name,
|
||||||
TypeDesc::TypePoint,
|
TypeFloat2,
|
||||||
ATTR_ELEMENT_CORNER);
|
ATTR_ELEMENT_CORNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,7 +509,7 @@ static void attr_create_subd_uv_map(Scene *scene,
|
|||||||
if(active_render)
|
if(active_render)
|
||||||
uv_attr = mesh->subd_attributes.add(uv_std, uv_name);
|
uv_attr = mesh->subd_attributes.add(uv_std, uv_name);
|
||||||
else
|
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) {
|
if(subdivide_uvs) {
|
||||||
uv_attr->flags |= ATTR_SUBDIVIDED;
|
uv_attr->flags |= ATTR_SUBDIVIDED;
|
||||||
|
@@ -69,6 +69,8 @@ void Attribute::resize(size_t num_elements)
|
|||||||
|
|
||||||
void Attribute::add(const float& f)
|
void Attribute::add(const float& f)
|
||||||
{
|
{
|
||||||
|
assert(data_sizeof() == sizeof(float));
|
||||||
|
|
||||||
char *data = (char*)&f;
|
char *data = (char*)&f;
|
||||||
size_t size = sizeof(f);
|
size_t size = sizeof(f);
|
||||||
|
|
||||||
@@ -78,6 +80,19 @@ void Attribute::add(const float& f)
|
|||||||
|
|
||||||
void Attribute::add(const uchar4& 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;
|
char *data = (char*)&f;
|
||||||
size_t size = sizeof(f);
|
size_t size = sizeof(f);
|
||||||
|
|
||||||
@@ -87,6 +102,8 @@ void Attribute::add(const uchar4& f)
|
|||||||
|
|
||||||
void Attribute::add(const float3& f)
|
void Attribute::add(const float3& f)
|
||||||
{
|
{
|
||||||
|
assert(data_sizeof() == sizeof(float3));
|
||||||
|
|
||||||
char *data = (char*)&f;
|
char *data = (char*)&f;
|
||||||
size_t size = sizeof(f);
|
size_t size = sizeof(f);
|
||||||
|
|
||||||
@@ -96,6 +113,8 @@ void Attribute::add(const float3& f)
|
|||||||
|
|
||||||
void Attribute::add(const Transform& f)
|
void Attribute::add(const Transform& f)
|
||||||
{
|
{
|
||||||
|
assert(data_sizeof() == sizeof(Transform));
|
||||||
|
|
||||||
char *data = (char*)&f;
|
char *data = (char*)&f;
|
||||||
size_t size = sizeof(f);
|
size_t size = sizeof(f);
|
||||||
|
|
||||||
@@ -105,6 +124,8 @@ void Attribute::add(const Transform& f)
|
|||||||
|
|
||||||
void Attribute::add(const VoxelAttribute& f)
|
void Attribute::add(const VoxelAttribute& f)
|
||||||
{
|
{
|
||||||
|
assert(data_sizeof() == sizeof(VoxelAttribute));
|
||||||
|
|
||||||
char *data = (char*)&f;
|
char *data = (char*)&f;
|
||||||
size_t size = sizeof(f);
|
size_t size = sizeof(f);
|
||||||
|
|
||||||
@@ -128,6 +149,8 @@ size_t Attribute::data_sizeof() const
|
|||||||
return sizeof(uchar4);
|
return sizeof(uchar4);
|
||||||
else if(type == TypeDesc::TypeFloat)
|
else if(type == TypeDesc::TypeFloat)
|
||||||
return sizeof(float);
|
return sizeof(float);
|
||||||
|
else if(type == TypeFloat2)
|
||||||
|
return sizeof(float2);
|
||||||
else if(type == TypeDesc::TypeMatrix)
|
else if(type == TypeDesc::TypeMatrix)
|
||||||
return sizeof(Transform);
|
return sizeof(Transform);
|
||||||
else
|
else
|
||||||
|
@@ -66,22 +66,80 @@ public:
|
|||||||
size_t element_size(Mesh *mesh, AttributePrimitive prim) const;
|
size_t element_size(Mesh *mesh, AttributePrimitive prim) const;
|
||||||
size_t buffer_size(Mesh *mesh, AttributePrimitive prim) const;
|
size_t buffer_size(Mesh *mesh, AttributePrimitive prim) const;
|
||||||
|
|
||||||
char *data() { return (buffer.size())? &buffer[0]: NULL; };
|
char *data()
|
||||||
float2 *data_float2() { return (float2*)data(); }
|
{
|
||||||
float3 *data_float3() { return (float3*)data(); }
|
return (buffer.size())? &buffer[0]: NULL;
|
||||||
float4 *data_float4() { return (float4*)data(); }
|
}
|
||||||
float *data_float() { return (float*)data(); }
|
float2 *data_float2()
|
||||||
uchar4 *data_uchar4() { return (uchar4*)data(); }
|
{
|
||||||
Transform *data_transform() { return (Transform*)data(); }
|
assert(data_sizeof() == sizeof(float2));
|
||||||
VoxelAttribute *data_voxel() { return ( VoxelAttribute*)data(); }
|
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 char *data() const
|
||||||
const float2 *data_float2() const { return (const float2*)data(); }
|
{
|
||||||
const float3 *data_float3() const { return (const float3*)data(); }
|
return (buffer.size())? &buffer[0]: NULL;
|
||||||
const float4 *data_float4() const { return (const float4*)data(); }
|
}
|
||||||
const float *data_float() const { return (const float*)data(); }
|
const float2 *data_float2() const
|
||||||
const Transform *data_transform() const { return (const Transform*)data(); }
|
{
|
||||||
const VoxelAttribute *data_voxel() const { return (const VoxelAttribute*)data(); }
|
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 zero_data(void* dst);
|
||||||
void add_with_weight(void* dst, void* src, float weight);
|
void add_with_weight(void* dst, void* src, float weight);
|
||||||
|
@@ -3480,7 +3480,7 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int attr = compiler.attribute(ATTR_STD_UV);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user