Cleanup: Avoid passing context to shrinkwrap blenkernel function

Such lower level functions generally shouldn't know about Blender's
overall context. If that spreads everywhere, things get hard to reason
about.
This commit is contained in:
Hans Goudey
2023-12-04 15:29:40 -05:00
parent 695e626d3f
commit c293c75975
3 changed files with 10 additions and 8 deletions

View File

@@ -28,7 +28,6 @@
* (So that you don't have to pass an enormous amount of arguments to functions)
*/
struct bContext;
struct BVHTree;
struct MDeformVert;
struct Mesh;
@@ -122,7 +121,10 @@ void shrinkwrapGpencilModifier_deform(ShrinkwrapGpencilModifierData *mmd,
/**
* Used in `editmesh_mask_extract.cc` to shrink-wrap the extracted mesh to the sculpt.
*/
void BKE_shrinkwrap_mesh_nearest_surface_deform(bContext *C, Object *ob_source, Object *ob_target);
void BKE_shrinkwrap_mesh_nearest_surface_deform(Depsgraph *depsgraph,
Scene *scene,
Object *ob_source,
Object *ob_target);
/**
* Used in `object_remesh.cc` to preserve the details and volume in the voxel remesher.

View File

@@ -29,7 +29,6 @@
#include "BKE_DerivedMesh.hh"
#include "BKE_attribute.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_context.hh"
#include "BKE_lattice.hh"
#include "BKE_lib_id.h"
#include "BKE_modifier.hh"
@@ -1517,10 +1516,11 @@ void shrinkwrapGpencilModifier_deform(ShrinkwrapGpencilModifierData *mmd,
}
}
void BKE_shrinkwrap_mesh_nearest_surface_deform(bContext *C, Object *ob_source, Object *ob_target)
void BKE_shrinkwrap_mesh_nearest_surface_deform(Depsgraph *depsgraph,
Scene *scene,
Object *ob_source,
Object *ob_target)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *sce = CTX_data_scene(C);
ShrinkwrapModifierData ssmd = {{nullptr}};
ModifierEvalContext ctx = {depsgraph, ob_source, ModifierApplyFlag(0)};
@@ -1534,7 +1534,7 @@ void BKE_shrinkwrap_mesh_nearest_surface_deform(bContext *C, Object *ob_source,
shrinkwrapModifier_deform(
&ssmd,
&ctx,
sce,
scene,
ob_source,
src_me,
nullptr,

View File

@@ -218,7 +218,7 @@ static int geometry_extract_apply(bContext *C,
BKE_mesh_copy_parameters_for_eval(new_ob_mesh, mesh);
if (params->apply_shrinkwrap) {
BKE_shrinkwrap_mesh_nearest_surface_deform(C, new_ob, ob);
BKE_shrinkwrap_mesh_nearest_surface_deform(CTX_data_depsgraph_pointer(C), scene, new_ob, ob);
}
if (params->add_solidify) {