Commit: 56ba20e08a7f0dc7247d43f27cb81354eb838ec6 Author: Kévin Dietrich Date: Wed Oct 14 14:33:40 2020 +0200 Branches: cycles_procedural_api https://developer.blender.org/rB56ba20e08a7f0dc7247d43f27cb81354eb838ec6
add some flags to detect geometry addition and removal =================================================================== M intern/cycles/render/geometry.cpp M intern/cycles/render/geometry.h M intern/cycles/render/scene.cpp =================================================================== diff --git a/intern/cycles/render/geometry.cpp b/intern/cycles/render/geometry.cpp index 4359956bb73..7553e56a751 100644 --- a/intern/cycles/render/geometry.cpp +++ b/intern/cycles/render/geometry.cpp @@ -953,7 +953,7 @@ void GeometryManager::device_update_mesh( if (geom->geometry_type == Geometry::MESH || geom->geometry_type == Geometry::VOLUME) { Mesh *mesh = static_cast<Mesh *>(geom); - if (mesh->shader_is_modified() || mesh->smooth_is_modified() || mesh->triangles_is_modified() || (device_update_flags & (DEVICE_TRIANGLES_NEEDS_REALLOC | DEVICE_VERTEX_NEEDS_REALLOC))) { + if (mesh->shader_is_modified() || mesh->smooth_is_modified() || mesh->triangles_is_modified() || (device_update_flags & DEVICE_CURVE_DATA_NEEDS_REALLOC)) { //std::cerr << "-- pack shaders for : " << mesh->name << '\n'; //number_packed_shaders += 1; tri_shader_modified = true; @@ -965,7 +965,7 @@ void GeometryManager::device_update_mesh( tri_patch_uv_modified |= mesh->vert_patch_uv_is_modified(); vnormal_modified |= mesh->triangles_is_modified() || mesh->verts_is_modified(); - if (mesh->triangles_is_modified() || mesh->verts_is_modified() || (device_update_flags & (DEVICE_TRIANGLES_NEEDS_REALLOC | DEVICE_VERTEX_NEEDS_REALLOC))) { + if (mesh->triangles_is_modified() || mesh->verts_is_modified() || (device_update_flags & DEVICE_MESH_DATA_NEEDS_REALLOC)) { //std::cerr << "-- pack verts for : " << mesh->name << '\n'; //number_packed_verts += 1; mesh->pack_normals(&vnormal[mesh->vert_offset]); @@ -1258,8 +1258,7 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro Volume *volume = static_cast<Volume *>(geom); create_volume_mesh(volume, progress); - device_update_flags |= DEVICE_VERTEX_NEEDS_REALLOC; - device_update_flags |= DEVICE_TRIANGLES_NEEDS_REALLOC; + device_update_flags |= DEVICE_MESH_DATA_NEEDS_REALLOC; } if (geom->is_hair()) { @@ -1278,7 +1277,7 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro } } - //geom->print_modified_sockets(); + geom->print_modified_sockets(); if (geom->is_mesh()) { Mesh *mesh = static_cast<Mesh *>(geom); @@ -1295,7 +1294,15 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro } } - //std::cerr << "device_update_flags: " << device_update_flags << '\n'; + if (update_flags & (MESH_ADDED | MESH_REMOVED)) { + device_update_flags |= DEVICE_MESH_DATA_NEEDS_REALLOC; + } + + if (update_flags & (HAIR_ADDED | HAIR_REMOVED)) { + device_update_flags |= DEVICE_CURVE_DATA_NEEDS_REALLOC; + } + + std::cerr << "device_update_flags: " << device_update_flags << '\n'; need_flags_update = false; } @@ -1409,7 +1416,9 @@ void GeometryManager::device_update(Device *device, if (shader->need_update_displacement) { // todo: tag all displacement related sockets as modified - geom->tag_modified(); + if (geom->is_mesh()) { + geom->tag_modified(); + } } } @@ -1426,8 +1435,7 @@ void GeometryManager::device_update(Device *device, } /* Test if we need tessellation. */ - if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE && mesh->num_subd_verts == 0 && - mesh->get_subd_params()) { + if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE && mesh->get_subd_params() && (mesh->verts_is_modified() || mesh->subd_dicing_rate_is_modified() || mesh->subd_max_level_is_modified())) { total_tess_needed++; } @@ -1463,8 +1471,7 @@ void GeometryManager::device_update(Device *device, } Mesh *mesh = static_cast<Mesh *>(geom); - if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE && mesh->num_subd_verts == 0 && - mesh->get_subd_params()) { + if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE && mesh->get_subd_params() && (mesh->verts_is_modified() || mesh->subd_dicing_rate_is_modified() || mesh->subd_max_level_is_modified())) { string msg = "Tessellating "; if (mesh->name == "") msg += string_printf("%u/%u", (uint)(i + 1), (uint)total_tess_needed); @@ -1478,6 +1485,8 @@ void GeometryManager::device_update(Device *device, DiagSplit dsplit(*mesh->subd_params); mesh->tessellate(&dsplit); + device_update_flags |= DEVICE_MESH_DATA_NEEDS_REALLOC; + i++; if (progress.get_cancel()) @@ -1651,6 +1660,7 @@ void GeometryManager::device_update(Device *device, } need_update = false; + update_flags = 0; if (true_displacement_used) { /* Re-tag flags for update, so they're re-evaluated diff --git a/intern/cycles/render/geometry.h b/intern/cycles/render/geometry.h index 31a6ad939d9..2b19d8e1b6d 100644 --- a/intern/cycles/render/geometry.h +++ b/intern/cycles/render/geometry.h @@ -161,12 +161,23 @@ class GeometryManager { DEVICE_TRIANGLES_NEEDS_REALLOC = (1 << 1), DEVICE_CURVES_NEEDS_REALLOC = (1 << 2), DEVICE_CURVE_KEYS_NEEDS_REALLOC = (1 << 3), + + DEVICE_MESH_DATA_NEEDS_REALLOC = (DEVICE_VERTEX_NEEDS_REALLOC | DEVICE_TRIANGLES_NEEDS_REALLOC), + DEVICE_CURVE_DATA_NEEDS_REALLOC = (DEVICE_CURVES_NEEDS_REALLOC | DEVICE_CURVE_KEYS_NEEDS_REALLOC), }; DeviceUpdateFlags device_update_flags; public: + enum { + MESH_ADDED = (1 << 0), + MESH_REMOVED = (1 << 1), + HAIR_ADDED = (1 << 2), + HAIR_REMOVED = (1 << 3), + }; + /* Update Flags */ + uint32_t update_flags = 0; bool need_update; bool need_flags_update; diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index 93855ab2740..16fe11530b8 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -618,6 +618,7 @@ template<> Mesh *Scene::create_node<Mesh>() node->set_owner(this); geometry.push_back(node); geometry_manager->tag_update(this); + geometry_manager->update_flags |= GeometryManager::MESH_ADDED; return node; } @@ -627,6 +628,7 @@ template<> Hair *Scene::create_node<Hair>() node->set_owner(this); geometry.push_back(node); geometry_manager->tag_update(this); + geometry_manager->update_flags |= GeometryManager::HAIR_ADDED; return node; } @@ -636,6 +638,7 @@ template<> Volume *Scene::create_node<Volume>() node->set_owner(this); geometry.push_back(node); geometry_manager->tag_update(this); + geometry_manager->update_flags |= GeometryManager::MESH_ADDED; return node; } @@ -698,22 +701,32 @@ template<> void Scene::delete_node_impl(Mesh *node) { delete_node_from_array(geometry, static_cast<Geometry *>(node)); geometry_manager->tag_update(this); + geometry_manager->update_flags |= GeometryManager::MESH_REMOVED; } template<> void Scene::delete_node_impl(Hair *node) { delete_node_from_array(geometry, static_cast<Geometry *>(node)); geometry_manager->tag_update(this); + geometry_manager->update_flags |= GeometryManager::HAIR_REMOVED; } template<> void Scene::delete_node_impl(Volume *node) { delete_node_from_array(geometry, static_cast<Geometry *>(node)); geometry_manager->tag_update(this); + geometry_manager->update_flags |= GeometryManager::MESH_REMOVED; } template<> void Scene::delete_node_impl(Geometry *node) { + if (node->is_hair()) { + geometry_manager->update_flags |= GeometryManager::HAIR_REMOVED; + } + else { + geometry_manager->update_flags |= GeometryManager::MESH_REMOVED; + } + delete_node_from_array(geometry, node); geometry_manager->tag_update(this); } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs