Blender  V2.93
attribute.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "render/attribute.h"
18 #include "render/hair.h"
19 #include "render/image.h"
20 #include "render/mesh.h"
21 
22 #include "util/util_foreach.h"
23 #include "util/util_transform.h"
24 
26 
27 /* Attribute */
28 
30  ustring name, TypeDesc type, AttributeElement element, Geometry *geom, AttributePrimitive prim)
31  : name(name), std(ATTR_STD_NONE), type(type), element(element), flags(0), modified(true)
32 {
33  /* string and matrix not supported! */
34  assert(type == TypeDesc::TypeFloat || type == TypeDesc::TypeColor ||
35  type == TypeDesc::TypePoint || type == TypeDesc::TypeVector ||
36  type == TypeDesc::TypeNormal || type == TypeDesc::TypeMatrix || type == TypeFloat2 ||
37  type == TypeFloat4 || type == TypeRGBA);
38 
39  if (element == ATTR_ELEMENT_VOXEL) {
40  buffer.resize(sizeof(ImageHandle));
41  new (buffer.data()) ImageHandle();
42  }
43  else {
44  resize(geom, prim, false);
45  }
46 }
47 
49 {
50  /* For voxel data, we need to free the image handle. */
51  if (element == ATTR_ELEMENT_VOXEL && buffer.size()) {
52  ImageHandle &handle = data_voxel();
53  handle.~ImageHandle();
54  }
55 }
56 
57 void Attribute::resize(Geometry *geom, AttributePrimitive prim, bool reserve_only)
58 {
59  if (element != ATTR_ELEMENT_VOXEL) {
60  if (reserve_only) {
61  buffer.reserve(buffer_size(geom, prim));
62  }
63  else {
64  buffer.resize(buffer_size(geom, prim), 0);
65  }
66  }
67 }
68 
69 void Attribute::resize(size_t num_elements)
70 {
71  if (element != ATTR_ELEMENT_VOXEL) {
72  buffer.resize(num_elements * data_sizeof(), 0);
73  }
74 }
75 
76 void Attribute::add(const float &f)
77 {
78  assert(data_sizeof() == sizeof(float));
79 
80  char *data = (char *)&f;
81  size_t size = sizeof(f);
82 
83  for (size_t i = 0; i < size; i++)
84  buffer.push_back(data[i]);
85 
86  modified = true;
87 }
88 
89 void Attribute::add(const uchar4 &f)
90 {
91  assert(data_sizeof() == sizeof(uchar4));
92 
93  char *data = (char *)&f;
94  size_t size = sizeof(f);
95 
96  for (size_t i = 0; i < size; i++)
97  buffer.push_back(data[i]);
98 
99  modified = true;
100 }
101 
102 void Attribute::add(const float2 &f)
103 {
104  assert(data_sizeof() == sizeof(float2));
105 
106  char *data = (char *)&f;
107  size_t size = sizeof(f);
108 
109  for (size_t i = 0; i < size; i++)
110  buffer.push_back(data[i]);
111 
112  modified = true;
113 }
114 
115 void Attribute::add(const float3 &f)
116 {
117  assert(data_sizeof() == sizeof(float3));
118 
119  char *data = (char *)&f;
120  size_t size = sizeof(f);
121 
122  for (size_t i = 0; i < size; i++)
123  buffer.push_back(data[i]);
124 
125  modified = true;
126 }
127 
128 void Attribute::add(const Transform &f)
129 {
130  assert(data_sizeof() == sizeof(Transform));
131 
132  char *data = (char *)&f;
133  size_t size = sizeof(f);
134 
135  for (size_t i = 0; i < size; i++)
136  buffer.push_back(data[i]);
137 
138  modified = true;
139 }
140 
141 void Attribute::add(const char *data)
142 {
143  size_t size = data_sizeof();
144 
145  for (size_t i = 0; i < size; i++)
146  buffer.push_back(data[i]);
147 
148  modified = true;
149 }
150 
152 {
153  assert(other.std == std);
154  assert(other.type == type);
155  assert(other.element == element);
156 
157  this->flags = other.flags;
158 
159  if (this->buffer.size() != other.buffer.size()) {
160  this->buffer = std::move(other.buffer);
161  modified = true;
162  }
163  else if (memcmp(this->data(), other.data(), other.buffer.size()) != 0) {
164  this->buffer = std::move(other.buffer);
165  modified = true;
166  }
167 }
168 
170 {
172  return sizeof(ImageHandle);
173  else if (element == ATTR_ELEMENT_CORNER_BYTE)
174  return sizeof(uchar4);
175  else if (type == TypeDesc::TypeFloat)
176  return sizeof(float);
177  else if (type == TypeFloat2)
178  return sizeof(float2);
179  else if (type == TypeDesc::TypeMatrix)
180  return sizeof(Transform);
181  else
182  return sizeof(float3);
183 }
184 
186 {
187  if (flags & ATTR_FINAL_SIZE) {
188  return buffer.size() / data_sizeof();
189  }
190 
191  size_t size = 0;
192 
193  switch (element) {
194  case ATTR_ELEMENT_OBJECT:
195  case ATTR_ELEMENT_MESH:
196  case ATTR_ELEMENT_VOXEL:
197  size = 1;
198  break;
199  case ATTR_ELEMENT_VERTEX:
200  if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
201  Mesh *mesh = static_cast<Mesh *>(geom);
202  size = mesh->get_verts().size() + mesh->get_num_ngons();
203  if (prim == ATTR_PRIM_SUBD) {
205  }
206  }
207  break;
209  if (geom->geometry_type == Geometry::MESH) {
210  Mesh *mesh = static_cast<Mesh *>(geom);
211  size = (mesh->get_verts().size() + mesh->get_num_ngons()) * (mesh->get_motion_steps() - 1);
212  if (prim == ATTR_PRIM_SUBD) {
213  size -= mesh->get_num_subd_verts() * (mesh->get_motion_steps() - 1);
214  }
215  }
216  break;
217  case ATTR_ELEMENT_FACE:
218  if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) {
219  Mesh *mesh = static_cast<Mesh *>(geom);
220  if (prim == ATTR_PRIM_GEOMETRY) {
221  size = mesh->num_triangles();
222  }
223  else {
224  size = mesh->get_num_subd_faces() + mesh->get_num_ngons();
225  }
226  }
227  break;
228  case ATTR_ELEMENT_CORNER:
230  if (geom->geometry_type == Geometry::MESH) {
231  Mesh *mesh = static_cast<Mesh *>(geom);
232  if (prim == ATTR_PRIM_GEOMETRY) {
233  size = mesh->num_triangles() * 3;
234  }
235  else {
236  size = mesh->get_subd_face_corners().size() + mesh->get_num_ngons();
237  }
238  }
239  break;
240  case ATTR_ELEMENT_CURVE:
241  if (geom->geometry_type == Geometry::HAIR) {
242  Hair *hair = static_cast<Hair *>(geom);
243  size = hair->num_curves();
244  }
245  break;
247  if (geom->geometry_type == Geometry::HAIR) {
248  Hair *hair = static_cast<Hair *>(geom);
249  size = hair->get_curve_keys().size();
250  }
251  break;
253  if (geom->geometry_type == Geometry::HAIR) {
254  Hair *hair = static_cast<Hair *>(geom);
255  size = hair->get_curve_keys().size() * (hair->get_motion_steps() - 1);
256  }
257  break;
258  default:
259  break;
260  }
261 
262  return size;
263 }
264 
266 {
267  return element_size(geom, prim) * data_sizeof();
268 }
269 
270 bool Attribute::same_storage(TypeDesc a, TypeDesc b)
271 {
272  if (a == b)
273  return true;
274 
275  if (a == TypeDesc::TypeColor || a == TypeDesc::TypePoint || a == TypeDesc::TypeVector ||
276  a == TypeDesc::TypeNormal) {
277  if (b == TypeDesc::TypeColor || b == TypeDesc::TypePoint || b == TypeDesc::TypeVector ||
278  b == TypeDesc::TypeNormal) {
279  return true;
280  }
281  }
282  return false;
283 }
284 
285 void Attribute::zero_data(void *dst)
286 {
287  memset(dst, 0, data_sizeof());
288 }
289 
290 void Attribute::add_with_weight(void *dst, void *src, float weight)
291 {
293  for (int i = 0; i < 4; i++) {
294  ((uchar *)dst)[i] += uchar(((uchar *)src)[i] * weight);
295  }
296  }
297  else if (same_storage(type, TypeDesc::TypeFloat)) {
298  *((float *)dst) += *((float *)src) * weight;
299  }
300  else if (same_storage(type, TypeFloat2)) {
301  *((float2 *)dst) += *((float2 *)src) * weight;
302  }
303  else if (same_storage(type, TypeDesc::TypeVector)) {
304  *((float4 *)dst) += *((float4 *)src) * weight;
305  }
306  else {
307  assert(!"not implemented for this type");
308  }
309 }
310 
312 {
313  switch (std) {
315  return "N";
317  return "Ng";
318  case ATTR_STD_UV:
319  return "uv";
320  case ATTR_STD_GENERATED:
321  return "generated";
323  return "generated_transform";
324  case ATTR_STD_UV_TANGENT:
325  return "tangent";
327  return "tangent_sign";
329  return "vertex_color";
331  return "undeformed";
333  return "undisplaced";
335  return "motion_P";
337  return "motion_N";
338  case ATTR_STD_PARTICLE:
339  return "particle";
341  return "curve_intercept";
343  return "curve_random";
345  return "ptex_face_id";
346  case ATTR_STD_PTEX_UV:
347  return "ptex_uv";
349  return "density";
351  return "color";
353  return "flame";
355  return "heat";
357  return "temperature";
359  return "velocity";
360  case ATTR_STD_POINTINESS:
361  return "pointiness";
363  return "random_per_island";
364  case ATTR_STD_NOT_FOUND:
365  case ATTR_STD_NONE:
366  case ATTR_STD_NUM:
367  return "";
368  }
369 
370  return "";
371 }
372 
374 {
375  if (name) {
376  for (int std = ATTR_STD_NONE; std < ATTR_STD_NUM; std++) {
377  if (strcmp(name, Attribute::standard_name((AttributeStandard)std)) == 0) {
378  return (AttributeStandard)std;
379  }
380  }
381  }
382 
383  return ATTR_STD_NONE;
384 }
385 
387  AttributePrimitive prim,
388  unordered_set<int> &tiles) const
389 {
390  if (type != TypeFloat2) {
391  return;
392  }
393 
394  const int num = element_size(geom, prim);
395  const float2 *uv = data_float2();
396  for (int i = 0; i < num; i++, uv++) {
397  float u = uv->x, v = uv->y;
398  int x = (int)u, y = (int)v;
399 
400  if (x < 0 || y < 0 || x >= 10) {
401  continue;
402  }
403 
404  /* Be conservative in corners - precisely touching the right or upper edge of a tile
405  * should not load its right/upper neighbor as well. */
406  if (x > 0 && (u < x + 1e-6f)) {
407  x--;
408  }
409  if (y > 0 && (v < y + 1e-6f)) {
410  y--;
411  }
412 
413  tiles.insert(1001 + 10 * y + x);
414  }
415 }
416 
417 /* Attribute Set */
418 
420  : geometry(geometry), prim(prim)
421 {
422 }
423 
425 {
426 }
427 
429 {
430  Attribute *attr = find(name);
431 
432  if (attr) {
433  /* return if same already exists */
434  if (attr->type == type && attr->element == element)
435  return attr;
436 
437  /* overwrite attribute with same name but different type/element */
438  remove(name);
439  }
440 
441  Attribute new_attr(name, type, element, geometry, prim);
442  attributes.emplace_back(std::move(new_attr));
443  modified = true;
444  return &attributes.back();
445 }
446 
447 Attribute *AttributeSet::find(ustring name) const
448 {
449  foreach (const Attribute &attr, attributes)
450  if (attr.name == name)
451  return (Attribute *)&attr;
452 
453  return NULL;
454 }
455 
456 void AttributeSet::remove(ustring name)
457 {
458  Attribute *attr = find(name);
459 
460  if (attr) {
461  list<Attribute>::iterator it;
462 
463  for (it = attributes.begin(); it != attributes.end(); it++) {
464  if (&*it == attr) {
465  modified = true;
466  attributes.erase(it);
467  return;
468  }
469  }
470  }
471 }
472 
474 {
475  Attribute *attr = NULL;
476 
477  if (name == ustring())
479 
481  switch (std) {
483  attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_VERTEX);
484  break;
486  attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_FACE);
487  break;
488  case ATTR_STD_UV:
489  attr = add(name, TypeFloat2, ATTR_ELEMENT_CORNER);
490  break;
491  case ATTR_STD_UV_TANGENT:
492  attr = add(name, TypeDesc::TypeVector, ATTR_ELEMENT_CORNER);
493  break;
495  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CORNER);
496  break;
498  attr = add(name, TypeRGBA, ATTR_ELEMENT_CORNER_BYTE);
499  break;
500  case ATTR_STD_GENERATED:
503  attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX);
504  break;
506  attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX_MOTION);
507  break;
509  attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_VERTEX_MOTION);
510  break;
512  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_FACE);
513  break;
514  case ATTR_STD_PTEX_UV:
515  attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX);
516  break;
518  attr = add(name, TypeDesc::TypeMatrix, ATTR_ELEMENT_MESH);
519  break;
520  case ATTR_STD_POINTINESS:
521  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_VERTEX);
522  break;
524  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_FACE);
525  break;
526  default:
527  assert(0);
528  break;
529  }
530  }
531  else if (geometry->geometry_type == Geometry::VOLUME) {
532  switch (std) {
534  attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_VERTEX);
535  break;
537  attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_FACE);
538  break;
543  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_VOXEL);
544  break;
546  attr = add(name, TypeDesc::TypeColor, ATTR_ELEMENT_VOXEL);
547  break;
549  attr = add(name, TypeDesc::TypeVector, ATTR_ELEMENT_VOXEL);
550  break;
551  default:
552  assert(0);
553  break;
554  }
555  }
556  else if (geometry->geometry_type == Geometry::HAIR) {
557  switch (std) {
558  case ATTR_STD_UV:
559  attr = add(name, TypeFloat2, ATTR_ELEMENT_CURVE);
560  break;
561  case ATTR_STD_GENERATED:
562  attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CURVE);
563  break;
565  attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CURVE_KEY_MOTION);
566  break;
568  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CURVE_KEY);
569  break;
571  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CURVE);
572  break;
574  attr = add(name, TypeDesc::TypeMatrix, ATTR_ELEMENT_MESH);
575  break;
576  case ATTR_STD_POINTINESS:
577  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_VERTEX);
578  break;
580  attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_FACE);
581  break;
582  default:
583  assert(0);
584  break;
585  }
586  }
587 
588  attr->std = std;
589 
590  return attr;
591 }
592 
594 {
595  foreach (const Attribute &attr, attributes)
596  if (attr.std == std)
597  return (Attribute *)&attr;
598 
599  return NULL;
600 }
601 
603 {
604  Attribute *attr = find(std);
605 
606  if (attr) {
607  list<Attribute>::iterator it;
608 
609  for (it = attributes.begin(); it != attributes.end(); it++) {
610  if (&*it == attr) {
611  modified = true;
612  attributes.erase(it);
613  return;
614  }
615  }
616  }
617 }
618 
620 {
621  if (req.std == ATTR_STD_NONE)
622  return find(req.name);
623  else
624  return find(req.std);
625 }
626 
628 {
629  if (attribute->std == ATTR_STD_NONE) {
630  remove(attribute->name);
631  }
632  else {
633  remove(attribute->std);
634  }
635 }
636 
637 void AttributeSet::resize(bool reserve_only)
638 {
639  foreach (Attribute &attr, attributes) {
640  attr.resize(geometry, prim, reserve_only);
641  }
642 }
643 
644 void AttributeSet::clear(bool preserve_voxel_data)
645 {
646  if (preserve_voxel_data) {
647  list<Attribute>::iterator it;
648 
649  for (it = attributes.begin(); it != attributes.end();) {
650  if (it->element == ATTR_ELEMENT_VOXEL || it->std == ATTR_STD_GENERATED_TRANSFORM) {
651  it++;
652  }
653  else {
654  attributes.erase(it++);
655  }
656  }
657  }
658  else {
659  attributes.clear();
660  }
661 }
662 
663 void AttributeSet::update(AttributeSet &&new_attributes)
664 {
665  /* add or update old_attributes based on the new_attributes */
666  foreach (Attribute &attr, new_attributes.attributes) {
667  Attribute *nattr = add(attr.name, attr.type, attr.element);
668  nattr->std = attr.std;
669  nattr->set_data_from(std::move(attr));
670  }
671 
672  /* remove any attributes not on new_attributes */
673  list<Attribute>::iterator it;
674  for (it = attributes.begin(); it != attributes.end();) {
675  if (it->std != ATTR_STD_NONE) {
676  if (new_attributes.find(it->std) == nullptr) {
677  modified = true;
678  attributes.erase(it++);
679  continue;
680  }
681  }
682  else if (it->name != "") {
683  if (new_attributes.find(it->name) == nullptr) {
684  modified = true;
685  attributes.erase(it++);
686  continue;
687  }
688  }
689 
690  it++;
691  }
692 
693  /* If all attributes were replaced, transform is no longer applied. */
694  geometry->transform_applied = false;
695 }
696 
698 {
699  foreach (Attribute &attr, attributes) {
700  attr.modified = false;
701  }
702  modified = false;
703 }
704 
705 /* AttributeRequest */
706 
708 {
709  name = name_;
710  std = ATTR_STD_NONE;
711 
712  type = TypeDesc::TypeFloat;
714  desc.offset = 0;
716 
717  subd_type = TypeDesc::TypeFloat;
719  subd_desc.offset = 0;
721 }
722 
724 {
725  name = ustring();
726  std = std_;
727 
728  type = TypeDesc::TypeFloat;
730  desc.offset = 0;
732 
733  subd_type = TypeDesc::TypeFloat;
735  subd_desc.offset = 0;
737 }
738 
739 /* AttributeRequestSet */
740 
742 {
743 }
744 
746 {
747 }
748 
750 {
751  if (requests.size() != other.requests.size())
752  return true;
753 
754  for (size_t i = 0; i < requests.size(); i++) {
755  bool found = false;
756 
757  for (size_t j = 0; j < requests.size() && !found; j++)
758  if (requests[i].name == other.requests[j].name && requests[i].std == other.requests[j].std) {
759  found = true;
760  }
761 
762  if (!found) {
763  return true;
764  }
765  }
766 
767  return false;
768 }
769 
770 void AttributeRequestSet::add(ustring name)
771 {
772  foreach (AttributeRequest &req, requests) {
773  if (req.name == name) {
774  return;
775  }
776  }
777 
778  requests.push_back(AttributeRequest(name));
779 }
780 
782 {
783  foreach (AttributeRequest &req, requests)
784  if (req.std == std)
785  return;
786 
787  requests.push_back(AttributeRequest(std));
788 }
789 
791 {
792  foreach (AttributeRequest &req, reqs.requests) {
793  if (req.std == ATTR_STD_NONE)
794  add(req.name);
795  else
796  add(req.std);
797  }
798 }
799 
801 {
802  if (name.empty()) {
803  return;
804  }
805 
807 
808  if (std) {
809  add(std);
810  }
811  else {
812  add(name);
813  }
814 }
815 
816 bool AttributeRequestSet::find(ustring name)
817 {
818  foreach (AttributeRequest &req, requests)
819  if (req.name == name)
820  return true;
821 
822  return false;
823 }
824 
826 {
827  foreach (AttributeRequest &req, requests)
828  if (req.std == std)
829  return true;
830 
831  return false;
832 }
833 
835 {
836  return requests.size();
837 }
838 
840 {
841  requests.clear();
842 }
843 
typedef float(TangentPoint)[2]
unsigned char uchar
Definition: BLI_sys_types.h:86
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
ATTR_WARN_UNUSED_RESULT const void * element
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
vector< AttributeRequest > requests
Definition: attribute.h:235
bool find(ustring name)
Definition: attribute.cpp:816
void add(ustring name)
Definition: attribute.cpp:770
bool modified(const AttributeRequestSet &other)
Definition: attribute.cpp:749
void add_standard(ustring name)
Definition: attribute.cpp:800
TypeDesc subd_type
Definition: attribute.h:222
AttributeRequest(ustring name_)
Definition: attribute.cpp:707
TypeDesc type
Definition: attribute.h:222
AttributeDescriptor subd_desc
Definition: attribute.h:223
AttributeDescriptor desc
Definition: attribute.h:223
AttributeStandard std
Definition: attribute.h:219
Geometry * geometry
Definition: attribute.h:179
Attribute * add(ustring name, TypeDesc type, AttributeElement element)
Definition: attribute.cpp:428
void update(AttributeSet &&new_attributes)
Definition: attribute.cpp:663
list< Attribute > attributes
Definition: attribute.h:181
Attribute * find(ustring name) const
Definition: attribute.cpp:447
void remove(ustring name)
Definition: attribute.cpp:456
void clear_modified()
Definition: attribute.cpp:697
AttributeSet(Geometry *geometry, AttributePrimitive prim)
Definition: attribute.cpp:419
bool modified
Definition: attribute.h:182
void resize(bool reserve_only=false)
Definition: attribute.cpp:637
void clear(bool preserve_voxel_data=false)
Definition: attribute.cpp:644
AttributePrimitive prim
Definition: attribute.h:180
ImageHandle & data_voxel()
Definition: attribute.h:113
AttributeElement element
Definition: attribute.h:54
static bool same_storage(TypeDesc a, TypeDesc b)
Definition: attribute.cpp:270
void add_with_weight(void *dst, void *src, float weight)
Definition: attribute.cpp:290
static AttributeStandard name_standard(const char *name)
Definition: attribute.cpp:373
TypeDesc type
Definition: attribute.h:52
void resize(Geometry *geom, AttributePrimitive prim, bool reserve_only)
Definition: attribute.cpp:57
size_t element_size(Geometry *geom, AttributePrimitive prim) const
Definition: attribute.cpp:185
void get_uv_tiles(Geometry *geom, AttributePrimitive prim, unordered_set< int > &tiles) const
Definition: attribute.cpp:386
char * data()
Definition: attribute.h:77
vector< char > buffer
Definition: attribute.h:53
void set_data_from(Attribute &&other)
Definition: attribute.cpp:151
bool modified
Definition: attribute.h:57
void zero_data(void *dst)
Definition: attribute.cpp:285
Attribute(ustring name, TypeDesc type, AttributeElement element, Geometry *geom, AttributePrimitive prim)
Definition: attribute.cpp:29
static const char * standard_name(AttributeStandard std)
Definition: attribute.cpp:311
uint flags
Definition: attribute.h:55
size_t buffer_size(Geometry *geom, AttributePrimitive prim) const
Definition: attribute.cpp:265
AttributeStandard std
Definition: attribute.h:50
ustring name
Definition: attribute.h:49
size_t data_sizeof() const
Definition: attribute.cpp:169
void add(const float &f)
Definition: attribute.cpp:76
float2 * data_float2()
Definition: attribute.h:81
Type geometry_type
Definition: geometry.h:78
@ MESH
Definition: geometry.h:73
@ VOLUME
Definition: geometry.h:75
@ HAIR
Definition: geometry.h:74
bool transform_applied
Definition: geometry.h:88
~ImageHandle()
Definition: image.cpp:118
#define CCL_NAMESPACE_END
AttributeStandard
Definition: kernel_types.h:744
@ ATTR_STD_CURVE_INTERCEPT
Definition: kernel_types.h:759
@ ATTR_STD_GENERATED_TRANSFORM
Definition: kernel_types.h:753
@ ATTR_STD_UV
Definition: kernel_types.h:748
@ ATTR_STD_MOTION_VERTEX_NORMAL
Definition: kernel_types.h:757
@ ATTR_STD_VOLUME_TEMPERATURE
Definition: kernel_types.h:767
@ ATTR_STD_VERTEX_NORMAL
Definition: kernel_types.h:746
@ ATTR_STD_UV_TANGENT
Definition: kernel_types.h:749
@ ATTR_STD_NOT_FOUND
Definition: kernel_types.h:773
@ ATTR_STD_NONE
Definition: kernel_types.h:745
@ ATTR_STD_VERTEX_COLOR
Definition: kernel_types.h:751
@ ATTR_STD_VOLUME_DENSITY
Definition: kernel_types.h:763
@ ATTR_STD_NUM
Definition: kernel_types.h:771
@ ATTR_STD_POSITION_UNDISPLACED
Definition: kernel_types.h:755
@ ATTR_STD_VOLUME_FLAME
Definition: kernel_types.h:765
@ ATTR_STD_PTEX_FACE_ID
Definition: kernel_types.h:761
@ ATTR_STD_VOLUME_VELOCITY
Definition: kernel_types.h:768
@ ATTR_STD_POSITION_UNDEFORMED
Definition: kernel_types.h:754
@ ATTR_STD_VOLUME_COLOR
Definition: kernel_types.h:764
@ ATTR_STD_MOTION_VERTEX_POSITION
Definition: kernel_types.h:756
@ ATTR_STD_VOLUME_HEAT
Definition: kernel_types.h:766
@ ATTR_STD_UV_TANGENT_SIGN
Definition: kernel_types.h:750
@ ATTR_STD_CURVE_RANDOM
Definition: kernel_types.h:760
@ ATTR_STD_FACE_NORMAL
Definition: kernel_types.h:747
@ ATTR_STD_PTEX_UV
Definition: kernel_types.h:762
@ ATTR_STD_POINTINESS
Definition: kernel_types.h:769
@ ATTR_STD_GENERATED
Definition: kernel_types.h:752
@ ATTR_STD_RANDOM_PER_ISLAND
Definition: kernel_types.h:770
@ ATTR_STD_PARTICLE
Definition: kernel_types.h:758
@ ATTR_FINAL_SIZE
Definition: kernel_types.h:777
AttributeElement
Definition: kernel_types.h:729
@ ATTR_ELEMENT_NONE
Definition: kernel_types.h:730
@ ATTR_ELEMENT_CORNER_BYTE
Definition: kernel_types.h:737
@ ATTR_ELEMENT_CURVE_KEY
Definition: kernel_types.h:739
@ ATTR_ELEMENT_CURVE_KEY_MOTION
Definition: kernel_types.h:740
@ ATTR_ELEMENT_VOXEL
Definition: kernel_types.h:741
@ ATTR_ELEMENT_CORNER
Definition: kernel_types.h:736
@ ATTR_ELEMENT_OBJECT
Definition: kernel_types.h:731
@ ATTR_ELEMENT_VERTEX_MOTION
Definition: kernel_types.h:735
@ ATTR_ELEMENT_VERTEX
Definition: kernel_types.h:734
@ ATTR_ELEMENT_FACE
Definition: kernel_types.h:733
@ ATTR_ELEMENT_MESH
Definition: kernel_types.h:732
@ ATTR_ELEMENT_CURVE
Definition: kernel_types.h:738
AttributePrimitive
Definition: kernel_types.h:722
@ ATTR_PRIM_SUBD
Definition: kernel_types.h:724
@ ATTR_PRIM_GEOMETRY
Definition: kernel_types.h:723
static unsigned a[3]
Definition: RandGen.cpp:92
AttributeElement element
Definition: kernel_types.h:782
NodeAttributeType type
Definition: kernel_types.h:783
size_t num_curves() const
Definition: hair.h:133
size_t get_num_subd_faces() const
Definition: mesh.h:246
float size[3]
size_t num_triangles() const
Definition: mesh.h:92
size_t get_num_subd_verts()
Definition: mesh.h:256
@ NODE_ATTR_FLOAT
Definition: svm_types.h:167
static constexpr TypeDesc TypeRGBA(TypeDesc::FLOAT, TypeDesc::VEC4, TypeDesc::COLOR)
CCL_NAMESPACE_BEGIN static constexpr OIIO_NAMESPACE_USING TypeDesc TypeFloat2(TypeDesc::FLOAT, TypeDesc::VEC2)
CCL_NAMESPACE_BEGIN struct Transform Transform