29 type == TypeNormal ||
type == TypeMatrix ||
type == TypeFloat2 ||
type == TypeFloat4 ||
30 type == TypeRGBA ||
type == TypeQuaternion ||
type == TypePackedSphericalHarmonicsRest);
70 static constexpr size_t ATTRIBUTE_BUFFER_PADDING = 4;
71 return element_size *
size + ATTRIBUTE_BUFFER_PADDING;
76 const size_t data_sizeof,
82 image->~ImageHandle();
134 if (num_elements ==
size_t(
size)) {
138 const size_t copy_elems = std::min(num_elements,
size_t(
size));
150 for (
size_t i = 0; i <
motion.size(); i++) {
159 motion = std::move(new_motion);
165 const int motion_steps = geom->get_motion_steps();
166 if (motion_steps <= 0) {
170 const int motion_size = geom->get_motion_steps() - 1;
171 if (motion_size ==
motion.size()) {
176 if (motion_size <
motion.size()) {
177 for (
size_t i = motion_size; i <
motion.size(); i++) {
180 motion.resize(motion_size);
183 motion.reserve(motion_size);
184 while (
motion.size() < motion_size) {
250 memcpy(new_data, buf.
data, element_size *
size);
255 return const_cast<char *
>(
reinterpret_cast<const char *
>(buf.
data));
258char *Attribute::data_for_write_buffer(
const int step)
282 if (
size != other.size ||
motion.size() != other.motion.size()) {
285 motion = std::move(other.motion);
301 const auto step_equals = [&](
const Buffer &a,
const Buffer &
b) {
302 if (a.
data ==
b.data) {
315 if (!step_equals(
center, other.center)) {
318 for (
size_t i = 0; i <
motion.size(); i++) {
319 if (!step_equals(
motion[i], other.motion[i])) {
336 if (
type == TypeFloat) {
337 return sizeof(
float);
339 if (
type == TypeFloat2) {
342 if (
type == TypeMatrix) {
347 if (
type == TypeFloat4) {
350 if (
type == TypeRGBA) {
353 if (
type == TypeQuaternion) {
356 if (
type == TypePackedSphericalHarmonicsRest) {
377 Mesh *mesh =
static_cast<Mesh *
>(geom);
393 Mesh *mesh =
static_cast<Mesh *
>(geom);
406 Mesh *mesh =
static_cast<Mesh *
>(geom);
408 size = mesh->get_subd_face_corners().size();
417 Hair *hair =
static_cast<Hair *
>(geom);
424 Hair *hair =
static_cast<Hair *
>(geom);
447 if (a == TypeColor || a == TypePoint || a == TypeVector || a == TypeNormal) {
448 if (
b == TypeColor ||
b == TypePoint ||
b == TypeVector ||
b == TypeNormal) {
457 if (
type == TypePackedSphericalHarmonicsRest) {
480 return "generated_transform";
484 return "tangent_sign";
486 return "undisplaced_tangent";
488 return "undisplaced_tangent_sign";
490 return "vertex_color";
494 return "undisplaced";
496 return "undisplaced_N";
500 return "curve_intercept";
502 return "curve_length";
504 return "curve_random";
506 return "point_random";
508 return "ptex_face_id";
520 return "temperature";
532 return "random_per_island";
534 return "shadow_transparency";
536 return "radiance:base";
538 return "radiance:sh";
611 if (attr.
type == TypeFloat) {
615 if (attr.
type == TypeFloat2) {
619 if (attr.
type == TypeFloat4 || attr.
type == TypeRGBA || attr.
type == TypeMatrix) {
623 if (attr.
type == TypeQuaternion) {
627 if (attr.
type == TypePackedSphericalHarmonicsRest) {
636 unordered_set<int> &
tiles)
const
638 if (
type != TypeFloat2) {
644 for (
int i = 0; i < num; i++, uv++) {
645 const float u = uv->
x;
646 const float v = uv->
y;
656 if (
x > 0 && (u <
x + 1e-6f)) {
659 if (
y > 0 && (v <
y + 1e-6f)) {
663 tiles.insert(1001 + 10 *
y +
x);
682 if (attr->
type == type && attr->
element == element) {
709 attributes.emplace_back(name, type, element, data, size, sharing_info);
718 if (attr->
type == other.type && attr->
element == other.element) {
719 attr->
std = other.std;
736 if (attr.name == name) {
749 list<Attribute>::iterator it;
846 type = TypePackedSphericalHarmonicsRest;
858 type = TypeQuaternion;
905 else if (geometry->
is_hair()) {
976 TypeDesc type = TypeFloat;
982 attr =
add(name, type, element);
1001 TypeDesc type = TypeFloat;
1007 attr =
add_shared(name, type, element, data, size, sharing_info);
1017 copy_attr.
std = attr.
std;
1027 if (attr.std == std) {
1038 if (attr.name != other.
name) {
1041 if (attr.std != other.
std) {
1044 if (attr.type != other.
type) {
1047 if (attr.element != other.
element) {
1060 list<Attribute>::iterator it;
1073 if (!req.
name.empty()) {
1088 if (req.
name.empty()) {
1126 if (preserve_voxel_data) {
1127 list<Attribute>::iterator it;
1146 list<Attribute>::iterator it;
1149 if (new_attributes.find_matching(old_attr) ==
nullptr) {
1157 for (
Attribute &attr : new_attributes.attributes) {
1175 attr.modified =
false;
1181void AttributeSet::tag_modified(
const Attribute &attr)
1184 modified_flag |= (1u << uint(kernel_type));
1189 return (modified_flag & (1u << uint(kernel_type))) != 0;
1239 for (
size_t i = 0; i <
requests.size(); i++) {
1242 for (
size_t j = 0; j <
requests.size() && !found; j++) {
1270 if (req.std == std) {
1273 req.name = ustring();
1284 if (req.
name.empty()) {
1307 else if (!
find(std)) {
1318 const char *suffixes[] = {
1319 ".tangent_sign",
".tangent",
".undisplaced_tangent",
".undisplaced_tangent_sign"};
1320 for (
const char *suffix : suffixes) {
1322 add(name.substr(0, name.size() - strlen(suffix)));
1331 if (req.name == name) {
1342 if (req.std == std) {
static size_t attribute_alloc_bytes(const size_t element_size, const size_t size)
static bool standard_type_element(const Geometry *geometry, const AttributeStandard std, TypeDesc &type, AttributeElement &element)
static char * buffer_for_write(Attribute::Buffer &buf, const size_t element_size, const size_t size)
static void free_step_buffer(Attribute::Buffer &buf, const AttributeElement element, const size_t data_sizeof, const size_t size)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
vector< AttributeRequest > requests
bool find(ustring name) const
void add_name_or_standard(ustring name)
bool modified(const AttributeRequestSet &other) const
AttributeRequest(ustring name_)
void update(AttributeSet &&new_attributes)
Attribute & copy(const Attribute &attr)
list< Attribute > attributes
Attribute * find(ustring name) const
Attribute * find_matching(const Attribute &other)
bool modified(AttrKernelDataType kernel_type) const
Attribute * add(ustring name, const TypeDesc type, AttributeElement element)
void remove(ustring name)
AttributeSet(Geometry *geometry, AttributePrimitive prim)
void clear(bool preserve_voxel_data=false)
Attribute * add_shared(ustring name, const TypeDesc type, AttributeElement element, const void *data, int size, ImplicitSharingInfo sharing_info)
Attribute * add_from(Attribute &&other)
static AttributeStandard name_standard(ustring name)
Attribute(ustring name, const TypeDesc type, AttributeElement element, Geometry *geom, AttributePrimitive prim)
void take_motion_from(Attribute &other)
const T * data(const int step=0) const
void resize(Geometry *geom, AttributePrimitive prim)
static AttrKernelDataType kernel_type(const Attribute &attr)
void set_motion_step_shared(int step, const void *data, int new_size, ImplicitSharingInfo sharing_info)
static size_t element_size(Geometry *geom, AttributeElement element, AttributePrimitive prim)
static ustring osl_name(AttributeStandard std)
static AttributeStandard name_volume_standard(ustring name)
void add_motion(const Geometry *geom)
void get_uv_tiles(Geometry *geom, AttributePrimitive prim, unordered_set< int > &tiles) const
void set_data_from(Attribute &&other)
void zero_data(void *dst)
static const char * standard_name(AttributeStandard std)
size_t buffer_size(Geometry *geom, AttributePrimitive prim) const
size_t data_sizeof() const
static bool same_storage(const TypeDesc a, const TypeDesc b)
bool matches_standard(const Geometry *geometry, AttributeStandard std) const
bool is_pointcloud() const
T * allocate(const size_t n, const void *hint=nullptr)
GuardedAllocator()=default
void deallocate(T *p, const size_t n)
size_t num_curves() const
size_t get_num_subd_faces() const
size_t get_num_subd_base_verts() const
NODE_DECLARE size_t num_verts() const
size_t num_triangles() const
size_t num_points() const
#define CCL_NAMESPACE_END
#define assert(assertion)
#define image(slot, qualifiers, format)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
const void * ImplicitSharingInfo
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
@ ATTR_ELEMENT_VERTEX_NORMAL
@ ATTR_ELEMENT_CORNER_BYTE
@ ATTR_ELEMENT_CORNER_NORMAL
@ ATTR_ELEMENT_CURVE_KEY_NORMAL
@ ATTR_STD_CURVE_INTERCEPT
@ ATTR_STD_GENERATED_TRANSFORM
@ ATTR_STD_VOLUME_VELOCITY_Y
@ ATTR_STD_VOLUME_TEMPERATURE
@ ATTR_STD_VOLUME_VELOCITY_Z
@ ATTR_STD_VOLUME_DENSITY
@ ATTR_STD_POSITION_UNDISPLACED
@ ATTR_STD_GSPLAT_RADIANCE_BASE
@ ATTR_STD_VOLUME_VELOCITY
@ ATTR_STD_POSITION_UNDEFORMED
@ ATTR_STD_NORMAL_UNDISPLACED
@ ATTR_STD_UV_TANGENT_SIGN
@ ATTR_STD_GSPLAT_ROTATION
@ ATTR_STD_UV_TANGENT_SIGN_UNDISPLACED
@ ATTR_STD_SHADOW_TRANSPARENCY
@ ATTR_STD_UV_TANGENT_UNDISPLACED
@ ATTR_STD_GSPLAT_RADIANCE
@ ATTR_STD_GSPLAT_RADIANCE_SPHERICAL_HARMONICS_REST
@ ATTR_STD_VOLUME_VELOCITY_X
@ ATTR_STD_RANDOM_PER_ISLAND
@ SPHERICAL_HARMONICS_REST
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bool string_endswith(const string_view s, const string_view end)
ImplicitSharingInfo sharing_info
ccl_device_forceinline void spherical_harmonics_rest_fill_zero(ccl_global PackedSphericalHarmonicsRest &packed_spherical_harmonics_rest)
ImplicitSharingUserAddFn g_implicit_sharing_user_remove_fn
CCL_NAMESPACE_BEGIN ImplicitSharingUserAddFn g_implicit_sharing_user_add_fn