Cleanup: simplify Cycles primitive attribute map storage
This commit is contained in:
@@ -29,17 +29,11 @@ ccl_device_inline uint subd_triangle_patch(KernelGlobals *kg, const ShaderData *
|
||||
|
||||
ccl_device_inline uint attribute_primitive_type(KernelGlobals *kg, const ShaderData *sd)
|
||||
{
|
||||
#ifdef __HAIR__
|
||||
if (sd->type & PRIMITIVE_ALL_CURVE) {
|
||||
return ATTR_PRIM_CURVE;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (subd_triangle_patch(kg, sd) != ~0) {
|
||||
if ((sd->type & PRIMITIVE_ALL_TRIANGLE) && subd_triangle_patch(kg, sd) != ~0) {
|
||||
return ATTR_PRIM_SUBD;
|
||||
}
|
||||
else {
|
||||
return ATTR_PRIM_TRIANGLE;
|
||||
return ATTR_PRIM_GEOMETRY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,7 @@ ccl_device_inline int find_attribute_curve_motion(KernelGlobals *kg,
|
||||
* zero iterations and rendering is really slow with motion curves. For until other
|
||||
* areas are speed up it's probably not so crucial to optimize this out.
|
||||
*/
|
||||
uint attr_offset = object_attribute_map_offset(kg, object) + ATTR_PRIM_CURVE;
|
||||
uint attr_offset = object_attribute_map_offset(kg, object) + ATTR_PRIM_GEOMETRY;
|
||||
uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
|
||||
|
||||
while (attr_map.x != id) {
|
||||
|
@@ -725,9 +725,8 @@ typedef enum PrimitiveType {
|
||||
/* Attributes */
|
||||
|
||||
typedef enum AttributePrimitive {
|
||||
ATTR_PRIM_TRIANGLE = 0,
|
||||
ATTR_PRIM_GEOMETRY = 0,
|
||||
ATTR_PRIM_SUBD,
|
||||
ATTR_PRIM_CURVE,
|
||||
|
||||
ATTR_PRIM_TYPES
|
||||
} AttributePrimitive;
|
||||
|
@@ -382,10 +382,6 @@ int OSLShader::find_attribute(KernelGlobals *kg,
|
||||
{
|
||||
/* for OSL, a hash map is used to lookup the attribute by name. */
|
||||
int object = sd->object * ATTR_PRIM_TYPES;
|
||||
#ifdef __HAIR__
|
||||
if (sd->type & PRIMITIVE_ALL_CURVE)
|
||||
object += ATTR_PRIM_CURVE;
|
||||
#endif
|
||||
|
||||
OSLGlobals::AttributeMap &attr_map = kg->osl->attribute_map[object];
|
||||
ustring stdname(std::string("geom:") +
|
||||
|
@@ -193,7 +193,7 @@ size_t Attribute::element_size(Geometry *geom, AttributePrimitive prim) const
|
||||
case ATTR_ELEMENT_FACE:
|
||||
if (geom->type == Geometry::MESH) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (prim == ATTR_PRIM_TRIANGLE) {
|
||||
if (prim == ATTR_PRIM_GEOMETRY) {
|
||||
size = mesh->num_triangles();
|
||||
}
|
||||
else {
|
||||
@@ -205,7 +205,7 @@ size_t Attribute::element_size(Geometry *geom, AttributePrimitive prim) const
|
||||
case ATTR_ELEMENT_CORNER_BYTE:
|
||||
if (geom->type == Geometry::MESH) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (prim == ATTR_PRIM_TRIANGLE) {
|
||||
if (prim == ATTR_PRIM_GEOMETRY) {
|
||||
size = mesh->num_triangles() * 3;
|
||||
}
|
||||
else {
|
||||
@@ -390,11 +390,9 @@ void Attribute::get_uv_tiles(Geometry *geom,
|
||||
|
||||
/* Attribute Set */
|
||||
|
||||
AttributeSet::AttributeSet()
|
||||
AttributeSet::AttributeSet(Geometry *geometry, AttributePrimitive prim)
|
||||
: geometry(geometry), prim(prim)
|
||||
{
|
||||
triangle_mesh = NULL;
|
||||
subd_mesh = NULL;
|
||||
hair = NULL;
|
||||
}
|
||||
|
||||
AttributeSet::~AttributeSet()
|
||||
@@ -428,12 +426,7 @@ Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement eleme
|
||||
#endif
|
||||
|
||||
/* this is weak .. */
|
||||
if (triangle_mesh)
|
||||
attr->resize(triangle_mesh, ATTR_PRIM_TRIANGLE, false);
|
||||
if (subd_mesh)
|
||||
attr->resize(subd_mesh, ATTR_PRIM_SUBD, false);
|
||||
if (hair)
|
||||
attr->resize(hair, ATTR_PRIM_CURVE, false);
|
||||
attr->resize(geometry, prim, false);
|
||||
|
||||
return attr;
|
||||
}
|
||||
@@ -470,7 +463,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
|
||||
if (name == ustring())
|
||||
name = Attribute::standard_name(std);
|
||||
|
||||
if (triangle_mesh || subd_mesh) {
|
||||
if (geometry->type == Geometry::MESH) {
|
||||
switch (std) {
|
||||
case ATTR_STD_VERTEX_NORMAL:
|
||||
attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_VERTEX);
|
||||
@@ -530,7 +523,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (hair) {
|
||||
else if (geometry->type == Geometry::HAIR) {
|
||||
switch (std) {
|
||||
case ATTR_STD_UV:
|
||||
attr = add(name, TypeFloat2, ATTR_ELEMENT_CURVE);
|
||||
@@ -613,12 +606,7 @@ void AttributeSet::remove(Attribute *attribute)
|
||||
void AttributeSet::resize(bool reserve_only)
|
||||
{
|
||||
foreach (Attribute &attr, attributes) {
|
||||
if (triangle_mesh)
|
||||
attr.resize(triangle_mesh, ATTR_PRIM_TRIANGLE, reserve_only);
|
||||
if (subd_mesh)
|
||||
attr.resize(subd_mesh, ATTR_PRIM_SUBD, reserve_only);
|
||||
if (hair)
|
||||
attr.resize(hair, ATTR_PRIM_CURVE, reserve_only);
|
||||
attr.resize(geometry, prim, reserve_only);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,15 +636,10 @@ AttributeRequest::AttributeRequest(ustring name_)
|
||||
name = name_;
|
||||
std = ATTR_STD_NONE;
|
||||
|
||||
triangle_type = TypeDesc::TypeFloat;
|
||||
triangle_desc.element = ATTR_ELEMENT_NONE;
|
||||
triangle_desc.offset = 0;
|
||||
triangle_desc.type = NODE_ATTR_FLOAT;
|
||||
|
||||
curve_type = TypeDesc::TypeFloat;
|
||||
curve_desc.element = ATTR_ELEMENT_NONE;
|
||||
curve_desc.offset = 0;
|
||||
curve_desc.type = NODE_ATTR_FLOAT;
|
||||
type = TypeDesc::TypeFloat;
|
||||
desc.element = ATTR_ELEMENT_NONE;
|
||||
desc.offset = 0;
|
||||
desc.type = NODE_ATTR_FLOAT;
|
||||
|
||||
subd_type = TypeDesc::TypeFloat;
|
||||
subd_desc.element = ATTR_ELEMENT_NONE;
|
||||
@@ -669,15 +652,10 @@ AttributeRequest::AttributeRequest(AttributeStandard std_)
|
||||
name = ustring();
|
||||
std = std_;
|
||||
|
||||
triangle_type = TypeDesc::TypeFloat;
|
||||
triangle_desc.element = ATTR_ELEMENT_NONE;
|
||||
triangle_desc.offset = 0;
|
||||
triangle_desc.type = NODE_ATTR_FLOAT;
|
||||
|
||||
curve_type = TypeDesc::TypeFloat;
|
||||
curve_desc.element = ATTR_ELEMENT_NONE;
|
||||
curve_desc.offset = 0;
|
||||
curve_desc.type = NODE_ATTR_FLOAT;
|
||||
type = TypeDesc::TypeFloat;
|
||||
desc.element = ATTR_ELEMENT_NONE;
|
||||
desc.offset = 0;
|
||||
desc.type = NODE_ATTR_FLOAT;
|
||||
|
||||
subd_type = TypeDesc::TypeFloat;
|
||||
subd_desc.element = ATTR_ELEMENT_NONE;
|
||||
|
@@ -170,12 +170,11 @@ class Attribute {
|
||||
|
||||
class AttributeSet {
|
||||
public:
|
||||
Mesh *triangle_mesh;
|
||||
Mesh *subd_mesh;
|
||||
Hair *hair;
|
||||
Geometry *geometry;
|
||||
AttributePrimitive prim;
|
||||
list<Attribute> attributes;
|
||||
|
||||
AttributeSet();
|
||||
AttributeSet(Geometry *geometry, AttributePrimitive prim);
|
||||
~AttributeSet();
|
||||
|
||||
Attribute *add(ustring name, TypeDesc type, AttributeElement element);
|
||||
@@ -206,8 +205,8 @@ class AttributeRequest {
|
||||
AttributeStandard std;
|
||||
|
||||
/* temporary variables used by GeometryManager */
|
||||
TypeDesc triangle_type, curve_type, subd_type;
|
||||
AttributeDescriptor triangle_desc, curve_desc, subd_desc;
|
||||
TypeDesc type, subd_type;
|
||||
AttributeDescriptor desc, subd_desc;
|
||||
|
||||
explicit AttributeRequest(ustring name_);
|
||||
explicit AttributeRequest(AttributeStandard std);
|
||||
|
@@ -56,7 +56,8 @@ NODE_ABSTRACT_DEFINE(Geometry)
|
||||
return type;
|
||||
}
|
||||
|
||||
Geometry::Geometry(const NodeType *node_type, const Type type) : Node(node_type), type(type)
|
||||
Geometry::Geometry(const NodeType *node_type, const Type type)
|
||||
: Node(node_type), type(type), attributes(this, ATTR_PRIM_GEOMETRY)
|
||||
{
|
||||
need_update = true;
|
||||
need_update_rebuild = false;
|
||||
@@ -300,9 +301,8 @@ void GeometryManager::update_osl_attributes(Device *device,
|
||||
osl_attr.desc.offset = 0;
|
||||
osl_attr.desc.flags = 0;
|
||||
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_TRIANGLE][attr.name()] = osl_attr;
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_GEOMETRY][attr.name()] = osl_attr;
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_SUBD][attr.name()] = osl_attr;
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_CURVE][attr.name()] = osl_attr;
|
||||
}
|
||||
|
||||
/* find geometry attributes */
|
||||
@@ -318,16 +318,16 @@ void GeometryManager::update_osl_attributes(Device *device,
|
||||
foreach (AttributeRequest &req, attributes.requests) {
|
||||
OSLGlobals::Attribute osl_attr;
|
||||
|
||||
if (req.triangle_desc.element != ATTR_ELEMENT_NONE) {
|
||||
osl_attr.desc = req.triangle_desc;
|
||||
if (req.desc.element != ATTR_ELEMENT_NONE) {
|
||||
osl_attr.desc = req.desc;
|
||||
|
||||
if (req.triangle_type == TypeDesc::TypeFloat)
|
||||
if (req.type == TypeDesc::TypeFloat)
|
||||
osl_attr.type = TypeDesc::TypeFloat;
|
||||
else if (req.triangle_type == TypeDesc::TypeMatrix)
|
||||
else if (req.type == TypeDesc::TypeMatrix)
|
||||
osl_attr.type = TypeDesc::TypeMatrix;
|
||||
else if (req.triangle_type == TypeFloat2)
|
||||
else if (req.type == TypeFloat2)
|
||||
osl_attr.type = TypeFloat2;
|
||||
else if (req.triangle_type == TypeRGBA)
|
||||
else if (req.type == TypeRGBA)
|
||||
osl_attr.type = TypeRGBA;
|
||||
else
|
||||
osl_attr.type = TypeDesc::TypeColor;
|
||||
@@ -335,36 +335,11 @@ void GeometryManager::update_osl_attributes(Device *device,
|
||||
if (req.std != ATTR_STD_NONE) {
|
||||
/* if standard attribute, add lookup by geom: name convention */
|
||||
ustring stdname(string("geom:") + string(Attribute::standard_name(req.std)));
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_TRIANGLE][stdname] = osl_attr;
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_GEOMETRY][stdname] = osl_attr;
|
||||
}
|
||||
else if (req.name != ustring()) {
|
||||
/* add lookup by geometry attribute name */
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_TRIANGLE][req.name] = osl_attr;
|
||||
}
|
||||
}
|
||||
|
||||
if (req.curve_desc.element != ATTR_ELEMENT_NONE) {
|
||||
osl_attr.desc = req.curve_desc;
|
||||
|
||||
if (req.curve_type == TypeDesc::TypeFloat)
|
||||
osl_attr.type = TypeDesc::TypeFloat;
|
||||
else if (req.curve_type == TypeDesc::TypeMatrix)
|
||||
osl_attr.type = TypeDesc::TypeMatrix;
|
||||
else if (req.curve_type == TypeFloat2)
|
||||
osl_attr.type = TypeFloat2;
|
||||
else if (req.curve_type == TypeRGBA)
|
||||
osl_attr.type = TypeRGBA;
|
||||
else
|
||||
osl_attr.type = TypeDesc::TypeColor;
|
||||
|
||||
if (req.std != ATTR_STD_NONE) {
|
||||
/* if standard attribute, add lookup by geom: name convention */
|
||||
ustring stdname(string("geom:") + string(Attribute::standard_name(req.std)));
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_CURVE][stdname] = osl_attr;
|
||||
}
|
||||
else if (req.name != ustring()) {
|
||||
/* add lookup by geometry attribute name */
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_CURVE][req.name] = osl_attr;
|
||||
og->attribute_map[i * ATTR_PRIM_TYPES + ATTR_PRIM_GEOMETRY][req.name] = osl_attr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,27 +415,22 @@ void GeometryManager::update_svm_attributes(Device *,
|
||||
else
|
||||
id = scene->shader_manager->get_attribute_id(req.std);
|
||||
|
||||
if (geom->type == Geometry::MESH) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
if (mesh->num_triangles()) {
|
||||
attr_map[index].x = id;
|
||||
attr_map[index].y = req.triangle_desc.element;
|
||||
attr_map[index].z = as_uint(req.triangle_desc.offset);
|
||||
attr_map[index].x = id;
|
||||
attr_map[index].y = req.desc.element;
|
||||
attr_map[index].z = as_uint(req.desc.offset);
|
||||
|
||||
if (req.triangle_type == TypeDesc::TypeFloat)
|
||||
attr_map[index].w = NODE_ATTR_FLOAT;
|
||||
else if (req.triangle_type == TypeDesc::TypeMatrix)
|
||||
attr_map[index].w = NODE_ATTR_MATRIX;
|
||||
else if (req.triangle_type == TypeFloat2)
|
||||
attr_map[index].w = NODE_ATTR_FLOAT2;
|
||||
else if (req.triangle_type == TypeRGBA)
|
||||
attr_map[index].w = NODE_ATTR_RGBA;
|
||||
else
|
||||
attr_map[index].w = NODE_ATTR_FLOAT3;
|
||||
if (req.type == TypeDesc::TypeFloat)
|
||||
attr_map[index].w = NODE_ATTR_FLOAT;
|
||||
else if (req.type == TypeDesc::TypeMatrix)
|
||||
attr_map[index].w = NODE_ATTR_MATRIX;
|
||||
else if (req.type == TypeFloat2)
|
||||
attr_map[index].w = NODE_ATTR_FLOAT2;
|
||||
else if (req.type == TypeRGBA)
|
||||
attr_map[index].w = NODE_ATTR_RGBA;
|
||||
else
|
||||
attr_map[index].w = NODE_ATTR_FLOAT3;
|
||||
|
||||
attr_map[index].w |= req.triangle_desc.flags << 8;
|
||||
}
|
||||
}
|
||||
attr_map[index].w |= req.desc.flags << 8;
|
||||
|
||||
index++;
|
||||
|
||||
@@ -477,7 +447,7 @@ void GeometryManager::update_svm_attributes(Device *,
|
||||
attr_map[index].w = NODE_ATTR_MATRIX;
|
||||
else if (req.subd_type == TypeFloat2)
|
||||
attr_map[index].w = NODE_ATTR_FLOAT2;
|
||||
else if (req.triangle_type == TypeRGBA)
|
||||
else if (req.subd_type == TypeRGBA)
|
||||
attr_map[index].w = NODE_ATTR_RGBA;
|
||||
else
|
||||
attr_map[index].w = NODE_ATTR_FLOAT3;
|
||||
@@ -487,28 +457,6 @@ void GeometryManager::update_svm_attributes(Device *,
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
if (geom->type == Geometry::HAIR) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
if (hair->num_curves()) {
|
||||
attr_map[index].x = id;
|
||||
attr_map[index].y = req.curve_desc.element;
|
||||
attr_map[index].z = as_uint(req.curve_desc.offset);
|
||||
|
||||
if (req.curve_type == TypeDesc::TypeFloat)
|
||||
attr_map[index].w = NODE_ATTR_FLOAT;
|
||||
else if (req.curve_type == TypeDesc::TypeMatrix)
|
||||
attr_map[index].w = NODE_ATTR_MATRIX;
|
||||
else if (req.curve_type == TypeFloat2)
|
||||
attr_map[index].w = NODE_ATTR_FLOAT2;
|
||||
else
|
||||
attr_map[index].w = NODE_ATTR_FLOAT3;
|
||||
|
||||
attr_map[index].w |= req.curve_desc.flags << 8;
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
/* terminator */
|
||||
@@ -654,13 +602,13 @@ static void update_attribute_element_offset(Geometry *geom,
|
||||
else if (element == ATTR_ELEMENT_VERTEX_MOTION)
|
||||
offset -= mesh->vert_offset;
|
||||
else if (element == ATTR_ELEMENT_FACE) {
|
||||
if (prim == ATTR_PRIM_TRIANGLE)
|
||||
if (prim == ATTR_PRIM_GEOMETRY)
|
||||
offset -= mesh->prim_offset;
|
||||
else
|
||||
offset -= mesh->face_offset;
|
||||
}
|
||||
else if (element == ATTR_ELEMENT_CORNER || element == ATTR_ELEMENT_CORNER_BYTE) {
|
||||
if (prim == ATTR_PRIM_TRIANGLE)
|
||||
if (prim == ATTR_PRIM_GEOMETRY)
|
||||
offset -= 3 * mesh->prim_offset;
|
||||
else
|
||||
offset -= mesh->corner_offset;
|
||||
@@ -720,38 +668,28 @@ void GeometryManager::device_update_attributes(Device *device,
|
||||
Geometry *geom = scene->geometry[i];
|
||||
AttributeRequestSet &attributes = geom_attributes[i];
|
||||
foreach (AttributeRequest &req, attributes.requests) {
|
||||
Attribute *attr = geom->attributes.find(req);
|
||||
|
||||
update_attribute_element_size(geom,
|
||||
attr,
|
||||
ATTR_PRIM_GEOMETRY,
|
||||
&attr_float_size,
|
||||
&attr_float2_size,
|
||||
&attr_float3_size,
|
||||
&attr_uchar4_size);
|
||||
|
||||
if (geom->type == Geometry::MESH) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
Attribute *triangle_mattr = mesh->attributes.find(req);
|
||||
Attribute *subd_mattr = mesh->subd_attributes.find(req);
|
||||
Attribute *subd_attr = mesh->subd_attributes.find(req);
|
||||
|
||||
update_attribute_element_size(mesh,
|
||||
triangle_mattr,
|
||||
ATTR_PRIM_TRIANGLE,
|
||||
&attr_float_size,
|
||||
&attr_float2_size,
|
||||
&attr_float3_size,
|
||||
&attr_uchar4_size);
|
||||
update_attribute_element_size(mesh,
|
||||
subd_mattr,
|
||||
subd_attr,
|
||||
ATTR_PRIM_SUBD,
|
||||
&attr_float_size,
|
||||
&attr_float2_size,
|
||||
&attr_float3_size,
|
||||
&attr_uchar4_size);
|
||||
}
|
||||
else if (geom->type == Geometry::HAIR) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
Attribute *curve_mattr = hair->attributes.find(req);
|
||||
|
||||
update_attribute_element_size(hair,
|
||||
curve_mattr,
|
||||
ATTR_PRIM_CURVE,
|
||||
&attr_float_size,
|
||||
&attr_float2_size,
|
||||
&attr_float3_size,
|
||||
&attr_uchar4_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -773,10 +711,24 @@ void GeometryManager::device_update_attributes(Device *device,
|
||||
/* todo: we now store std and name attributes from requests even if
|
||||
* they actually refer to the same mesh attributes, optimize */
|
||||
foreach (AttributeRequest &req, attributes.requests) {
|
||||
Attribute *attr = geom->attributes.find(req);
|
||||
update_attribute_element_offset(geom,
|
||||
dscene->attributes_float,
|
||||
attr_float_offset,
|
||||
dscene->attributes_float2,
|
||||
attr_float2_offset,
|
||||
dscene->attributes_float3,
|
||||
attr_float3_offset,
|
||||
dscene->attributes_uchar4,
|
||||
attr_uchar4_offset,
|
||||
attr,
|
||||
ATTR_PRIM_GEOMETRY,
|
||||
req.type,
|
||||
req.desc);
|
||||
|
||||
if (geom->type == Geometry::MESH) {
|
||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||
Attribute *triangle_mattr = mesh->attributes.find(req);
|
||||
Attribute *subd_mattr = mesh->subd_attributes.find(req);
|
||||
Attribute *subd_attr = mesh->subd_attributes.find(req);
|
||||
|
||||
update_attribute_element_offset(mesh,
|
||||
dscene->attributes_float,
|
||||
@@ -787,42 +739,11 @@ void GeometryManager::device_update_attributes(Device *device,
|
||||
attr_float3_offset,
|
||||
dscene->attributes_uchar4,
|
||||
attr_uchar4_offset,
|
||||
triangle_mattr,
|
||||
ATTR_PRIM_TRIANGLE,
|
||||
req.triangle_type,
|
||||
req.triangle_desc);
|
||||
update_attribute_element_offset(mesh,
|
||||
dscene->attributes_float,
|
||||
attr_float_offset,
|
||||
dscene->attributes_float2,
|
||||
attr_float2_offset,
|
||||
dscene->attributes_float3,
|
||||
attr_float3_offset,
|
||||
dscene->attributes_uchar4,
|
||||
attr_uchar4_offset,
|
||||
subd_mattr,
|
||||
subd_attr,
|
||||
ATTR_PRIM_SUBD,
|
||||
req.subd_type,
|
||||
req.subd_desc);
|
||||
}
|
||||
else if (geom->type == Geometry::HAIR) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
Attribute *curve_mattr = hair->attributes.find(req);
|
||||
|
||||
update_attribute_element_offset(hair,
|
||||
dscene->attributes_float,
|
||||
attr_float_offset,
|
||||
dscene->attributes_float2,
|
||||
attr_float2_offset,
|
||||
dscene->attributes_float3,
|
||||
attr_float3_offset,
|
||||
dscene->attributes_uchar4,
|
||||
attr_uchar4_offset,
|
||||
curve_mattr,
|
||||
ATTR_PRIM_CURVE,
|
||||
req.curve_type,
|
||||
req.curve_desc);
|
||||
}
|
||||
|
||||
if (progress.get_cancel())
|
||||
return;
|
||||
|
@@ -294,8 +294,6 @@ NODE_DEFINE(Hair)
|
||||
Hair::Hair() : Geometry(node_type, Geometry::HAIR)
|
||||
{
|
||||
curvekey_offset = 0;
|
||||
|
||||
attributes.hair = this;
|
||||
}
|
||||
|
||||
Hair::~Hair()
|
||||
@@ -368,7 +366,7 @@ void Hair::get_uv_tiles(ustring map, unordered_set<int> &tiles)
|
||||
}
|
||||
|
||||
if (attr) {
|
||||
attr->get_uv_tiles(this, ATTR_PRIM_CURVE, tiles);
|
||||
attr->get_uv_tiles(this, ATTR_PRIM_GEOMETRY, tiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -135,7 +135,7 @@ NODE_DEFINE(Mesh)
|
||||
return type;
|
||||
}
|
||||
|
||||
Mesh::Mesh() : Geometry(node_type, Geometry::MESH)
|
||||
Mesh::Mesh() : Geometry(node_type, Geometry::MESH), subd_attributes(this, ATTR_PRIM_SUBD)
|
||||
{
|
||||
vert_offset = 0;
|
||||
|
||||
@@ -145,9 +145,6 @@ Mesh::Mesh() : Geometry(node_type, Geometry::MESH)
|
||||
|
||||
num_subd_verts = 0;
|
||||
|
||||
attributes.triangle_mesh = this;
|
||||
subd_attributes.subd_mesh = this;
|
||||
|
||||
volume_isovalue = 0.001f;
|
||||
|
||||
num_ngons = 0;
|
||||
@@ -329,7 +326,9 @@ void Mesh::get_uv_tiles(ustring map, unordered_set<int> &tiles)
|
||||
}
|
||||
|
||||
if (attr) {
|
||||
attr->get_uv_tiles(this, ATTR_PRIM_TRIANGLE, tiles);
|
||||
attr->get_uv_tiles(this, ATTR_PRIM_GEOMETRY, tiles);
|
||||
}
|
||||
if (subd_attr) {
|
||||
subd_attr->get_uv_tiles(this, ATTR_PRIM_SUBD, tiles);
|
||||
}
|
||||
}
|
||||
@@ -546,8 +545,7 @@ void Mesh::add_undisplaced()
|
||||
float3 *data = attr->data_float3();
|
||||
|
||||
/* copy verts */
|
||||
size_t size = attr->buffer_size(
|
||||
this, (subdivision_type == SUBDIVISION_NONE) ? ATTR_PRIM_TRIANGLE : ATTR_PRIM_SUBD);
|
||||
size_t size = attr->buffer_size(this, attrs.prim);
|
||||
|
||||
/* Center points for ngons aren't stored in Mesh::verts but are included in size since they will
|
||||
* be calculated later, we subtract them from size here so we don't have an overflow while
|
||||
|
Reference in New Issue
Block a user