Blender  V2.93
hair.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2020 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 "bvh/bvh.h"
18 
19 #include "render/curves.h"
20 #include "render/hair.h"
21 #include "render/scene.h"
22 
24 
25 /* Hair Curve */
26 
27 void Hair::Curve::bounds_grow(const int k,
28  const float3 *curve_keys,
29  const float *curve_radius,
30  BoundBox &bounds) const
31 {
32  float3 P[4];
33 
34  P[0] = curve_keys[max(first_key + k - 1, first_key)];
35  P[1] = curve_keys[first_key + k];
36  P[2] = curve_keys[first_key + k + 1];
37  P[3] = curve_keys[min(first_key + k + 2, first_key + num_keys - 1)];
38 
39  float3 lower;
40  float3 upper;
41 
42  curvebounds(&lower.x, &upper.x, P, 0);
43  curvebounds(&lower.y, &upper.y, P, 1);
44  curvebounds(&lower.z, &upper.z, P, 2);
45 
46  float mr = max(curve_radius[first_key + k], curve_radius[first_key + k + 1]);
47 
48  bounds.grow(lower, mr);
49  bounds.grow(upper, mr);
50 }
51 
52 void Hair::Curve::bounds_grow(const int k,
53  const float3 *curve_keys,
54  const float *curve_radius,
55  const Transform &aligned_space,
56  BoundBox &bounds) const
57 {
58  float3 P[4];
59 
60  P[0] = curve_keys[max(first_key + k - 1, first_key)];
61  P[1] = curve_keys[first_key + k];
62  P[2] = curve_keys[first_key + k + 1];
63  P[3] = curve_keys[min(first_key + k + 2, first_key + num_keys - 1)];
64 
65  P[0] = transform_point(&aligned_space, P[0]);
66  P[1] = transform_point(&aligned_space, P[1]);
67  P[2] = transform_point(&aligned_space, P[2]);
68  P[3] = transform_point(&aligned_space, P[3]);
69 
70  float3 lower;
71  float3 upper;
72 
73  curvebounds(&lower.x, &upper.x, P, 0);
74  curvebounds(&lower.y, &upper.y, P, 1);
75  curvebounds(&lower.z, &upper.z, P, 2);
76 
77  float mr = max(curve_radius[first_key + k], curve_radius[first_key + k + 1]);
78 
79  bounds.grow(lower, mr);
80  bounds.grow(upper, mr);
81 }
82 
83 void Hair::Curve::bounds_grow(float4 keys[4], BoundBox &bounds) const
84 {
85  float3 P[4] = {
86  float4_to_float3(keys[0]),
87  float4_to_float3(keys[1]),
88  float4_to_float3(keys[2]),
89  float4_to_float3(keys[3]),
90  };
91 
92  float3 lower;
93  float3 upper;
94 
95  curvebounds(&lower.x, &upper.x, P, 0);
96  curvebounds(&lower.y, &upper.y, P, 1);
97  curvebounds(&lower.z, &upper.z, P, 2);
98 
99  float mr = max(keys[1].w, keys[2].w);
100 
101  bounds.grow(lower, mr);
102  bounds.grow(upper, mr);
103 }
104 
105 void Hair::Curve::motion_keys(const float3 *curve_keys,
106  const float *curve_radius,
107  const float3 *key_steps,
108  size_t num_curve_keys,
109  size_t num_steps,
110  float time,
111  size_t k0,
112  size_t k1,
113  float4 r_keys[2]) const
114 {
115  /* Figure out which steps we need to fetch and their interpolation factor. */
116  const size_t max_step = num_steps - 1;
117  const size_t step = min((int)(time * max_step), max_step - 1);
118  const float t = time * max_step - step;
119  /* Fetch vertex coordinates. */
120  float4 curr_keys[2];
121  float4 next_keys[2];
123  curve_keys, curve_radius, key_steps, num_curve_keys, num_steps, step, k0, k1, curr_keys);
125  curve_keys, curve_radius, key_steps, num_curve_keys, num_steps, step + 1, k0, k1, next_keys);
126  /* Interpolate between steps. */
127  r_keys[0] = (1.0f - t) * curr_keys[0] + t * next_keys[0];
128  r_keys[1] = (1.0f - t) * curr_keys[1] + t * next_keys[1];
129 }
130 
132  const float *curve_radius,
133  const float3 *key_steps,
134  size_t num_curve_keys,
135  size_t num_steps,
136  float time,
137  size_t k0,
138  size_t k1,
139  size_t k2,
140  size_t k3,
141  float4 r_keys[4]) const
142 {
143  /* Figure out which steps we need to fetch and their interpolation factor. */
144  const size_t max_step = num_steps - 1;
145  const size_t step = min((int)(time * max_step), max_step - 1);
146  const float t = time * max_step - step;
147  /* Fetch vertex coordinates. */
148  float4 curr_keys[4];
149  float4 next_keys[4];
150  cardinal_keys_for_step(curve_keys,
151  curve_radius,
152  key_steps,
153  num_curve_keys,
154  num_steps,
155  step,
156  k0,
157  k1,
158  k2,
159  k3,
160  curr_keys);
161  cardinal_keys_for_step(curve_keys,
162  curve_radius,
163  key_steps,
164  num_curve_keys,
165  num_steps,
166  step + 1,
167  k0,
168  k1,
169  k2,
170  k3,
171  next_keys);
172  /* Interpolate between steps. */
173  r_keys[0] = (1.0f - t) * curr_keys[0] + t * next_keys[0];
174  r_keys[1] = (1.0f - t) * curr_keys[1] + t * next_keys[1];
175  r_keys[2] = (1.0f - t) * curr_keys[2] + t * next_keys[2];
176  r_keys[3] = (1.0f - t) * curr_keys[3] + t * next_keys[3];
177 }
178 
179 void Hair::Curve::keys_for_step(const float3 *curve_keys,
180  const float *curve_radius,
181  const float3 *key_steps,
182  size_t num_curve_keys,
183  size_t num_steps,
184  size_t step,
185  size_t k0,
186  size_t k1,
187  float4 r_keys[2]) const
188 {
189  k0 = max(k0, 0);
190  k1 = min(k1, num_keys - 1);
191  const size_t center_step = ((num_steps - 1) / 2);
192  if (step == center_step) {
193  /* Center step: regular key location. */
194  /* TODO(sergey): Consider adding make_float4(float3, float)
195  * function.
196  */
197  r_keys[0] = make_float4(curve_keys[first_key + k0].x,
198  curve_keys[first_key + k0].y,
199  curve_keys[first_key + k0].z,
200  curve_radius[first_key + k0]);
201  r_keys[1] = make_float4(curve_keys[first_key + k1].x,
202  curve_keys[first_key + k1].y,
203  curve_keys[first_key + k1].z,
204  curve_radius[first_key + k1]);
205  }
206  else {
207  /* Center step is not stored in this array. */
208  if (step > center_step) {
209  step--;
210  }
211  const size_t offset = first_key + step * num_curve_keys;
212  r_keys[0] = make_float4(key_steps[offset + k0].x,
213  key_steps[offset + k0].y,
214  key_steps[offset + k0].z,
215  curve_radius[first_key + k0]);
216  r_keys[1] = make_float4(key_steps[offset + k1].x,
217  key_steps[offset + k1].y,
218  key_steps[offset + k1].z,
219  curve_radius[first_key + k1]);
220  }
221 }
222 
224  const float *curve_radius,
225  const float3 *key_steps,
226  size_t num_curve_keys,
227  size_t num_steps,
228  size_t step,
229  size_t k0,
230  size_t k1,
231  size_t k2,
232  size_t k3,
233  float4 r_keys[4]) const
234 {
235  k0 = max(k0, 0);
236  k3 = min(k3, num_keys - 1);
237  const size_t center_step = ((num_steps - 1) / 2);
238  if (step == center_step) {
239  /* Center step: regular key location. */
240  r_keys[0] = make_float4(curve_keys[first_key + k0].x,
241  curve_keys[first_key + k0].y,
242  curve_keys[first_key + k0].z,
243  curve_radius[first_key + k0]);
244  r_keys[1] = make_float4(curve_keys[first_key + k1].x,
245  curve_keys[first_key + k1].y,
246  curve_keys[first_key + k1].z,
247  curve_radius[first_key + k1]);
248  r_keys[2] = make_float4(curve_keys[first_key + k2].x,
249  curve_keys[first_key + k2].y,
250  curve_keys[first_key + k2].z,
251  curve_radius[first_key + k2]);
252  r_keys[3] = make_float4(curve_keys[first_key + k3].x,
253  curve_keys[first_key + k3].y,
254  curve_keys[first_key + k3].z,
255  curve_radius[first_key + k3]);
256  }
257  else {
258  /* Center step is not stored in this array. */
259  if (step > center_step) {
260  step--;
261  }
262  const size_t offset = first_key + step * num_curve_keys;
263  r_keys[0] = make_float4(key_steps[offset + k0].x,
264  key_steps[offset + k0].y,
265  key_steps[offset + k0].z,
266  curve_radius[first_key + k0]);
267  r_keys[1] = make_float4(key_steps[offset + k1].x,
268  key_steps[offset + k1].y,
269  key_steps[offset + k1].z,
270  curve_radius[first_key + k1]);
271  r_keys[2] = make_float4(key_steps[offset + k2].x,
272  key_steps[offset + k2].y,
273  key_steps[offset + k2].z,
274  curve_radius[first_key + k2]);
275  r_keys[3] = make_float4(key_steps[offset + k3].x,
276  key_steps[offset + k3].y,
277  key_steps[offset + k3].z,
278  curve_radius[first_key + k3]);
279  }
280 }
281 
282 /* Hair */
283 
285 {
286  NodeType *type = NodeType::add("hair", create, NodeType::NONE, Geometry::get_node_base_type());
287 
288  SOCKET_POINT_ARRAY(curve_keys, "Curve Keys", array<float3>());
289  SOCKET_FLOAT_ARRAY(curve_radius, "Curve Radius", array<float>());
290  SOCKET_INT_ARRAY(curve_first_key, "Curve First Key", array<int>());
291  SOCKET_INT_ARRAY(curve_shader, "Curve Shader", array<int>());
292 
293  return type;
294 }
295 
296 Hair::Hair() : Geometry(get_node_type(), Geometry::HAIR)
297 {
298  curvekey_offset = 0;
300 }
301 
303 {
304 }
305 
306 void Hair::resize_curves(int numcurves, int numkeys)
307 {
308  curve_keys.resize(numkeys);
309  curve_radius.resize(numkeys);
310  curve_first_key.resize(numcurves);
311  curve_shader.resize(numcurves);
312 
313  attributes.resize();
314 }
315 
316 void Hair::reserve_curves(int numcurves, int numkeys)
317 {
318  curve_keys.reserve(numkeys);
319  curve_radius.reserve(numkeys);
320  curve_first_key.reserve(numcurves);
321  curve_shader.reserve(numcurves);
322 
323  attributes.resize(true);
324 }
325 
326 void Hair::clear(bool preserve_shaders)
327 {
328  Geometry::clear(preserve_shaders);
329 
330  curve_keys.clear();
331  curve_radius.clear();
332  curve_first_key.clear();
333  curve_shader.clear();
334 
335  attributes.clear();
336 }
337 
338 void Hair::add_curve_key(float3 co, float radius)
339 {
340  curve_keys.push_back_reserved(co);
341  curve_radius.push_back_reserved(radius);
342 
343  tag_curve_keys_modified();
344  tag_curve_radius_modified();
345 }
346 
347 void Hair::add_curve(int first_key, int shader)
348 {
349  curve_first_key.push_back_reserved(first_key);
350  curve_shader.push_back_reserved(shader);
351 
352  tag_curve_first_key_modified();
353  tag_curve_shader_modified();
354 }
355 
356 void Hair::copy_center_to_motion_step(const int motion_step)
357 {
359  if (attr_mP) {
360  float3 *keys = &curve_keys[0];
361  size_t numkeys = curve_keys.size();
362  memcpy(attr_mP->data_float3() + motion_step * numkeys, keys, sizeof(float3) * numkeys);
363  }
364 }
365 
366 void Hair::get_uv_tiles(ustring map, unordered_set<int> &tiles)
367 {
368  Attribute *attr;
369 
370  if (map.empty()) {
371  attr = attributes.find(ATTR_STD_UV);
372  }
373  else {
374  attr = attributes.find(map);
375  }
376 
377  if (attr) {
378  attr->get_uv_tiles(this, ATTR_PRIM_GEOMETRY, tiles);
379  }
380 }
381 
383 {
384  BoundBox bnds = BoundBox::empty;
385  size_t curve_keys_size = curve_keys.size();
386 
387  if (curve_keys_size > 0) {
388  for (size_t i = 0; i < curve_keys_size; i++)
389  bnds.grow(curve_keys[i], curve_radius[i]);
390 
392  if (use_motion_blur && curve_attr) {
393  size_t steps_size = curve_keys.size() * (motion_steps - 1);
394  float3 *key_steps = curve_attr->data_float3();
395 
396  for (size_t i = 0; i < steps_size; i++)
397  bnds.grow(key_steps[i]);
398  }
399 
400  if (!bnds.valid()) {
401  bnds = BoundBox::empty;
402 
403  /* skip nan or inf coordinates */
404  for (size_t i = 0; i < curve_keys_size; i++)
405  bnds.grow_safe(curve_keys[i], curve_radius[i]);
406 
407  if (use_motion_blur && curve_attr) {
408  size_t steps_size = curve_keys.size() * (motion_steps - 1);
409  float3 *key_steps = curve_attr->data_float3();
410 
411  for (size_t i = 0; i < steps_size; i++)
412  bnds.grow_safe(key_steps[i]);
413  }
414  }
415  }
416 
417  if (!bnds.valid()) {
418  /* empty mesh */
419  bnds.grow(zero_float3());
420  }
421 
422  bounds = bnds;
423 }
424 
425 void Hair::apply_transform(const Transform &tfm, const bool apply_to_motion)
426 {
427  /* compute uniform scale */
428  float3 c0 = transform_get_column(&tfm, 0);
429  float3 c1 = transform_get_column(&tfm, 1);
430  float3 c2 = transform_get_column(&tfm, 2);
431  float scalar = powf(fabsf(dot(cross(c0, c1), c2)), 1.0f / 3.0f);
432 
433  /* apply transform to curve keys */
434  for (size_t i = 0; i < curve_keys.size(); i++) {
435  float3 co = transform_point(&tfm, curve_keys[i]);
436  float radius = curve_radius[i] * scalar;
437 
438  /* scale for curve radius is only correct for uniform scale */
439  curve_keys[i] = co;
440  curve_radius[i] = radius;
441  }
442 
443  if (apply_to_motion) {
445 
446  if (curve_attr) {
447  /* apply transform to motion curve keys */
448  size_t steps_size = curve_keys.size() * (motion_steps - 1);
449  float4 *key_steps = curve_attr->data_float4();
450 
451  for (size_t i = 0; i < steps_size; i++) {
452  float3 co = transform_point(&tfm, float4_to_float3(key_steps[i]));
453  float radius = key_steps[i].w * scalar;
454 
455  /* scale for curve radius is only correct for uniform scale */
456  key_steps[i] = float3_to_float4(co);
457  key_steps[i].w = radius;
458  }
459  }
460  }
461 }
462 
464  float4 *curve_key_co,
465  float4 *curve_data,
466  size_t curvekey_offset)
467 {
468  size_t curve_keys_size = curve_keys.size();
469 
470  /* pack curve keys */
471  if (curve_keys_size) {
472  float3 *keys_ptr = curve_keys.data();
473  float *radius_ptr = curve_radius.data();
474 
475  for (size_t i = 0; i < curve_keys_size; i++)
476  curve_key_co[i] = make_float4(keys_ptr[i].x, keys_ptr[i].y, keys_ptr[i].z, radius_ptr[i]);
477  }
478 
479  /* pack curve segments */
480  size_t curve_num = num_curves();
481 
482  for (size_t i = 0; i < curve_num; i++) {
483  Curve curve = get_curve(i);
484  int shader_id = curve_shader[i];
485  Shader *shader = (shader_id < used_shaders.size()) ?
486  static_cast<Shader *>(used_shaders[shader_id]) :
488  shader_id = scene->shader_manager->get_shader_id(shader, false);
489 
492  __int_as_float(shader_id),
493  0.0f);
494  }
495 }
496 
497 void Hair::pack_primitives(PackedBVH *pack, int object, uint visibility, PackFlags pack_flags)
498 {
499  if (curve_first_key.empty())
500  return;
501 
502  /* Separate loop as other arrays are not initialized if their packing is not required. */
503  if ((pack_flags & PACK_VISIBILITY) != 0) {
504  unsigned int *prim_visibility = &pack->prim_visibility[optix_prim_offset];
505 
506  size_t index = 0;
507  for (size_t j = 0; j < num_curves(); ++j) {
508  Curve curve = get_curve(j);
509  for (size_t k = 0; k < curve.num_segments(); ++k, ++index) {
510  prim_visibility[index] = visibility;
511  }
512  }
513  }
514 
515  if ((pack_flags & PACK_GEOMETRY) != 0) {
516  unsigned int *prim_tri_index = &pack->prim_tri_index[optix_prim_offset];
517  int *prim_type = &pack->prim_type[optix_prim_offset];
518  int *prim_index = &pack->prim_index[optix_prim_offset];
519  int *prim_object = &pack->prim_object[optix_prim_offset];
520  // 'pack->prim_time' is unused by Embree and OptiX
521 
527 
528  size_t index = 0;
529  for (size_t j = 0; j < num_curves(); ++j) {
530  Curve curve = get_curve(j);
531  for (size_t k = 0; k < curve.num_segments(); ++k, ++index) {
532  prim_tri_index[index] = -1;
533  prim_type[index] = PRIMITIVE_PACK_SEGMENT(type, k);
534  // Each curve segment points back to its curve index
535  prim_index[index] = j + prim_offset;
536  prim_object[index] = object;
537  }
538  }
539  }
540 }
541 
unsigned int uint
Definition: BLI_sys_types.h:83
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_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
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition: btDbvt.cpp:299
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
Attribute * find(ustring name) const
Definition: attribute.cpp:447
void resize(bool reserve_only=false)
Definition: attribute.cpp:637
void clear(bool preserve_voxel_data=false)
Definition: attribute.cpp:644
float4 * data_float4()
Definition: attribute.h:91
void get_uv_tiles(Geometry *geom, AttributePrimitive prim, unordered_set< int > &tiles) const
Definition: attribute.cpp:386
float3 * data_float3()
Definition: attribute.h:86
@ HAIR
Definition: geometry.h:74
BoundBox bounds
Definition: geometry.h:87
size_t optix_prim_offset
Definition: geometry.h:103
size_t index
Definition: geometry.h:114
int motion_step(float time) const
Definition: geometry.cpp:150
size_t prim_offset
Definition: geometry.h:102
bool has_motion_blur() const
Definition: geometry.cpp:255
AttributeSet attributes
Definition: geometry.h:81
virtual void clear(bool preserve_shaders=false)
Definition: geometry.cpp:91
int get_shader_id(Shader *shader, bool smooth=false)
Definition: shader.cpp:449
Definition: shader.h:80
CCL_NAMESPACE_BEGIN void curvebounds(float *lower, float *upper, float3 *p, int dim)
Definition: curves.cpp:32
double time
Scene scene
Curve curve
PackFlags
Definition: geometry.h:47
@ PACK_GEOMETRY
Definition: geometry.h:51
@ PACK_VISIBILITY
Definition: geometry.h:57
NODE_DEFINE(Hair)
Definition: hair.cpp:284
#define powf(x, y)
#define CCL_NAMESPACE_END
#define make_float4(x, y, z, w)
#define fabsf(x)
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
#define PRIMITIVE_PACK_SEGMENT(type, segment)
Definition: kernel_types.h:710
@ PRIMITIVE_MOTION_CURVE_RIBBON
Definition: kernel_types.h:691
@ PRIMITIVE_CURVE_RIBBON
Definition: kernel_types.h:690
@ PRIMITIVE_MOTION_CURVE_THICK
Definition: kernel_types.h:689
@ PRIMITIVE_CURVE_THICK
Definition: kernel_types.h:688
@ ATTR_STD_UV
Definition: kernel_types.h:748
@ ATTR_STD_MOTION_VERTEX_POSITION
Definition: kernel_types.h:756
@ CURVE_RIBBON
Definition: kernel_types.h:714
@ ATTR_PRIM_GEOMETRY
Definition: kernel_types.h:723
static float P(float k)
Definition: math_interp.c:41
#define SOCKET_POINT_ARRAY(name, ui_name, default_value,...)
Definition: node_type.h:261
#define SOCKET_FLOAT_ARRAY(name, ui_name, default_value,...)
Definition: node_type.h:252
#define SOCKET_INT_ARRAY(name, ui_name, default_value,...)
Definition: node_type.h:250
#define min(a, b)
Definition: sort.c:51
__forceinline bool valid() const
__forceinline void grow_safe(const float3 &pt)
Definition: util_boundbox.h:76
__forceinline void grow(const float3 &pt)
Definition: util_boundbox.h:55
int first_key
Definition: hair.h:30
void keys_for_step(const float3 *curve_keys, const float *curve_radius, const float3 *key_steps, size_t num_curve_keys, size_t num_steps, size_t step, size_t k0, size_t k1, float4 r_keys[2]) const
Definition: hair.cpp:179
void cardinal_motion_keys(const float3 *curve_keys, const float *curve_radius, const float3 *key_steps, size_t num_curve_keys, size_t num_steps, float time, size_t k0, size_t k1, size_t k2, size_t k3, float4 r_keys[4]) const
Definition: hair.cpp:131
int num_segments() const
Definition: hair.h:33
void cardinal_keys_for_step(const float3 *curve_keys, const float *curve_radius, const float3 *key_steps, size_t num_curve_keys, size_t num_steps, size_t step, size_t k0, size_t k1, size_t k2, size_t k3, float4 r_keys[4]) const
Definition: hair.cpp:223
int num_keys
Definition: hair.h:31
void motion_keys(const float3 *curve_keys, const float *curve_radius, const float3 *key_steps, size_t num_curve_keys, size_t num_steps, float time, size_t k0, size_t k1, float4 r_keys[2]) const
Definition: hair.cpp:105
void bounds_grow(const int k, const float3 *curve_keys, const float *curve_radius, BoundBox &bounds) const
Definition: hair.cpp:27
~Hair()
Definition: hair.cpp:302
float(* co)[3]
void resize_curves(int numcurves, int numkeys)
Definition: hair.cpp:306
size_t curvekey_offset
Definition: hair.h:98
void pack_curves(Scene *scene, float4 *curve_key_co, float4 *curve_data, size_t curvekey_offset)
Definition: hair.cpp:463
void add_curve(int first_key, int shader)
Definition: hair.cpp:347
float * radius
Curve get_curve(size_t i) const
Definition: hair.h:119
void compute_bounds() override
Definition: hair.cpp:382
void reserve_curves(int numcurves, int numkeys)
Definition: hair.cpp:316
size_t num_curves() const
Definition: hair.h:133
void get_uv_tiles(ustring map, unordered_set< int > &tiles) override
Definition: hair.cpp:366
void copy_center_to_motion_step(const int motion_step)
Definition: hair.cpp:356
CurveShapeType curve_shape
Definition: hair.h:99
void clear(bool preserve_shaders=false) override
Definition: hair.cpp:326
void pack_primitives(PackedBVH *pack, int object, uint visibility, PackFlags pack_flags) override
Definition: hair.cpp:497
void apply_transform(const Transform &tfm, const bool apply_to_motion) override
Definition: hair.cpp:425
Hair()
Definition: hair.cpp:296
void add_curve_key(float3 loc, float radius)
Definition: hair.cpp:338
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=NULL)
const NodeType * type
Definition: node.h:175
array< int > prim_index
Definition: bvh/bvh.h:63
array< int > prim_type
Definition: bvh/bvh.h:58
array< uint > prim_visibility
Definition: bvh/bvh.h:60
array< uint > prim_tri_index
Definition: bvh/bvh.h:54
array< int > prim_object
Definition: bvh/bvh.h:65
Shader * default_surface
Definition: scene.h:253
ShaderManager * shader_manager
Definition: scene.h:245
float z
Definition: sky_float3.h:35
float y
Definition: sky_float3.h:35
float x
Definition: sky_float3.h:35
float max
__forceinline avxf cross(const avxf &a, const avxf &b)
Definition: util_avxf.h:119
ccl_device_inline float4 float3_to_float4(const float3 a)
Definition: util_math.h:420
ccl_device_inline float3 float4_to_float3(const float4 a)
Definition: util_math.h:415
ccl_device_inline float __int_as_float(int i)
Definition: util_math.h:212
ccl_device_inline float dot(const float2 &a, const float2 &b)
ccl_device_inline float3 zero_float3()
ccl_device_inline float3 transform_get_column(const Transform *t, int column)
ccl_device_inline float3 transform_point(const Transform *t, const float3 a)