103 if (type == TypeFloat) {
106 else if (type == TypeMatrix) {
109 else if (type == TypeFloat2) {
112 else if (type == TypeFloat4) {
115 else if (type == TypeRGBA) {
118 else if (type == TypeQuaternion) {
121 else if (type == TypePackedSphericalHarmonicsRest) {
134 const uint chain_link)
139 attr_map[
index + j].
offset = chain ? chain_link + j : 0;
164 size_t attr_map_size = 0;
170 size_t attr_count = 0;
184 attr_count = geom_attributes[i].size();
190 for (
size_t i = 0; i < scene->
objects.
size(); i++) {
194 if (object_attributes[i].size() == 0) {
195 object->attr_map_offset = 0;
198 object->attr_map_offset = attr_map_size;
203 if (attr_map_size == 0) {
247 for (
size_t i = 0; i < scene->
objects.
size(); i++) {
252 if (attributes.
size() > 0) {
253 size_t index =
object->attr_map_offset;
287 template<
typename U>
size_t add(
const U *attr_data,
const size_t attr_size,
const bool modified)
290 size_t start_offset =
offset;
292 for (
size_t k = 0; k < attr_size; k++) {
344 if (mattr ==
nullptr) {
368 const int num_motion = mattr->
motion.size();
371 int &offset = desc.
offset;
390 else if (mattr->
type == TypeFloat) {
396 else if (mattr->
type == TypeFloat2) {
402 else if (mattr->
type == TypeMatrix) {
410 else if (mattr->
type == TypeQuaternion) {
416 else if (mattr->
type == TypePackedSphericalHarmonicsRest) {
424 else if (mattr->
type == TypeFloat4 || mattr->
type == TypeRGBA) {
442 Mesh *mesh =
static_cast<Mesh *
>(geom);
451 Hair *hair =
static_cast<Hair *
>(geom);
465 if (mattr ==
nullptr) {
483 else if (mattr->
type == TypeFloat) {
486 else if (mattr->
type == TypeFloat2) {
489 else if (mattr->
type == TypeMatrix) {
492 else if (mattr->
type == TypeFloat4 || mattr->
type == TypeRGBA) {
495 else if (mattr->
type == TypeQuaternion) {
498 else if (mattr->
type == TypePackedSphericalHarmonicsRest) {
515 const size_t base_size = attr_P->
size;
516 const int steps = attr_P->
has_motion() ? geom->get_motion_steps() : 1;
517 const size_t total_size = base_size * steps;
522 const float *
R = attr_R->
data<
float>(
step);
523 const size_t dst_offset = size_t(
step) * base_size;
524 for (
size_t i = 0; i < base_size; i++) {
532 int &offset = desc.
offset;
535 offset = table.
add(combined.data(), total_size, modified);
545 const int steps = attr_P->
has_motion() ? geom->get_motion_steps() : 1;
546 const size_t total_size = attr_P->
size * steps;
587 progress.
set_status(
"Updating Mesh",
"Computing attributes");
600 geom_attributes[i].add(global_attributes);
602 for (
Node *
node : geom->get_used_shaders()) {
613 geom_attributes[i].add(attr.
std);
626 geom_attributes[i].add(attr.
std);
639 object_attribute_values.reserve(scene->
objects.
size());
641 for (
size_t i = 0; i < scene->
objects.
size(); i++) {
644 const size_t geom_idx = geom->
index;
646 assert(geom_idx < scene->geometry.size() && scene->
geometry[geom_idx] == geom);
654 for (
size_t j = 0; j <
object->attributes.size(); j++) {
655 const ParamValue ¶m =
object->attributes[j];
659 attributes.
add(param.name());
680 unordered_set<const Attribute *> reserved;
683 if (attr && !reserved.insert(attr).second) {
701 for (
size_t i = 0; i < scene->
objects.
size(); i++) {
704 for (
Attribute &attr : object_attribute_values[i].attributes) {
728 unordered_map<const Attribute *, const AttributeRequest *> added;
734 const auto it = added.find(attr);
735 if (it != added.end()) {
737 req.
type = it->second->type;
738 req.
desc = it->second->desc;
755 for (
size_t i = 0; i < scene->
objects.
size(); i++) {
760 unordered_map<const Attribute *, const AttributeRequest *> added;
766 const auto it = added.find(attr);
767 if (it != added.end()) {
769 req.
type = it->second->type;
770 req.
desc = it->second->desc;
798 progress.
set_status(
"Updating Mesh",
"Copying Attributes to device");
808 scene->
object_manager->device_update_geom_offsets(device, dscene, scene);
unsigned long long int uint64_t
vector< AttributeRequest > requests
bool find(ustring name) const
list< Attribute > attributes
Attribute * find(ustring name) const
Attribute * add(ustring name, const TypeDesc type, AttributeElement element)
AttributeSet(Geometry *geometry, AttributePrimitive prim)
void add(Geometry *geom, Attribute *mattr, AttributePrimitive prim, TypeDesc &type, AttributeDescriptor &desc)
AttributeTableEntry< packed_float3 > attr_float3
AttributeTableEntry< Quaternion > attr_quaternion
AttributeTableEntry< float2 > attr_float2
void copy_to_device_if_modified()
AttributeTableEntry< float4 > curve_keys
AttributeTableEntry< float4 > points
AttributeTableBuilder(DeviceScene *dscene)
AttributeTableEntry< packed_float3 > tri_verts
void reserve_position_radius(Geometry *geom, Attribute *attr_P)
void reserve(Geometry *geom, Attribute *mattr, AttributePrimitive prim)
AttributeTableEntry< PackedSphericalHarmonicsRest > attr_spherical_harmonics_rest
AttributeTableEntry< packed_normal > attr_normal
AttributeTableEntry< uchar4 > attr_uchar4
AttributeTableEntry< float > attr_float
void add_position_radius(Geometry *geom, Attribute *attr_P, TypeDesc &type, AttributeDescriptor &desc)
AttributeTableEntry< float4 > attr_float4
const T * data(const int step=0) const
static AttrKernelDataType kernel_type(const Attribute &attr)
T * data_for_write(const int step=0)
static size_t element_size(Geometry *geom, AttributeElement element, AttributePrimitive prim)
const ImageHandle & data_voxel() const
int num_motion_steps() const
device_vector< float4 > attributes_float4
device_vector< float2 > attributes_float2
device_vector< packed_normal > attributes_normal
device_vector< AttributeMap > attributes_map
device_vector< packed_float3 > attributes_float3
device_vector< Quaternion > attributes_quaternion
device_vector< float > attributes_float
device_vector< PackedSphericalHarmonicsRest > attributes_spherical_harmonics_rest
device_vector< uchar4 > attributes_uchar4
void device_update_attributes(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void update_osl_globals(Device *device, Scene *scene)
void update_svm_attributes(Device *device, DeviceScene *dscene, Scene *scene, vector< AttributeRequestSet > &geom_attributes, vector< AttributeRequestSet > &object_attributes)
bool has_voxel_attributes() const
bool is_pointcloud() const
AttributeRequestSet needed_attributes()
bool need_attribute(const Scene *scene, AttributeStandard std)
void set_status(const string &status_, const string &substatus_="")
unique_ptr< ObjectManager > object_manager
bool need_global_attribute(AttributeStandard std) const
void need_global_attributes(AttributeRequestSet &attributes)
unique_ptr_vector< Geometry > geometry
unique_ptr_vector< Shader > shaders
unique_ptr< ShaderManager > shader_manager
unique_ptr_vector< Object > objects
AttributeRequestSet global_attributes
AttributeRequestSet attributes
T * alloc(const size_t width, const size_t height=0)
#define CCL_NAMESPACE_END
static void emit_attribute_mapping(AttributeMap *attr_map, const size_t index, const uint64_t id, AttributeRequest &req)
static void emit_attribute_map_terminator(AttributeMap *attr_map, const size_t index, const bool chain, const uint chain_link)
static void emit_attribute_map_entry(AttributeMap *attr_map, const size_t index, const uint64_t id, const TypeDesc type, const AttributeDescriptor &desc)
#define assert(assertion)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
@ NODE_ATTR_SPHERICAL_HARMONICS_REST
@ ATTR_STD_GSPLAT_RADIANCE_BASE
@ ATTR_STD_GSPLAT_ROTATION
@ ATTR_STD_SHADOW_TRANSPARENCY
@ ATTR_STD_GSPLAT_RADIANCE_SPHERICAL_HARMONICS_REST
size_t add(const U *attr_data, const size_t attr_size, const bool modified)
void reserve(const size_t attr_size)
device_vector< T > & data
Node(const NodeType *type, ustring name=ustring())