diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-01-16 22:50:10 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-01-16 23:03:12 +0300 |
commit | 43872f59b9a6c471b81fff48b09a2f5e2487d985 (patch) | |
tree | c4ae234968ee6aa108c03a057d8bc83a310e99f9 /intern | |
parent | af9e99763c95add81f72cf619acf9098e6cd9f1a (diff) | |
parent | e0303d02974c914d4633e37d789e33b21689b5eb (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern')
21 files changed, 190 insertions, 144 deletions
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 29a68bf272e..35a30ae683f 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -523,7 +523,7 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node) /* we don't yet support arbitrary attributes, for now add vertex * coordinates as generated coordinates if requested */ - if (mesh->need_attribute(state.scene, ATTR_STD_GENERATED)) { + if(mesh->need_attribute(state.scene, ATTR_STD_GENERATED)) { Attribute *attr = mesh->attributes.add(ATTR_STD_GENERATED); memcpy(attr->data_float3(), mesh->verts.data(), sizeof(float3)*mesh->verts.size()); } diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index 378ae67f0c7..e42ff5d72a6 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -29,24 +29,6 @@ CCL_NAMESPACE_BEGIN -/* Utilities */ - -/* Hair curve functions */ - -void curveinterp_v3_v3v3v3v3(float3 *p, float3 *v1, float3 *v2, float3 *v3, float3 *v4, const float w[4]); -void interp_weights(float t, float data[4]); -float shaperadius(float shape, float root, float tip, float time); -void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData); -bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int uv_num); -bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int vcol_num); -bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background); -void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData); -void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, - float3 RotCam, bool is_ortho); -void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resolution); -void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata); -void ExportCurveTriangleVcol(ParticleCurveData *CData, int vert_offset, int resol, uchar4 *cdata); - ParticleCurveData::ParticleCurveData() { } @@ -55,7 +37,7 @@ ParticleCurveData::~ParticleCurveData() { } -void interp_weights(float t, float data[4]) +static void interp_weights(float t, float data[4]) { /* Cardinal curve interpolation */ float t2 = t * t; @@ -68,17 +50,19 @@ void interp_weights(float t, float data[4]) data[3] = fc * t3 - fc * t2; } -void curveinterp_v3_v3v3v3v3(float3 *p, float3 *v1, float3 *v2, float3 *v3, float3 *v4, const float w[4]) +static void curveinterp_v3_v3v3v3v3(float3 *p, + float3 *v1, float3 *v2, float3 *v3, float3 *v4, + const float w[4]) { p->x = v1->x * w[0] + v2->x * w[1] + v3->x * w[2] + v4->x * w[3]; p->y = v1->y * w[0] + v2->y * w[1] + v3->y * w[2] + v4->y * w[3]; p->z = v1->z * w[0] + v2->z * w[1] + v3->z * w[2] + v4->z * w[3]; } -float shaperadius(float shape, float root, float tip, float time) +static float shaperadius(float shape, float root, float tip, float time) { float radius = 1.0f - time; - + if(shape != 0.0f) { if(shape < 0.0f) radius = powf(radius, 1.0f + shape); @@ -90,7 +74,13 @@ float shaperadius(float shape, float root, float tip, float time) /* curve functions */ -void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData) +static void InterpolateKeySegments(int seg, + int segno, + int key, + int curve, + float3 *keyloc, + float *time, + ParticleCurveData *CData) { float3 ckey_loc1 = CData->curvekey_co[key]; float3 ckey_loc2 = ckey_loc1; @@ -119,7 +109,11 @@ void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyl curveinterp_v3_v3v3v3v3(keyloc, &ckey_loc1, &ckey_loc2, &ckey_loc3, &ckey_loc4, t); } -bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background) +static bool ObtainCacheParticleData(Mesh *mesh, + BL::Mesh *b_mesh, + BL::Object *b_ob, + ParticleCurveData *CData, + bool background) { int curvenum = 0; int keyno = 0; @@ -143,7 +137,7 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par int totparts = b_psys.particles.length(); int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f); int totcurves = totchild; - + if(b_part.child_type() == 0 || totchild == 0) totcurves += totparts; @@ -161,7 +155,7 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par CData->psys_shader.push_back_slow(shader); float radius = get_float(cpsys, "radius_scale") * 0.5f; - + CData->psys_rootradius.push_back_slow(radius * get_float(cpsys, "root_width")); CData->psys_tipradius.push_back_slow(radius * get_float(cpsys, "tip_width")); CData->psys_shape.push_back_slow(get_float(cpsys, "shape")); @@ -181,7 +175,7 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par for(; pa_no < totparts+totchild; pa_no++) { int keynum = 0; CData->curve_firstkey.push_back_slow(keyno); - + float curve_length = 0.0f; float3 pcKey; for(int step_no = 0; step_no < ren_step; step_no++) { @@ -213,7 +207,12 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par return true; } -bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int uv_num) +static bool ObtainCacheParticleUV(Mesh *mesh, + BL::Mesh *b_mesh, + BL::Object *b_ob, + ParticleCurveData *CData, + bool background, + int uv_num) { if(!(mesh && b_mesh && b_ob && CData)) return false; @@ -231,7 +230,7 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti int totparts = b_psys.particles.length(); int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f); int totcurves = totchild; - + if(b_part.child_type() == 0 || totchild == 0) totcurves += totparts; @@ -267,7 +266,12 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti return true; } -bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int vcol_num) +static bool ObtainCacheParticleVcol(Mesh *mesh, + BL::Mesh *b_mesh, + BL::Object *b_ob, + ParticleCurveData *CData, + bool background, + int vcol_num) { if(!(mesh && b_mesh && b_ob && CData)) return false; @@ -285,7 +289,7 @@ bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par int totparts = b_psys.particles.length(); int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f); int totcurves = totchild; - + if(b_part.child_type() == 0 || totchild == 0) totcurves += totparts; @@ -333,16 +337,16 @@ static void set_resolution(BL::Object *b_ob, BL::Scene *scene, bool render) } } -void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, - float3 RotCam, bool is_ortho) +static void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, + float3 RotCam, bool is_ortho) { int vertexno = mesh->verts.size(); int vertexindex = vertexno; int numverts = 0, numtris = 0; /* compute and reserve size of arrays */ - for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) { - for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f) continue; @@ -354,8 +358,8 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, mesh->reserve_mesh(mesh->verts.size() + numverts, mesh->num_triangles() + numtris); /* actually export */ - for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) { - for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f) continue; @@ -380,7 +384,7 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, if(curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1) v1 = CData->curvekey_co[curvekey] - CData->curvekey_co[max(curvekey - 1, CData->curve_firstkey[curve])]; - else + else v1 = CData->curvekey_co[curvekey + 1] - CData->curvekey_co[curvekey - 1]; time = CData->curvekey_time[curvekey]/CData->curve_length[curve]; @@ -416,15 +420,17 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, /* texture coords still needed */ } -void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resolution) +static void ExportCurveTriangleGeometry(Mesh *mesh, + ParticleCurveData *CData, + int resolution) { int vertexno = mesh->verts.size(); int vertexindex = vertexno; int numverts = 0, numtris = 0; /* compute and reserve size of arrays */ - for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) { - for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f) continue; @@ -436,8 +442,8 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol mesh->reserve_mesh(mesh->verts.size() + numverts, mesh->num_triangles() + numtris); /* actually export */ - for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) { - for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f) continue; @@ -548,7 +554,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol /* texture coords still needed */ } -void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData) +static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData) { int num_keys = 0; int num_curves = 0; @@ -557,13 +563,13 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData) return; Attribute *attr_intercept = NULL; - + if(mesh->need_attribute(scene, ATTR_STD_CURVE_INTERCEPT)) attr_intercept = mesh->curve_attributes.add(ATTR_STD_CURVE_INTERCEPT); /* compute and reserve size of arrays */ - for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) { - for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f) continue; @@ -582,8 +588,8 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData) num_curves = 0; /* actually export */ - for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) { - for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f) continue; @@ -677,8 +683,13 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int /* in case of new attribute, we verify if there really was any motion */ if(new_attribute) { if(i != numkeys || !have_motion) { - /* no motion, remove attributes again */ - VLOG(1) << "No motion, removing attribute"; + /* No motion or hair "topology" changed, remove attributes again. */ + if(i != numkeys) { + VLOG(1) << "Hair topology changed, removing attribute."; + } + else { + VLOG(1) << "No motion, removing attribute."; + } mesh->curve_attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION); } else if(time_index > 0) { @@ -698,7 +709,10 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int } } -void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata) +static void ExportCurveTriangleUV(ParticleCurveData *CData, + int vert_offset, + int resol, + float3 *uvdata) { if(uvdata == NULL) return; @@ -708,8 +722,8 @@ void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol, int vertexindex = vert_offset; - for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) { - for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f) continue; @@ -743,15 +757,18 @@ void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol, } } -void ExportCurveTriangleVcol(ParticleCurveData *CData, int vert_offset, int resol, uchar4 *cdata) +static void ExportCurveTriangleVcol(ParticleCurveData *CData, + int vert_offset, + int resol, + uchar4 *cdata) { if(cdata == NULL) return; int vertexindex = vert_offset; - for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) { - for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) { + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f) continue; @@ -1044,4 +1061,3 @@ void BlenderSync::sync_curves(Mesh *mesh, } CCL_NAMESPACE_END - diff --git a/intern/cycles/blender/blender_object_cull.cpp b/intern/cycles/blender/blender_object_cull.cpp index b8582df0f93..08918dd1a49 100644 --- a/intern/cycles/blender/blender_object_cull.cpp +++ b/intern/cycles/blender/blender_object_cull.cpp @@ -43,7 +43,7 @@ BlenderObjectCulling::BlenderObjectCulling(Scene *scene, BL::Scene& b_scene) camera_cull_margin_ = get_float(cscene, "camera_cull_margin"); distance_cull_margin_ = get_float(cscene, "distance_cull_margin"); - if (distance_cull_margin_ == 0.0f) { + if(distance_cull_margin_ == 0.0f) { use_scene_distance_cull_ = false; } } diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 21166b2f155..04b5c3fa013 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -305,12 +305,16 @@ static PassType get_pass_type(BL::RenderPass& b_pass) #ifdef WITH_CYCLES_DEBUG case BL::RenderPass::type_DEBUG: { - if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSAL_STEPS) - return PASS_BVH_TRAVERSAL_STEPS; - if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSED_INSTANCES) - return PASS_BVH_TRAVERSED_INSTANCES; - if(b_pass.debug_type() == BL::RenderPass::debug_type_RAY_BOUNCES) - return PASS_RAY_BOUNCES; + switch(b_pass.debug_type()) { + case BL::RenderPass::debug_type_BVH_TRAVERSED_NODES: + return PASS_BVH_TRAVERSED_NODES; + case BL::RenderPass::debug_type_BVH_TRAVERSED_INSTANCES: + return PASS_BVH_TRAVERSED_INSTANCES; + case BL::RenderPass::debug_type_BVH_INTERSECTIONS: + return PASS_BVH_INTERSECTIONS; + case BL::RenderPass::debug_type_RAY_BOUNCES: + return PASS_RAY_BOUNCES; + } break; } #endif diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index 14f66aca70f..8cf1495b33d 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -130,12 +130,13 @@ void BVHBuild::add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh, /* motion triangles */ if(attr_mP) { - size_t mesh_size = mesh->verts.size(); - size_t steps = mesh->motion_steps - 1; - float3 *vert_steps = attr_mP->data_float3(); + const size_t mesh_size = mesh->verts.size(); + const size_t num_steps = mesh->motion_steps - 1; + const float3 *vert_steps = attr_mP->data_float3(); - for(size_t i = 0; i < steps; i++) - t.bounds_grow(vert_steps + i*mesh_size, bounds); + for(size_t step = 0; step < num_steps; step++) { + t.bounds_grow(vert_steps + step*mesh_size, bounds); + } type = PRIMITIVE_MOTION_TRIANGLE; } @@ -156,21 +157,23 @@ void BVHBuild::add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh, size_t num_curves = mesh->num_curves(); for(uint j = 0; j < num_curves; j++) { - Mesh::Curve curve = mesh->get_curve(j); + const Mesh::Curve curve = mesh->get_curve(j); PrimitiveType type = PRIMITIVE_CURVE; + const float *curve_radius = &mesh->curve_radius[0]; for(int k = 0; k < curve.num_keys - 1; k++) { BoundBox bounds = BoundBox::empty; - curve.bounds_grow(k, &mesh->curve_keys[0], &mesh->curve_radius[0], bounds); + curve.bounds_grow(k, &mesh->curve_keys[0], curve_radius, bounds); /* motion curve */ if(curve_attr_mP) { - size_t mesh_size = mesh->curve_keys.size(); - size_t steps = mesh->motion_steps - 1; - float3 *key_steps = curve_attr_mP->data_float3(); + const size_t mesh_size = mesh->curve_keys.size(); + const size_t num_steps = mesh->motion_steps - 1; + const float3 *key_steps = curve_attr_mP->data_float3(); - for(size_t i = 0; i < steps; i++) - curve.bounds_grow(k, key_steps + i*mesh_size, &mesh->curve_radius[0], bounds); + for(size_t step = 0; step < num_steps; step++) { + curve.bounds_grow(k, key_steps + step*mesh_size, curve_radius, bounds); + } type = PRIMITIVE_MOTION_CURVE; } @@ -435,6 +438,7 @@ bool BVHBuild::range_within_max_leaf_size(const BVHRange& range, return false; size_t num_triangles = 0; + size_t num_motion_triangles = 0; size_t num_curves = 0; size_t num_motion_curves = 0; @@ -445,13 +449,16 @@ bool BVHBuild::range_within_max_leaf_size(const BVHRange& range, num_curves++; if(ref.prim_type() & PRIMITIVE_MOTION_CURVE) num_motion_curves++; - else if(ref.prim_type() & PRIMITIVE_ALL_TRIANGLE) + else if(ref.prim_type() & PRIMITIVE_TRIANGLE) num_triangles++; + else if(ref.prim_type() & PRIMITIVE_MOTION_TRIANGLE) + num_motion_triangles++; } - return (num_triangles < params.max_triangle_leaf_size) && - (num_curves < params.max_curve_leaf_size) && - (num_motion_curves < params.max_curve_leaf_size); + return (num_triangles <= params.max_triangle_leaf_size) && + (num_motion_triangles <= params.max_motion_triangle_leaf_size) && + (num_curves <= params.max_curve_leaf_size) && + (num_motion_curves <= params.max_motion_curve_leaf_size); } /* multithreaded binning builder */ @@ -918,7 +925,7 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range, BVHNode *inner = new InnerNode(inner_bounds, leaves[1], leaves[2]); return new InnerNode(range.bounds(), leaves[0], inner); } else { - /* Shpuld be doing more branches if more primitive types added. */ + /* Should be doing more branches if more primitive types added. */ assert(num_leaves <= 5); BoundBox inner_bounds_a = merge(leaves[0]->m_bounds, leaves[1]->m_bounds); BoundBox inner_bounds_b = merge(leaves[2]->m_bounds, leaves[3]->m_bounds); diff --git a/intern/cycles/bvh/bvh_params.h b/intern/cycles/bvh/bvh_params.h index 2e698a80742..6d426475737 100644 --- a/intern/cycles/bvh/bvh_params.h +++ b/intern/cycles/bvh/bvh_params.h @@ -43,7 +43,9 @@ public: /* number of primitives in leaf */ int min_leaf_size; int max_triangle_leaf_size; + int max_motion_triangle_leaf_size; int max_curve_leaf_size; + int max_motion_curve_leaf_size; /* object or mesh level bvh */ bool top_level; @@ -80,7 +82,9 @@ public: min_leaf_size = 1; max_triangle_leaf_size = 8; - max_curve_leaf_size = 2; + max_motion_triangle_leaf_size = 8; + max_curve_leaf_size = 1; + max_motion_curve_leaf_size = 4; top_level = false; use_qbvh = false; diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h index 294362ea995..df33a86bb18 100644 --- a/intern/cycles/kernel/bvh/bvh_shadow_all.h +++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h @@ -187,7 +187,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, /* primitive intersection */ while(prim_addr < prim_addr2) { - kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type); bool hit; @@ -222,6 +222,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, #if BVH_FEATURE(BVH_HAIR) case PRIMITIVE_CURVE: case PRIMITIVE_MOTION_CURVE: { + const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr); if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { hit = bvh_cardinal_curve_intersect(kg, isect_array, @@ -231,7 +232,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, object, prim_addr, ray->time, - type, + curve_type, NULL, 0, 0); } @@ -244,7 +245,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, object, prim_addr, ray->time, - type, + curve_type, NULL, 0, 0); } diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h b/intern/cycles/kernel/bvh/bvh_traversal.h index a0e478e972b..80c8f31473a 100644 --- a/intern/cycles/kernel/bvh/bvh_traversal.h +++ b/intern/cycles/kernel/bvh/bvh_traversal.h @@ -213,7 +213,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, --stack_ptr; } } - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_NODE(); } /* if node is leaf, fetch triangle list */ @@ -235,7 +235,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, switch(type & PRIMITIVE_ALL) { case PRIMITIVE_TRIANGLE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); if(triangle_intersect(kg, &isect_precalc, @@ -264,7 +264,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, #if BVH_FEATURE(BVH_MOTION) case PRIMITIVE_MOTION_TRIANGLE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); if(motion_triangle_intersect(kg, isect, @@ -296,8 +296,9 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, case PRIMITIVE_CURVE: case PRIMITIVE_MOTION_CURVE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); - kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + BVH_DEBUG_NEXT_INTERSECTION(); + const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr); + kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL)); bool hit; if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { hit = bvh_cardinal_curve_intersect(kg, @@ -308,7 +309,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, object, prim_addr, ray->time, - type, + curve_type, lcg_state, difl, extmax); @@ -322,7 +323,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, object, prim_addr, ray->time, - type, + curve_type, lcg_state, difl, extmax); diff --git a/intern/cycles/kernel/bvh/bvh_types.h b/intern/cycles/kernel/bvh/bvh_types.h index c3abe2e157d..ead424aaaaf 100644 --- a/intern/cycles/kernel/bvh/bvh_types.h +++ b/intern/cycles/kernel/bvh/bvh_types.h @@ -50,12 +50,17 @@ CCL_NAMESPACE_BEGIN #ifdef __KERNEL_DEBUG__ # define BVH_DEBUG_INIT() \ do { \ - isect->num_traversal_steps = 0; \ + isect->num_traversed_nodes = 0; \ isect->num_traversed_instances = 0; \ + isect->num_intersections = 0; \ } while(0) -# define BVH_DEBUG_NEXT_STEP() \ +# define BVH_DEBUG_NEXT_NODE() \ do { \ - ++isect->num_traversal_steps; \ + ++isect->num_traversed_nodes; \ + } while(0) +# define BVH_DEBUG_NEXT_INTERSECTION() \ + do { \ + ++isect->num_intersections; \ } while(0) # define BVH_DEBUG_NEXT_INSTANCE() \ do { \ @@ -63,7 +68,8 @@ CCL_NAMESPACE_BEGIN } while(0) #else /* __KERNEL_DEBUG__ */ # define BVH_DEBUG_INIT() -# define BVH_DEBUG_NEXT_STEP() +# define BVH_DEBUG_NEXT_NODE() +# define BVH_DEBUG_NEXT_INTERSECTION() # define BVH_DEBUG_NEXT_INSTANCE() #endif /* __KERNEL_DEBUG__ */ diff --git a/intern/cycles/kernel/bvh/qbvh_shadow_all.h b/intern/cycles/kernel/bvh/qbvh_shadow_all.h index 5f4d06f12ea..b2e99725626 100644 --- a/intern/cycles/kernel/bvh/qbvh_shadow_all.h +++ b/intern/cycles/kernel/bvh/qbvh_shadow_all.h @@ -262,7 +262,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, /* Primitive intersection. */ while(prim_addr < prim_addr2) { - kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type); bool hit; @@ -297,6 +297,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, #if BVH_FEATURE(BVH_HAIR) case PRIMITIVE_CURVE: case PRIMITIVE_MOTION_CURVE: { + const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr); if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { hit = bvh_cardinal_curve_intersect(kg, isect_array, @@ -306,7 +307,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, object, prim_addr, ray->time, - type, + curve_type, NULL, 0, 0); } @@ -319,7 +320,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, object, prim_addr, ray->time, - type, + curve_type, NULL, 0, 0); } diff --git a/intern/cycles/kernel/bvh/qbvh_traversal.h b/intern/cycles/kernel/bvh/qbvh_traversal.h index f2d8e558dcc..1d5643ca540 100644 --- a/intern/cycles/kernel/bvh/qbvh_traversal.h +++ b/intern/cycles/kernel/bvh/qbvh_traversal.h @@ -131,7 +131,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, int child_mask; ssef dist; - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_NODE(); #if BVH_FEATURE(BVH_HAIR_MINIMUM_WIDTH) if(difl != 0.0f) { @@ -326,7 +326,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, switch(type & PRIMITIVE_ALL) { case PRIMITIVE_TRIANGLE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); if(triangle_intersect(kg, &isect_precalc, @@ -347,7 +347,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, #if BVH_FEATURE(BVH_MOTION) case PRIMITIVE_MOTION_TRIANGLE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); + BVH_DEBUG_NEXT_INTERSECTION(); kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); if(motion_triangle_intersect(kg, isect, @@ -371,8 +371,9 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, case PRIMITIVE_CURVE: case PRIMITIVE_MOTION_CURVE: { for(; prim_addr < prim_addr2; prim_addr++) { - BVH_DEBUG_NEXT_STEP(); - kernel_assert(kernel_tex_fetch(__prim_type, prim_addr) == type); + BVH_DEBUG_NEXT_INTERSECTION(); + const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr); + kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL)); bool hit; if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { hit = bvh_cardinal_curve_intersect(kg, @@ -383,7 +384,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, object, prim_addr, ray->time, - type, + curve_type, lcg_state, difl, extmax); @@ -397,7 +398,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, object, prim_addr, ray->time, - type, + curve_type, lcg_state, difl, extmax); diff --git a/intern/cycles/kernel/bvh/qbvh_volume.h b/intern/cycles/kernel/bvh/qbvh_volume.h index 424710b69f2..1e77d8e67ec 100644 --- a/intern/cycles/kernel/bvh/qbvh_volume.h +++ b/intern/cycles/kernel/bvh/qbvh_volume.h @@ -295,7 +295,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, int object_flag = kernel_tex_fetch(__object_flag, object); if(object_flag & SD_OBJECT_HAS_VOLUME) { - # if BVH_FEATURE(BVH_MOTION) bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_itfm); # else diff --git a/intern/cycles/kernel/geom/geom_curve.h b/intern/cycles/kernel/geom/geom_curve.h index 636dbcc71e0..9de335403ce 100644 --- a/intern/cycles/kernel/geom/geom_curve.h +++ b/intern/cycles/kernel/geom/geom_curve.h @@ -911,7 +911,7 @@ ccl_device_forceinline bool bvh_curve_intersect(KernelGlobals *kg, Intersection # undef len3_squared # undef len3 # undef dot3 -# endif +#endif } ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3) diff --git a/intern/cycles/kernel/kernel_debug.h b/intern/cycles/kernel/kernel_debug.h index 24d6458567e..5647bbae5b5 100644 --- a/intern/cycles/kernel/kernel_debug.h +++ b/intern/cycles/kernel/kernel_debug.h @@ -18,8 +18,9 @@ CCL_NAMESPACE_BEGIN ccl_device_inline void debug_data_init(DebugData *debug_data) { - debug_data->num_bvh_traversal_steps = 0; + debug_data->num_bvh_traversed_nodes = 0; debug_data->num_bvh_traversed_instances = 0; + debug_data->num_bvh_intersections = 0; debug_data->num_ray_bounces = 0; } @@ -30,16 +31,21 @@ ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg, int sample) { int flag = kernel_data.film.pass_flag; - if(flag & PASS_BVH_TRAVERSAL_STEPS) { - kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversal_steps, + if(flag & PASS_BVH_TRAVERSED_NODES) { + kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_nodes, sample, - debug_data->num_bvh_traversal_steps); + debug_data->num_bvh_traversed_nodes); } if(flag & PASS_BVH_TRAVERSED_INSTANCES) { kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances, sample, debug_data->num_bvh_traversed_instances); } + if(flag & PASS_BVH_INTERSECTIONS) { + kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_intersections, + sample, + debug_data->num_bvh_intersections); + } if(flag & PASS_RAY_BOUNCES) { kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces, sample, diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 6a36c68d69f..e25f2597366 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -634,8 +634,9 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg, #ifdef __KERNEL_DEBUG__ if(state.flag & PATH_RAY_CAMERA) { - debug_data.num_bvh_traversal_steps += isect.num_traversal_steps; + debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes; debug_data.num_bvh_traversed_instances += isect.num_traversed_instances; + debug_data.num_bvh_intersections += isect.num_intersections; } debug_data.num_ray_bounces++; #endif /* __KERNEL_DEBUG__ */ diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h index 10174e1c4ce..72a8d98ac00 100644 --- a/intern/cycles/kernel/kernel_path_branched.h +++ b/intern/cycles/kernel/kernel_path_branched.h @@ -288,8 +288,9 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in #endif /* __HAIR__ */ #ifdef __KERNEL_DEBUG__ - debug_data.num_bvh_traversal_steps += isect.num_traversal_steps; + debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes; debug_data.num_bvh_traversed_instances += isect.num_traversed_instances; + debug_data.num_bvh_intersections += isect.num_intersections; debug_data.num_ray_bounces++; #endif /* __KERNEL_DEBUG__ */ diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 2563f1491b1..4180465d1a1 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -345,9 +345,10 @@ typedef enum PassType { PASS_SUBSURFACE_COLOR = (1 << 24), PASS_LIGHT = (1 << 25), /* no real pass, used to force use_light_pass */ #ifdef __KERNEL_DEBUG__ - PASS_BVH_TRAVERSAL_STEPS = (1 << 26), + PASS_BVH_TRAVERSED_NODES = (1 << 26), PASS_BVH_TRAVERSED_INSTANCES = (1 << 27), - PASS_RAY_BOUNCES = (1 << 28), + PASS_BVH_INTERSECTIONS = (1 << 28), + PASS_RAY_BOUNCES = (1 << 29), #endif } PassType; @@ -542,8 +543,9 @@ typedef ccl_addr_space struct Intersection { int type; #ifdef __KERNEL_DEBUG__ - int num_traversal_steps; + int num_traversed_nodes; int num_traversed_instances; + int num_intersections; #endif } Intersection; @@ -1040,10 +1042,10 @@ typedef struct KernelFilm { float mist_falloff; #ifdef __KERNEL_DEBUG__ - int pass_bvh_traversal_steps; + int pass_bvh_traversed_nodes; int pass_bvh_traversed_instances; + int pass_bvh_intersections; int pass_ray_bounces; - int pass_pad3; #endif } KernelFilm; static_assert_align(KernelFilm, 16); @@ -1188,10 +1190,9 @@ static_assert_align(KernelData, 16); * really important here. */ typedef ccl_addr_space struct DebugData { - // Total number of BVH node traversal steps and primitives intersections - // for the camera rays. - int num_bvh_traversal_steps; + int num_bvh_traversed_nodes; int num_bvh_traversed_instances; + int num_bvh_intersections; int num_ray_bounces; } DebugData; #endif diff --git a/intern/cycles/kernel/split/kernel_scene_intersect.h b/intern/cycles/kernel/split/kernel_scene_intersect.h index fc4b4ee38e5..2388580051f 100644 --- a/intern/cycles/kernel/split/kernel_scene_intersect.h +++ b/intern/cycles/kernel/split/kernel_scene_intersect.h @@ -116,8 +116,9 @@ ccl_device void kernel_scene_intersect( #ifdef __KERNEL_DEBUG__ if(state.flag & PATH_RAY_CAMERA) { - debug_data->num_bvh_traversal_steps += isect->num_traversal_steps; + debug_data->num_bvh_traversed_nodes += isect->num_traversed_nodes; debug_data->num_bvh_traversed_instances += isect->num_traversed_instances; + debug_data->num_bvh_intersections += isect->num_intersections; } debug_data->num_ray_bounces++; #endif diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index cb20e811708..f1692712d61 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -185,13 +185,11 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int } } #ifdef WITH_CYCLES_DEBUG - else if(type == PASS_BVH_TRAVERSAL_STEPS) { - for(int i = 0; i < size; i++, in += pass_stride, pixels++) { - float f = *in; - pixels[0] = f*scale; - } - } - else if(type == PASS_RAY_BOUNCES) { + else if(type == PASS_BVH_TRAVERSED_NODES || + type == PASS_BVH_TRAVERSED_INSTANCES || + type == PASS_BVH_INTERSECTIONS || + type == PASS_RAY_BOUNCES) + { for(int i = 0; i < size; i++, in += pass_stride, pixels++) { float f = *in; pixels[0] = f*scale; diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index e10a938e1eb..923252bb375 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -154,14 +154,9 @@ void Pass::add(PassType type, array<Pass>& passes) pass.components = 0; break; #ifdef WITH_CYCLES_DEBUG - case PASS_BVH_TRAVERSAL_STEPS: - pass.components = 1; - pass.exposure = false; - break; + case PASS_BVH_TRAVERSED_NODES: case PASS_BVH_TRAVERSED_INSTANCES: - pass.components = 1; - pass.exposure = false; - break; + case PASS_BVH_INTERSECTIONS: case PASS_RAY_BOUNCES: pass.components = 1; pass.exposure = false; @@ -421,12 +416,15 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) break; #ifdef WITH_CYCLES_DEBUG - case PASS_BVH_TRAVERSAL_STEPS: - kfilm->pass_bvh_traversal_steps = kfilm->pass_stride; + case PASS_BVH_TRAVERSED_NODES: + kfilm->pass_bvh_traversed_nodes = kfilm->pass_stride; break; case PASS_BVH_TRAVERSED_INSTANCES: kfilm->pass_bvh_traversed_instances = kfilm->pass_stride; break; + case PASS_BVH_INTERSECTIONS: + kfilm->pass_bvh_intersections = kfilm->pass_stride; + break; case PASS_RAY_BOUNCES: kfilm->pass_ray_bounces = kfilm->pass_stride; break; diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 33721048722..73caf93ea00 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -834,11 +834,11 @@ void Session::update_status_time(bool show_pause, bool show_done) substatus = string_printf("Path Tracing Tile %d/%d", tile, num_tiles); - if(device->show_samples() || (is_cpu && is_last_tile)) - { + if(device->show_samples() || (is_cpu && is_last_tile)) { /* Some devices automatically support showing the sample number: * - CUDADevice - * - OpenCLDevice when using the megakernel (the split kernel renders multiple samples at the same time, so the current sample isn't really defined) + * - OpenCLDevice when using the megakernel (the split kernel renders multiple + * samples at the same time, so the current sample isn't really defined) * - CPUDevice when using one thread * For these devices, the current sample is always shown. * |