Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/osl/osl_services.cpp
| Show First 20 Lines • Show All 555 Lines • ▼ Show 20 Lines | static bool set_attribute_matrix(const Transform& tfm, TypeDesc type, void *val) | ||||
| if(type == TypeDesc::TypeMatrix) { | if(type == TypeDesc::TypeMatrix) { | ||||
| copy_matrix(*(OSL::Matrix44*)val, tfm); | copy_matrix(*(OSL::Matrix44*)val, tfm); | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static bool get_mesh_element_attribute(KernelGlobals *kg, const ShaderData *sd, const OSLGlobals::Attribute& attr, | static bool get_primitive_attribute(KernelGlobals *kg, const ShaderData *sd, const OSLGlobals::Attribute& attr, | ||||
| const TypeDesc& type, bool derivatives, void *val) | const TypeDesc& type, bool derivatives, void *val) | ||||
| { | { | ||||
| if(attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector || | if(attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector || | ||||
| attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor) | attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor) | ||||
| { | { | ||||
| float3 fval[3]; | float3 fval[3]; | ||||
| fval[0] = primitive_attribute_float3(kg, sd, attr.desc, | fval[0] = primitive_attribute_float3(kg, sd, attr.desc, | ||||
brecht: Despite the name `get_mesh_element_attribute` this function needs to support volume attributes… | |||||
| (derivatives) ? &fval[1] : NULL, (derivatives) ? &fval[2] : NULL); | (derivatives) ? &fval[1] : NULL, (derivatives) ? &fval[2] : NULL); | ||||
| return set_attribute_float3(fval, type, derivatives, val); | return set_attribute_float3(fval, type, derivatives, val); | ||||
| } | } | ||||
| else if(attr.type == TypeDesc::TypeFloat) { | else if(attr.type == TypeDesc::TypeFloat) { | ||||
| float fval[3]; | float fval[3]; | ||||
| fval[0] = primitive_attribute_float(kg, sd, attr.desc, | fval[0] = primitive_attribute_float(kg, sd, attr.desc, | ||||
| (derivatives) ? &fval[1] : NULL, (derivatives) ? &fval[2] : NULL); | (derivatives) ? &fval[1] : NULL, (derivatives) ? &fval[2] : NULL); | ||||
| return set_attribute_float(fval, type, derivatives, val); | return set_attribute_float(fval, type, derivatives, val); | ||||
| ▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | bool OSLRenderServices::get_attribute(ShaderData *sd, bool derivatives, ustring object_name, | ||||
| OSLGlobals::AttributeMap& attribute_map = kg->osl->attribute_map[object]; | OSLGlobals::AttributeMap& attribute_map = kg->osl->attribute_map[object]; | ||||
| OSLGlobals::AttributeMap::iterator it = attribute_map.find(name); | OSLGlobals::AttributeMap::iterator it = attribute_map.find(name); | ||||
| if(it != attribute_map.end()) { | if(it != attribute_map.end()) { | ||||
| const OSLGlobals::Attribute& attr = it->second; | const OSLGlobals::Attribute& attr = it->second; | ||||
| if(attr.desc.element != ATTR_ELEMENT_OBJECT) { | if(attr.desc.element != ATTR_ELEMENT_OBJECT) { | ||||
| /* triangle and vertex attributes */ | /* triangle and vertex attributes */ | ||||
| if(get_mesh_element_attribute(kg, sd, attr, type, derivatives, val)) | if(get_primitive_attribute(kg, sd, attr, type, derivatives, val)) | ||||
| return true; | return true; | ||||
| else | else | ||||
| return get_mesh_attribute(kg, sd, attr, type, derivatives, val); | return get_mesh_attribute(kg, sd, attr, type, derivatives, val); | ||||
| } | } | ||||
| else { | else { | ||||
| /* object attribute */ | /* object attribute */ | ||||
| get_object_attribute(attr, derivatives, val); | get_object_attribute(attr, derivatives, val); | ||||
| return true; | return true; | ||||
| ▲ Show 20 Lines • Show All 464 Lines • Show Last 20 Lines | |||||
Despite the name get_mesh_element_attribute this function needs to support volume attributes as well.
This function could be renamed to get_primitive_attribute for clarity.