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/blenkernel | |
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/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_geometry_set.hh | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/geometry_set.cc | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/volume.cc | 18 |
5 files changed, 12 insertions, 24 deletions
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 58935aca0a8..89cdef34297 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -380,6 +380,8 @@ struct GeometrySet { void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); void replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership = GeometryOwnershipType::Owned); + void replace_volume(Volume *volume, + GeometryOwnershipType ownership = GeometryOwnershipType::Owned); }; /** A geometry component that can store a mesh. */ diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index ab2ecbe2507..c0153dd8241 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -258,10 +258,6 @@ typedef struct ModifierTypeInfo { const struct ModifierEvalContext *ctx, struct GeometrySet *geometry_set); - struct Volume *(*modifyVolume)(struct ModifierData *md, - const struct ModifierEvalContext *ctx, - struct Volume *volume); - /********************* Optional functions *********************/ /** diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 3e457e48076..6ae78343fea 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -306,6 +306,13 @@ void GeometrySet::replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipTy pointcloud_component.replace(pointcloud, ownership); } +/* Clear the existing volume and replace with the given one. */ +void GeometrySet::replace_volume(Volume *volume, GeometryOwnershipType ownership) +{ + VolumeComponent &volume_component = this->get_component_for_write<VolumeComponent>(); + volume_component.replace(volume, ownership); +} + /* Returns a mutable mesh or null. No ownership is transferred. */ Mesh *GeometrySet::get_mesh_for_write() { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 522b4549f57..24593bf3812 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1332,12 +1332,9 @@ bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) if (ob->type == OB_HAIR) { return (mti->modifyHair != NULL) || (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly); } - if (ob->type == OB_POINTCLOUD) { + if (ELEM(ob->type, OB_POINTCLOUD, OB_VOLUME)) { return (mti->modifyGeometrySet != NULL); } - if (ob->type == OB_VOLUME) { - return (mti->modifyVolume != NULL) || (mti->modifyGeometrySet != NULL); - } if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { if (ob->type == OB_LATTICE && (mti->flags & eModifierTypeFlag_AcceptsVertexCosOnly) == 0) { return false; diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 93d5e116131..c0ce57818d1 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -1007,7 +1007,6 @@ static void volume_update_simplify_level(Volume *volume, const Depsgraph *depsgr static void volume_evaluate_modifiers(struct Depsgraph *depsgraph, struct Scene *scene, Object *object, - Volume *volume_input, GeometrySet &geometry_set) { /* Modifier evaluation modes. */ @@ -1033,18 +1032,6 @@ static void volume_evaluate_modifiers(struct Depsgraph *depsgraph, if (mti->modifyGeometrySet) { mti->modifyGeometrySet(md, &mectx, &geometry_set); } - else if (mti->modifyVolume) { - VolumeComponent &volume_component = geometry_set.get_component_for_write<VolumeComponent>(); - Volume *volume_old = volume_component.get_for_write(); - if (volume_old == nullptr) { - volume_old = BKE_volume_new_for_eval(volume_input); - volume_component.replace(volume_old); - } - Volume *volume_new = mti->modifyVolume(md, &mectx, volume_old); - if (volume_new != volume_old) { - volume_component.replace(volume_new); - } - } } } @@ -1095,9 +1082,8 @@ void BKE_volume_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob /* Evaluate modifiers. */ Volume *volume = (Volume *)object->data; GeometrySet geometry_set; - VolumeComponent &volume_component = geometry_set.get_component_for_write<VolumeComponent>(); - volume_component.replace(volume, GeometryOwnershipType::ReadOnly); - volume_evaluate_modifiers(depsgraph, scene, object, volume, geometry_set); + geometry_set.replace_volume(volume, GeometryOwnershipType::ReadOnly); + volume_evaluate_modifiers(depsgraph, scene, object, geometry_set); Volume *volume_eval = take_volume_ownership_from_geometry_set(geometry_set); |