From 70e100b94d49ca758f1aef1d9b0e0c4d4c2e85fa Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 26 Jul 2023 12:59:12 +1000 Subject: [PATCH] On shader changes, make sure these are uploaded in the cases where an expensive object rebuild isn't required. --- src/scene/geometry.cpp | 29 +++++++++++++++++------------ src/scene/image_vdb.cpp | 9 +++++++++ src/scene/image_vdb.h | 2 ++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/scene/geometry.cpp b/src/scene/geometry.cpp index c32b584de..f14fccfb4 100644 --- a/src/scene/geometry.cpp +++ b/src/scene/geometry.cpp @@ -435,19 +435,24 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro /* Re-create volume mesh if we will rebuild or refit the BVH. Note we * should only do it in that case, otherwise the BVH and mesh can go * out of sync. */ - if (geom->is_modified() && geom->geometry_type == Geometry::VOLUME) { - /* Create volume meshes if there is voxel data. */ - if (!volume_images_updated) { - progress.set_status("Updating Meshes Volume Bounds"); - device_update_volume_images(device, scene, progress); - volume_images_updated = true; + if (geom->is_volume()) { + if (geom->need_update_rebuild) { + /* Create volume meshes if there is voxel data. */ + if (!volume_images_updated) { + progress.set_status("Updating Meshes Volume Bounds"); + device_update_volume_images(device, scene, progress); + volume_images_updated = true; + } + + Volume *volume = static_cast(geom); + create_volume_mesh(scene, volume, progress); + + /* always reallocate when we have a volume, as we need to rebuild the BVH */ + device_update_flags |= DEVICE_MESH_DATA_NEEDS_REALLOC; + } + else if (geom->is_modified()) { + device_update_flags |= DEVICE_MESH_DATA_MODIFIED; } - - Volume *volume = static_cast(geom); - create_volume_mesh(scene, volume, progress); - - /* always reallocate when we have a volume, as we need to rebuild the BVH */ - device_update_flags |= DEVICE_MESH_DATA_NEEDS_REALLOC; } if (geom->is_hair()) { diff --git a/src/scene/image_vdb.cpp b/src/scene/image_vdb.cpp index 478b88c6d..214bc18a2 100644 --- a/src/scene/image_vdb.cpp +++ b/src/scene/image_vdb.cpp @@ -265,4 +265,13 @@ openvdb::GridBase::ConstPtr VDBImageLoader::get_grid() } #endif +int VDBImageLoader::get_precision() const +{ +#ifdef WITH_NANOVDB + return precision; +#else + return 0; +#endif +} + CCL_NAMESPACE_END diff --git a/src/scene/image_vdb.h b/src/scene/image_vdb.h index 49853cf37..92c23c11b 100644 --- a/src/scene/image_vdb.h +++ b/src/scene/image_vdb.h @@ -40,6 +40,8 @@ class VDBImageLoader : public ImageLoader { virtual bool is_vdb_loader() const override; + int get_precision() const; + #ifdef WITH_OPENVDB openvdb::GridBase::ConstPtr get_grid(); #endif -- 2.30.2