Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/mesh.cpp
| Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | Mesh::Mesh() | ||||
| curve_offset = 0; | curve_offset = 0; | ||||
| curvekey_offset = 0; | curvekey_offset = 0; | ||||
| attributes.triangle_mesh = this; | attributes.triangle_mesh = this; | ||||
| curve_attributes.curve_mesh = this; | curve_attributes.curve_mesh = this; | ||||
| has_volume = false; | has_volume = false; | ||||
| has_surface_bssrdf = false; | |||||
| } | } | ||||
| Mesh::~Mesh() | Mesh::~Mesh() | ||||
| { | { | ||||
| delete bvh; | delete bvh; | ||||
| } | } | ||||
| void Mesh::reserve(int numverts, int numtris, int numcurves, int numcurvekeys) | void Mesh::reserve(int numverts, int numtris, int numcurves, int numcurvekeys) | ||||
| ▲ Show 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | |||||
| void Mesh::compute_bvh(SceneParams *params, Progress *progress, int n, int total) | void Mesh::compute_bvh(SceneParams *params, Progress *progress, int n, int total) | ||||
| { | { | ||||
| if(progress->get_cancel()) | if(progress->get_cancel()) | ||||
| return; | return; | ||||
| compute_bounds(); | compute_bounds(); | ||||
| if(!transform_applied) { | 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 | ||||
| msg += string_printf("%s %u/%u", name.c_str(), (uint)(n+1), (uint)total); | msg += string_printf("%s %u/%u", name.c_str(), (uint)(n+1), (uint)total); | ||||
| Object object; | Object object; | ||||
| object.mesh = this; | object.mesh = this; | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
| bool Mesh::has_motion_blur() const | bool Mesh::has_motion_blur() const | ||||
| { | { | ||||
| return (use_motion_blur && | return (use_motion_blur && | ||||
| (attributes.find(ATTR_STD_MOTION_VERTEX_POSITION) || | (attributes.find(ATTR_STD_MOTION_VERTEX_POSITION) || | ||||
| curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION))); | curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION))); | ||||
| } | } | ||||
| bool Mesh::need_build_bvh() const | |||||
| { | |||||
| return !transform_applied || has_surface_bssrdf; | |||||
| } | |||||
| /* Mesh Manager */ | /* Mesh Manager */ | ||||
| MeshManager::MeshManager() | MeshManager::MeshManager() | ||||
| { | { | ||||
| bvh = NULL; | bvh = NULL; | ||||
| need_update = true; | need_update = true; | ||||
| need_flags_update = true; | need_flags_update = true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 576 Lines • ▼ Show 20 Lines | void MeshManager::device_update_flags(Device * /*device*/, | ||||
| Progress& /*progress*/) | Progress& /*progress*/) | ||||
| { | { | ||||
| if(!need_update && !need_flags_update) { | if(!need_update && !need_flags_update) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* update flags */ | /* update flags */ | ||||
| foreach(Mesh *mesh, scene->meshes) { | foreach(Mesh *mesh, scene->meshes) { | ||||
| mesh->has_volume = false; | mesh->has_volume = false; | ||||
| foreach(uint shader, mesh->used_shaders) { | foreach(uint shader_index, mesh->used_shaders) { | ||||
| if(scene->shaders[shader]->has_volume) { | const Shader *shader = scene->shaders[shader_index]; | ||||
| if(shader->has_volume) { | |||||
| mesh->has_volume = true; | mesh->has_volume = true; | ||||
| } | } | ||||
| if(shader->has_surface_bssrdf) { | |||||
| mesh->has_surface_bssrdf = true; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| need_flags_update = false; | need_flags_update = false; | ||||
| } | } | ||||
| void MeshManager::device_update_displacement_images(Device *device, | void MeshManager::device_update_displacement_images(Device *device, | ||||
| DeviceScene *dscene, | DeviceScene *dscene, | ||||
| Scene *scene, | Scene *scene, | ||||
| ▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | if(displacement_done) { | ||||
| device_update_attributes(device, dscene, scene, progress); | device_update_attributes(device, dscene, scene, progress); | ||||
| if(progress.get_cancel()) return; | if(progress.get_cancel()) return; | ||||
| } | } | ||||
| /* update bvh */ | /* update bvh */ | ||||
| size_t i = 0, num_bvh = 0; | size_t i = 0, num_bvh = 0; | ||||
| foreach(Mesh *mesh, scene->meshes) | foreach(Mesh *mesh, scene->meshes) | ||||
| if(mesh->need_update && !mesh->transform_applied) | if(mesh->need_update && mesh->need_build_bvh()) | ||||
| num_bvh++; | num_bvh++; | ||||
| TaskPool pool; | TaskPool pool; | ||||
| 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->params, | &scene->params, | ||||
| &progress, | &progress, | ||||
| i, | i, | ||||
| num_bvh)); | num_bvh)); | ||||
| if(!mesh->transform_applied) { | if(mesh->need_build_bvh()) { | ||||
| i++; | i++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| pool.wait_work(); | pool.wait_work(); | ||||
| foreach(Shader *shader, scene->shaders) | foreach(Shader *shader, scene->shaders) | ||||
| shader->need_update_attributes = false; | shader->need_update_attributes = false; | ||||
| ▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines | |||||