55 const size_t max_step = num_steps - 1;
56 const size_t step =
min((
int)(
time * max_step), max_step - 1);
57 const float t =
time * max_step - step;
64 r_verts[0] = (1.0f -
t) * curr_verts[0] +
t * next_verts[0];
65 r_verts[1] = (1.0f -
t) * curr_verts[1] +
t * next_verts[1];
66 r_verts[2] = (1.0f -
t) * curr_verts[2] +
t * next_verts[2];
76 const size_t center_step = ((num_steps - 1) / 2);
77 if (step == center_step) {
85 if (step > center_step) {
88 size_t offset = step * num_verts;
89 r_verts[0] = vert_steps[offset +
v[0]];
90 r_verts[1] = vert_steps[offset +
v[1]];
91 r_verts[2] = vert_steps[offset +
v[2]];
101 const float normlen =
len(
norm);
102 if (normlen == 0.0f) {
105 return norm / normlen;
138 static NodeEnum subdivision_type_enum;
155 SOCKET_FLOAT(subd_dicing_rate,
"Subdivision Dicing Rate", 0.0f)
156 SOCKET_INT(subd_max_level,
"Subdivision Dicing Rate", 0);
164 if (subdivision_type == SubdivisionType::SUBDIVISION_NONE) {
181 return get_subd_params() && (verts_is_modified() || subd_dicing_rate_is_modified() ||
182 subd_objecttoworld_is_modified() || subd_max_level_is_modified());
217 verts.resize(numverts);
218 triangles.resize(numtris * 3);
220 smooth.resize(numtris);
223 triangle_patch.resize(numtris);
224 vert_patch_uv.resize(numverts);
233 verts.reserve(numverts);
234 triangles.reserve(numtris * 3);
236 smooth.reserve(numtris);
239 triangle_patch.reserve(numtris);
240 vert_patch_uv.reserve(numverts);
248 subd_start_corner.resize(numfaces);
249 subd_num_corners.resize(numfaces);
250 subd_shader.resize(numfaces);
251 subd_smooth.resize(numfaces);
252 subd_ptex_offset.resize(numfaces);
253 subd_face_corners.resize(numcorners);
254 num_ngons = num_ngons_;
255 num_subd_faces = numfaces;
257 subd_attributes.resize();
262 subd_start_corner.reserve(numfaces);
263 subd_num_corners.reserve(numfaces);
264 subd_shader.reserve(numfaces);
265 subd_smooth.reserve(numfaces);
266 subd_ptex_offset.reserve(numfaces);
267 subd_face_corners.reserve(numcorners);
268 num_ngons = num_ngons_;
269 num_subd_faces = numfaces;
271 subd_attributes.resize(
true);
276 subd_creases_edge.reserve(num_creases * 2);
277 subd_creases_weight.reserve(num_creases);
287 vert_to_stitching_key_map.clear();
288 vert_stitching_map.clear();
304 triangle_patch.clear();
305 vert_patch_uv.clear();
307 subd_start_corner.clear();
308 subd_num_corners.clear();
311 subd_ptex_offset.clear();
312 subd_face_corners.clear();
314 subd_creases_edge.clear();
315 subd_creases_weight.clear();
317 subd_attributes.clear();
320 subdivision_type = SubdivisionType::SUBDIVISION_NONE;
327 clear(preserve_shaders,
false);
332 verts.push_back_reserved(
P);
333 tag_verts_modified();
337 tag_vert_patch_uv_modified();
344 tag_verts_modified();
348 tag_vert_patch_uv_modified();
354 triangles.push_back_reserved(v0);
355 triangles.push_back_reserved(
v1);
356 triangles.push_back_reserved(
v2);
357 shader.push_back_reserved(shader_);
358 smooth.push_back_reserved(smooth_);
360 tag_triangles_modified();
361 tag_shader_modified();
362 tag_smooth_modified();
365 triangle_patch.push_back_reserved(-1);
366 tag_triangle_patch_modified();
372 int start_corner = subd_face_corners.size();
374 for (
int i = 0; i < num_corners; i++) {
375 subd_face_corners.push_back_reserved(corners[i]);
381 if (subd_shader.size()) {
386 subd_start_corner.push_back_reserved(start_corner);
387 subd_num_corners.push_back_reserved(num_corners);
388 subd_shader.push_back_reserved(shader_);
389 subd_smooth.push_back_reserved(smooth_);
390 subd_ptex_offset.push_back_reserved(ptex_offset);
392 tag_subd_face_corners_modified();
393 tag_subd_start_corner_modified();
394 tag_subd_num_corners_modified();
395 tag_subd_shader_modified();
396 tag_subd_smooth_modified();
397 tag_subd_ptex_offset_modified();
413 subd_creases_edge.push_back_slow(v0);
414 subd_creases_edge.push_back_slow(
v1);
415 subd_creases_weight.push_back_slow(weight);
417 tag_subd_creases_edge_modified();
418 tag_subd_creases_edge_modified();
419 tag_subd_creases_weight_modified();
431 size_t numverts =
verts.size();
449 subd_attr = subd_attributes.find(map);
463 size_t verts_size =
verts.size();
465 if (verts_size > 0) {
466 for (
size_t i = 0; i < verts_size; i++)
470 if (use_motion_blur && attr) {
471 size_t steps_size =
verts.size() * (motion_steps - 1);
474 for (
size_t i = 0; i < steps_size; i++)
475 bnds.
grow(vert_steps[i]);
482 for (
size_t i = 0; i < verts_size; i++)
485 if (use_motion_blur && attr) {
486 size_t steps_size =
verts.size() * (motion_steps - 1);
489 for (
size_t i = 0; i < steps_size; i++)
508 for (
size_t i = 0; i <
verts.size(); i++)
511 if (apply_to_motion) {
515 size_t steps_size =
verts.size() * (motion_steps - 1);
518 for (
size_t i = 0; i < steps_size; i++)
526 size_t steps_size =
verts.size() * (motion_steps - 1);
529 for (
size_t i = 0; i < steps_size; i++)
548 if (triangles_size) {
551 for (
size_t i = 0; i < triangles_size; i++) {
560 for (
size_t i = 0; i < triangles_size; i++)
568 size_t verts_size =
verts.size();
583 for (
size_t i = 0; i < triangles_size; i++) {
584 for (
size_t j = 0; j < 3; j++) {
589 for (
size_t i = 0; i < verts_size; i++) {
605 for (
int step = 0; step < motion_steps - 1; step++) {
612 for (
size_t i = 0; i < triangles_size; i++) {
613 for (
size_t j = 0; j < 3; j++) {
619 for (
size_t i = 0; i < verts_size; i++) {
647 for (
size_t i = 0; i < verts_size; i++) {
688 uint last_shader = -1;
689 bool last_smooth =
false;
692 int *shader_ptr =
shader.data();
694 for (
size_t i = 0; i < triangles_size; i++) {
695 if (shader_ptr[i] != last_shader || last_smooth != smooth[i]) {
696 last_shader = shader_ptr[i];
697 last_smooth = smooth[i];
699 static_cast<Shader *
>(used_shaders[last_shader]) :
704 tri_shader[i] = shader_id;
711 if (attr_vN ==
NULL) {
720 size_t verts_size =
verts.size();
722 for (
size_t i = 0; i < verts_size; i++) {
739 size_t verts_size =
verts.size();
742 float2 *vert_patch_uv_ptr = vert_patch_uv.data();
744 for (
size_t i = 0; i < verts_size; i++) {
745 tri_patch_uv[i] = vert_patch_uv_ptr[i];
751 for (
size_t i = 0; i < triangles_size; i++) {
754 t.v[1] + vert_offset,
755 t.v[2] + vert_offset,
756 tri_prim_index[i + tri_offset]);
767 for (
size_t f = 0; f < num_faces; f++) {
772 memcpy(
c, &subd_face_corners[face.
start_corner],
sizeof(
int) * 4);
774 *(patch_data++) =
c[0] + vert_offset;
775 *(patch_data++) =
c[1] + vert_offset;
776 *(patch_data++) =
c[2] + vert_offset;
777 *(patch_data++) =
c[3] + vert_offset;
779 *(patch_data++) = f + face_offset;
789 c[2] =
verts.size() - num_subd_verts + ngons;
792 *(patch_data++) =
c[0] + vert_offset;
793 *(patch_data++) =
c[1] + vert_offset;
794 *(patch_data++) =
c[2] + vert_offset;
795 *(patch_data++) =
c[3] + vert_offset;
797 *(patch_data++) = f + face_offset;
800 *(patch_data++) = subd_face_corners.size() + ngons + corner_offset;
810 if (triangles.empty())
817 float4 *prim_tri_verts = &pack->prim_tri_verts[
prim_offset * 3];
825 for (
size_t k = 0; k < num_prims; ++k) {
826 prim_visibility[k] = visibility;
837 for (
size_t k = 0; k < num_prims; ++k) {
842 prim_object[k] = object;
848 for (
size_t k = 0; k < num_prims; ++k) {
_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
_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 v1
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Attribute * add(ustring name, TypeDesc type, AttributeElement element)
Attribute * find(ustring name) const
void resize(bool reserve_only=false)
void clear(bool preserve_voxel_data=false)
void get_uv_tiles(Geometry *geom, AttributePrimitive prim, unordered_set< int > &tiles) const
size_t buffer_size(Geometry *geom, AttributePrimitive prim) const
size_t data_sizeof() const
Transform transform_normal
int motion_step(float time) const
bool has_motion_blur() const
bool transform_negative_scaled
virtual void clear(bool preserve_shaders=false)
int get_shader_id(Shader *shader, bool smooth=false)
#define CCL_NAMESPACE_END
#define make_float4(x, y, z, w)
#define make_float3(x, y, z)
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
@ PRIMITIVE_MOTION_TRIANGLE
@ ATTR_STD_MOTION_VERTEX_NORMAL
@ ATTR_STD_POSITION_UNDISPLACED
@ ATTR_STD_MOTION_VERTEX_POSITION
static void vnormal(PROCESS *process, const float point[3], float r_no[3])
#define SOCKET_BOOLEAN_ARRAY(name, ui_name, default_value,...)
#define SOCKET_POINT_ARRAY(name, ui_name, default_value,...)
#define SOCKET_POINT2_ARRAY(name, ui_name, default_value,...)
#define SOCKET_FLOAT(name, ui_name, default_value,...)
#define SOCKET_INT(name, ui_name, default_value,...)
#define SOCKET_FLOAT_ARRAY(name, ui_name, default_value,...)
#define SOCKET_TRANSFORM(name, ui_name, default_value,...)
#define SOCKET_INT_ARRAY(name, ui_name, default_value,...)
#define SOCKET_ENUM(name, ui_name, values, default_value,...)
__forceinline bool valid() const
__forceinline void grow_safe(const float3 &pt)
__forceinline void grow(const float3 &pt)
int num_ptex_faces() const
float3 normal(const Mesh *mesh) const
bool valid(const float3 *verts) const
void motion_verts(const float3 *verts, const float3 *vert_steps, size_t num_verts, size_t num_steps, float time, float3 r_verts[3]) const
void verts_for_step(const float3 *verts, const float3 *vert_steps, size_t num_verts, size_t num_steps, size_t step, float3 r_verts[3]) const
void bounds_grow(const float3 *verts, BoundBox &bounds) const
float3 compute_normal(const float3 *verts) const
void pack_primitives(PackedBVH *pack, int object, uint visibility, PackFlags pack_flags) override
SubdParams * get_subd_params()
void reserve_subd_faces(int numfaces, int num_ngons, int numcorners)
size_t get_num_subd_faces() const
void reserve_subd_creases(size_t num_creases)
void compute_bounds() override
void add_vertex_normals()
Triangle get_triangle(size_t i) const
void copy_center_to_motion_step(const int motion_step)
void clear(bool preserve_shaders=false) override
void resize_subd_faces(int numfaces, int num_ngons, int numcorners)
void pack_verts(const vector< uint > &tri_prim_index, uint4 *tri_vindex, uint *tri_patch, float2 *tri_patch_uv, size_t vert_offset, size_t tri_offset)
void reserve_mesh(int numverts, int numfaces)
void pack_normals(float4 *vnormal)
void pack_patches(uint *patch_data, uint vert_offset, uint face_offset, uint corner_offset)
void add_vertex_slow(float3 P)
@ SUBDIVISION_CATMULL_CLARK
size_t num_triangles() const
void add_crease(int v0, int v1, float weight)
void add_vertex(float3 P)
void get_uv_tiles(ustring map, unordered_set< int > &tiles) override
void add_triangle(int v0, int v1, int v2, int shader, bool smooth)
void add_subd_face(int *corners, int num_corners, int shader_, bool smooth_)
SubdFace get_subd_face(size_t index) const
void pack_shaders(Scene *scene, uint *shader)
void resize_mesh(int numverts, int numfaces)
void apply_transform(const Transform &tfm, const bool apply_to_motion) override
void insert(const char *x, int y)
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=NULL)
ShaderManager * shader_manager
__forceinline avxf cross(const avxf &a, const avxf &b)
ccl_device_inline int mod(int x, int m)
ccl_device_inline float4 float3_to_float4(const float3 a)
ccl_device_inline float2 normalize(const float2 &a)
ccl_device_inline float2 safe_normalize(const float2 &a)
ccl_device_inline float2 zero_float2()
ccl_device_inline float3 zero_float3()
ccl_device_inline bool isfinite3_safe(float3 v)
ccl_device_inline uint4 make_uint4(uint x, uint y, uint z, uint w)