Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/mesh.cpp
| Show First 20 Lines • Show All 1,010 Lines • ▼ Show 20 Lines | else { | ||||
| *(patch_data++) = subd_face_corners.size() + ngons + corner_offset; | *(patch_data++) = subd_face_corners.size() + ngons + corner_offset; | ||||
| } | } | ||||
| ngons++; | ngons++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void Mesh::compute_bvh(DeviceScene *dscene, | void Mesh::compute_bvh(const Scene *scene, | ||||
| SceneParams *params, | DeviceScene *dscene, | ||||
| Progress *progress, | Progress *progress, | ||||
| int n, | int n, | ||||
| int total) | int total) | ||||
| { | { | ||||
| if(progress->get_cancel()) | const SceneParams *params = &scene->params; | ||||
| if(progress->get_cancel()) { | |||||
| return; | return; | ||||
| } | |||||
| compute_bounds(); | compute_bounds(); | ||||
| if(need_build_bvh()) { | if(need_build_bvh()) { | ||||
| string msg = "Updating Mesh BVH "; | string msg = "Updating Mesh BVH "; | ||||
| if(name == "") | if(name == "") | ||||
| msg += string_printf("%u/%u", (uint)(n+1), (uint)total); | msg += string_printf("%u/%u", (uint)(n+1), (uint)total); | ||||
| else | else | ||||
| Show All 17 Lines | else { | ||||
| bparams.use_spatial_split = params->use_bvh_spatial_split; | bparams.use_spatial_split = params->use_bvh_spatial_split; | ||||
| bparams.use_qbvh = params->use_qbvh; | bparams.use_qbvh = params->use_qbvh; | ||||
| bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && | bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && | ||||
| params->use_bvh_unaligned_nodes; | params->use_bvh_unaligned_nodes; | ||||
| bparams.num_motion_triangle_steps = params->num_bvh_time_steps; | bparams.num_motion_triangle_steps = params->num_bvh_time_steps; | ||||
| bparams.num_motion_curve_steps = params->num_bvh_time_steps; | bparams.num_motion_curve_steps = params->num_bvh_time_steps; | ||||
| delete bvh; | delete bvh; | ||||
| bvh = BVH::create(bparams, objects); | bvh = BVH::create(bparams, scene, objects); | ||||
| MEM_GUARDED_CALL(progress, bvh->build, *progress); | MEM_GUARDED_CALL(progress, bvh->build, *progress); | ||||
| } | } | ||||
| } | } | ||||
| need_update = false; | need_update = false; | ||||
| need_update_rebuild = false; | need_update_rebuild = false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 753 Lines • ▼ Show 20 Lines | void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) | ||||
| bparams.use_qbvh = scene->params.use_qbvh; | bparams.use_qbvh = scene->params.use_qbvh; | ||||
| bparams.use_spatial_split = scene->params.use_bvh_spatial_split; | bparams.use_spatial_split = scene->params.use_bvh_spatial_split; | ||||
| bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && | bparams.use_unaligned_nodes = dscene->data.bvh.have_curves && | ||||
| scene->params.use_bvh_unaligned_nodes; | scene->params.use_bvh_unaligned_nodes; | ||||
| bparams.num_motion_triangle_steps = scene->params.num_bvh_time_steps; | bparams.num_motion_triangle_steps = scene->params.num_bvh_time_steps; | ||||
| bparams.num_motion_curve_steps = scene->params.num_bvh_time_steps; | bparams.num_motion_curve_steps = scene->params.num_bvh_time_steps; | ||||
| delete bvh; | delete bvh; | ||||
| bvh = BVH::create(bparams, scene->objects); | bvh = BVH::create(bparams, scene, scene->objects); | ||||
| bvh->build(progress); | bvh->build(progress); | ||||
| if(progress.get_cancel()) return; | if(progress.get_cancel()) return; | ||||
| /* copy to device */ | /* copy to device */ | ||||
| progress.set_status("Updating Scene BVH", "Copying BVH to device"); | progress.set_status("Updating Scene BVH", "Copying BVH to device"); | ||||
| PackedBVH& pack = bvh->pack; | PackedBVH& pack = bvh->pack; | ||||
| ▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Lines | void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) | ||||
| TaskPool pool; | TaskPool pool; | ||||
| i = 0; | i = 0; | ||||
| foreach(Mesh *mesh, scene->meshes) { | foreach(Mesh *mesh, scene->meshes) { | ||||
| if(mesh->need_update) { | if(mesh->need_update) { | ||||
| pool.push(function_bind(&Mesh::compute_bvh, | pool.push(function_bind(&Mesh::compute_bvh, | ||||
| mesh, | mesh, | ||||
| scene, | |||||
| dscene, | dscene, | ||||
| &scene->params, | |||||
| &progress, | &progress, | ||||
| i, | i, | ||||
| num_bvh)); | num_bvh)); | ||||
| if(mesh->need_build_bvh()) { | if(mesh->need_build_bvh()) { | ||||
| i++; | i++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines | |||||