[Bf-blender-cvs] [e0a833bbbf0] geometry-nodes-level-set-nodes: Cleanup: Use stringref type

Hans Goudey noreply at git.blender.org
Fri Aug 13 22:09:30 CEST 2021


Commit: e0a833bbbf0328eb09262f52b4ee4683886e0f05
Author: Hans Goudey
Date:   Fri Aug 13 11:30:22 2021 -0500
Branches: geometry-nodes-level-set-nodes
https://developer.blender.org/rBe0a833bbbf0328eb09262f52b4ee4683886e0f05

Cleanup: Use stringref type

===================================================================

M	source/blender/blenkernel/BKE_volume.h
M	source/blender/blenkernel/intern/volume.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h
index 26e5b26ed87..10e023c201f 100644
--- a/source/blender/blenkernel/BKE_volume.h
+++ b/source/blender/blenkernel/BKE_volume.h
@@ -161,6 +161,7 @@ bool BKE_volume_save(const struct Volume *volume,
 #ifdef __cplusplus
 #  include "BLI_float3.hh"
 #  include "BLI_float4x4.hh"
+#  include "BLI_string_ref.hh"
 
 bool BKE_volume_min_max(const Volume *volume, blender::float3 &r_min, blender::float3 &r_max);
 
@@ -168,8 +169,8 @@ bool BKE_volume_min_max(const Volume *volume, blender::float3 &r_min, blender::f
 #    include <openvdb/openvdb.h>
 #    include <openvdb/points/PointDataGrid.h>
 
-VolumeGrid *BKE_volume_grid_add_vdb(struct Volume *volume,
-                                    const char *name,
+VolumeGrid *BKE_volume_grid_add_vdb(Volume *volume,
+                                    blender::StringRef name,
                                     openvdb::FloatGrid::Ptr vdb_grid);
 
 bool BKE_volume_grid_bounds(openvdb::GridBase::ConstPtr grid,
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index 8cdabce579f..e787a9a52ce 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -36,6 +36,7 @@
 #include "BLI_math.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
+#include "BLI_string_ref.hh"
 #include "BLI_task.hh"
 #include "BLI_utildefines.h"
 
@@ -71,6 +72,7 @@ static CLG_LogRef LOG = {"bke.volume"};
 using blender::float3;
 using blender::float4x4;
 using blender::IndexRange;
+using blender::StringRef;
 
 #ifdef WITH_OPENVDB
 #  include <atomic>
@@ -1465,23 +1467,20 @@ VolumeGrid *BKE_volume_grid_add(Volume *volume, const char *name, VolumeGridType
 #endif
 }
 
+#ifdef WITH_OPENVDB
 VolumeGrid *BKE_volume_grid_add_vdb(Volume *volume,
-                                    const char *name,
+                                    const StringRef name,
                                     openvdb::FloatGrid::Ptr vdb_grid)
 {
-#ifdef WITH_OPENVDB
   VolumeGridVector &grids = *volume->runtime.grids;
-  BLI_assert(BKE_volume_grid_find_for_read(volume, name) == nullptr);
+  BLI_assert(BKE_volume_grid_find_for_read(volume, name.data()) == nullptr);
   BLI_assert(BKE_volume_grid_type_openvdb(*vdb_grid) != VOLUME_GRID_UNKNOWN);
 
   vdb_grid->setName(name);
   grids.emplace_back(vdb_grid);
   return &grids.back();
-#else
-  UNUSED_VARS(volume, name, type);
-  return nullptr;
-#endif
 }
+#endif
 
 void BKE_volume_grid_remove(Volume *volume, VolumeGrid *grid)
 {



More information about the Bf-blender-cvs mailing list