diff options
author | Hans Goudey <h.goudey@me.com> | 2021-04-26 22:42:03 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-04-26 22:42:03 +0300 |
commit | e032ca2e25bf2e305b660da7a6026834e2e5006f (patch) | |
tree | aca3fa8d4ab413c3e95518d7450a2af9dda21c6a /source/blender/modifiers/intern/MOD_volume_displace.cc | |
parent | a7bda035163ec07901d590389a04d1730b291f13 (diff) |
Cleanup: Replace modifyVolume with modifyGeometrySet
This allows us to remove a callback from the modifier type info struct.
In the future the these modifiers might just be replaced by nodes
internally anyway, but in the meantime it's nice to unify the handling
of evaluated geometry a bit.
Differential Revision: https://developer.blender.org/D11080
Diffstat (limited to 'source/blender/modifiers/intern/MOD_volume_displace.cc')
-rw-r--r-- | source/blender/modifiers/intern/MOD_volume_displace.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc index e7c4004853e..6a148e824fa 100644 --- a/source/blender/modifiers/intern/MOD_volume_displace.cc +++ b/source/blender/modifiers/intern/MOD_volume_displace.cc @@ -18,6 +18,7 @@ * \ingroup modifiers */ +#include "BKE_geometry_set.hh" #include "BKE_lib_query.h" #include "BKE_mesh_runtime.h" #include "BKE_modifier.h" @@ -284,7 +285,7 @@ struct DisplaceGridOp { #endif -static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Volume *volume) +static void displace_volume(ModifierData *md, const ModifierEvalContext *ctx, Volume *volume) { #ifdef WITH_OPENVDB VolumeDisplaceModifierData *vdmd = reinterpret_cast<VolumeDisplaceModifierData *>(md); @@ -303,14 +304,22 @@ static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, Vo BKE_volume_grid_type_operation(grid_type, displace_grid_op); } - return volume; #else UNUSED_VARS(md, ctx); BKE_modifier_set_error(ctx->object, md, "Compiled without OpenVDB"); - return volume; #endif } +static void modifyGeometrySet(ModifierData *md, + const ModifierEvalContext *ctx, + GeometrySet *geometry_set) +{ + Volume *input_volume = geometry_set->get_volume_for_write(); + if (input_volume != nullptr) { + displace_volume(md, ctx, input_volume); + } +} + ModifierTypeInfo modifierType_VolumeDisplace = { /* name */ "Volume Displace", /* structName */ "VolumeDisplaceModifierData", @@ -328,8 +337,7 @@ ModifierTypeInfo modifierType_VolumeDisplace = { /* deformMatricesEM */ nullptr, /* modifyMesh */ nullptr, /* modifyHair */ nullptr, - /* modifyGeometrySet */ nullptr, - /* modifyVolume */ modifyVolume, + /* modifyGeometrySet */ modifyGeometrySet, /* initData */ initData, /* requiredDataMask */ nullptr, |