21 : name(name), std(
ATTR_STD_NONE), type(type), element(element), flags(0), modified(
true)
24 assert(type == TypeDesc::TypeFloat || type == TypeDesc::TypeColor ||
25 type == TypeDesc::TypePoint || type == TypeDesc::TypeVector ||
26 type == TypeDesc::TypeNormal || type == TypeDesc::TypeMatrix || type ==
TypeFloat2 ||
27 type == TypeFloat4 || type ==
TypeRGBA);
43 handle.~ImageHandle();
70 char *data = (
char *)&f;
71 size_t size =
sizeof(f);
73 for (
size_t i = 0; i <
size; i++) {
84 char *data = (
char *)&f;
85 size_t size =
sizeof(f);
87 for (
size_t i = 0; i <
size; i++) {
98 char *data = (
char *)&f;
99 size_t size =
sizeof(f);
101 for (
size_t i = 0; i <
size; i++) {
102 buffer.push_back(data[i]);
112 char *data = (
char *)&f;
113 size_t size =
sizeof(f);
115 for (
size_t i = 0; i <
size; i++) {
116 buffer.push_back(data[i]);
126 char *data = (
char *)&f;
127 size_t size =
sizeof(f);
129 for (
size_t i = 0; i <
size; i++) {
130 buffer.push_back(data[i]);
140 for (
size_t i = 0; i <
size; i++) {
141 buffer.push_back(data[i]);
149 assert(other.std ==
std);
150 assert(other.type == type);
151 assert(other.element == element);
153 this->
flags = other.flags;
155 if (this->
buffer.size() != other.buffer.size()) {
156 this->
buffer = std::move(other.buffer);
159 else if (memcmp(this->
data(), other.data(), other.buffer.size()) != 0) {
160 this->
buffer = std::move(other.buffer);
173 else if (type == TypeDesc::TypeFloat) {
174 return sizeof(
float);
179 else if (type == TypeDesc::TypeMatrix) {
184 else if (type == TypeDesc::TypeFloat4) {
185 return sizeof(float4);
188 return sizeof(float4);
211 Mesh *mesh =
static_cast<Mesh *
>(geom);
212 size = mesh->get_verts().size() + mesh->get_num_ngons();
224 Mesh *mesh =
static_cast<Mesh *
>(geom);
226 size = (mesh->get_verts().size() + mesh->get_num_ngons()) * (mesh->get_motion_steps() - 1);
228 size -= mesh->get_num_subd_verts() * (mesh->get_motion_steps() - 1);
233 size = pointcloud->
num_points() * (pointcloud->get_motion_steps() - 1);
238 Mesh *mesh =
static_cast<Mesh *
>(geom);
243 size = mesh->get_num_subd_faces() + mesh->get_num_ngons();
250 Mesh *mesh =
static_cast<Mesh *
>(geom);
255 size = mesh->get_subd_face_corners().size() + mesh->get_num_ngons();
261 Hair *hair =
static_cast<Hair *
>(geom);
267 Hair *hair =
static_cast<Hair *
>(geom);
268 size = hair->get_curve_keys().size();
273 Hair *hair =
static_cast<Hair *
>(geom);
275 size = hair->get_curve_keys().size() * (hair->get_motion_steps() - 1);
296 if (a == TypeDesc::TypeColor || a == TypeDesc::TypePoint || a == TypeDesc::TypeVector ||
297 a == TypeDesc::TypeNormal)
299 if (
b == TypeDesc::TypeColor ||
b == TypeDesc::TypePoint ||
b == TypeDesc::TypeVector ||
300 b == TypeDesc::TypeNormal)
316 for (
int i = 0; i < 4; i++) {
321 *((
float *)dst) += *((
float *)src) * weight;
331 assert(!
"not implemented for this type");
347 return "generated_transform";
351 return "tangent_sign";
353 return "vertex_color";
357 return "undisplaced";
365 return "curve_intercept";
367 return "curve_length";
369 return "curve_random";
371 return "point_random";
373 return "ptex_face_id";
385 return "temperature";
397 return "random_per_island";
399 return "shadow_transparency";
428 if (attr.
type == TypeDesc::TypeFloat) {
445 unordered_set<int> &
tiles)
const
453 for (
int i = 0; i < num; i++, uv++) {
454 float u = uv->
x,
v = uv->
y;
455 int x = (
int)u, y = (
int)
v;
463 if (x > 0 && (u < x + 1e-6f)) {
466 if (y > 0 && (
v < y + 1e-6f)) {
470 tiles.insert(1001 + 10 * y + x);
477 : modified_flag(~0u), geometry(geometry), prim(prim)
489 if (attr->
type == type && attr->
element == element) {
498 attributes.emplace_back(std::move(new_attr));
499 tag_modified(attributes.back());
500 return &attributes.back();
505 foreach (
const Attribute &attr, attributes)
506 if (attr.
name == name) {
518 list<Attribute>::iterator it;
520 for (it = attributes.begin(); it != attributes.end(); it++) {
533 if (name == ustring()) {
686 foreach (
const Attribute &attr, attributes)
687 if (attr.
std == std) {
697 if (attr.name != other.name) {
700 if (attr.std != other.std) {
703 if (attr.type != other.type) {
706 if (attr.element != other.element) {
719 list<Attribute>::iterator it;
721 for (it = attributes.begin(); it != attributes.end(); it++) {
753 attributes.erase(it);
765 if (preserve_voxel_data) {
766 list<Attribute>::iterator it;
768 for (it = attributes.begin(); it != attributes.end();) {
773 attributes.erase(it++);
785 list<Attribute>::iterator it;
786 for (it = attributes.begin(); it != attributes.end();) {
788 if (new_attributes.find_matching(old_attr) ==
nullptr) {
796 foreach (
Attribute &attr, new_attributes.attributes) {
803 geometry->transform_applied =
false;
815void AttributeSet::tag_modified(
const Attribute &attr)
823 if (modifies_device_array) {
825 modified_flag |= (1u << kernel_type);
831 return (modified_flag & (1u << kernel_type)) != 0;
841 type = TypeDesc::TypeFloat;
857 type = TypeDesc::TypeFloat;
876 if (
requests.size() != other.requests.size()) {
880 for (
size_t i = 0; i <
requests.size(); i++) {
883 for (
size_t j = 0; j <
requests.size() && !found; j++) {
884 if (
requests[i].name == other.requests[j].name &&
requests[i].std == other.requests[j].std) {
900 if (req.
name == name) {
911 if (req.
std == std) {
949 if (req.
name == name) {
959 if (req.
std == std) {
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
vector< AttributeRequest > requests
bool modified(const AttributeRequestSet &other)
void add_standard(ustring name)
AttributeRequest(ustring name_)
AttributeDescriptor subd_desc
Attribute * add(ustring name, TypeDesc type, AttributeElement element)
void update(AttributeSet &&new_attributes)
list< Attribute > attributes
Attribute * find(ustring name) const
Attribute * find_matching(const Attribute &other)
bool modified(AttrKernelDataType kernel_type) const
void remove(ustring name)
AttributeSet(Geometry *geometry, AttributePrimitive prim)
void resize(bool reserve_only=false)
void clear(bool preserve_voxel_data=false)
static bool same_storage(TypeDesc a, TypeDesc b)
void add_with_weight(void *dst, void *src, float weight)
static AttrKernelDataType kernel_type(const Attribute &attr)
static AttributeStandard name_standard(const char *name)
void resize(Geometry *geom, AttributePrimitive prim, bool reserve_only)
size_t element_size(Geometry *geom, AttributePrimitive prim) const
void get_uv_tiles(Geometry *geom, AttributePrimitive prim, unordered_set< int > &tiles) const
void set_data_from(Attribute &&other)
void zero_data(void *dst)
Attribute(ustring name, TypeDesc type, AttributeElement element, Geometry *geom, AttributePrimitive prim)
static const char * standard_name(AttributeStandard std)
size_t buffer_size(Geometry *geom, AttributePrimitive prim) const
ImageHandle & data_voxel()
size_t data_sizeof() const
size_t num_curves() const
local_group_size(16, 16) .push_constant(Type b
#define CCL_NAMESPACE_END
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
@ ATTR_STD_CURVE_INTERCEPT
@ ATTR_STD_GENERATED_TRANSFORM
@ ATTR_STD_MOTION_VERTEX_NORMAL
@ ATTR_STD_VOLUME_VELOCITY_Y
@ ATTR_STD_VOLUME_TEMPERATURE
@ ATTR_STD_VOLUME_VELOCITY_Z
@ ATTR_STD_VOLUME_DENSITY
@ ATTR_STD_POSITION_UNDISPLACED
@ ATTR_STD_VOLUME_VELOCITY
@ ATTR_STD_POSITION_UNDEFORMED
@ ATTR_STD_MOTION_VERTEX_POSITION
@ ATTR_STD_UV_TANGENT_SIGN
@ ATTR_STD_SHADOW_TRANSPARENCY
@ ATTR_STD_VOLUME_VELOCITY_X
@ ATTR_STD_RANDOM_PER_ISLAND
@ ATTR_ELEMENT_CORNER_BYTE
@ ATTR_ELEMENT_CURVE_KEY_MOTION
@ ATTR_ELEMENT_VERTEX_MOTION
static constexpr TypeDesc TypeRGBA(TypeDesc::FLOAT, TypeDesc::VEC4, TypeDesc::COLOR)
CCL_NAMESPACE_BEGIN static OIIO_NAMESPACE_USING constexpr TypeDesc TypeFloat2(TypeDesc::FLOAT, TypeDesc::VEC2)
size_t num_triangles() const
size_t get_num_subd_verts()
size_t num_points() const