Commit: aa09a46fd736061668746e027877b512cc124950 Author: Brecht Van Lommel Date: Tue Apr 21 13:09:41 2020 +0200 Branches: master https://developer.blender.org/rBaa09a46fd736061668746e027877b512cc124950
Objects: add infrastructure for hair, pointcloud, volume modifiers There is no user visible difference in standard builds, as there are no volume modifiers yet. When using WITH_NEW_OBJECT_TYPES some deform only modifiers are now available for hair and pointcloud objects. Differential Revision: https://developer.blender.org/D7141 =================================================================== M source/blender/blenkernel/BKE_modifier.h M source/blender/blenkernel/intern/DerivedMesh.c M source/blender/blenkernel/intern/displist.c M source/blender/blenkernel/intern/hair.c M source/blender/blenkernel/intern/lattice.c M source/blender/blenkernel/intern/mesh_convert.c M source/blender/blenkernel/intern/modifier.c M source/blender/blenkernel/intern/multires.c M source/blender/blenkernel/intern/object.c M source/blender/blenkernel/intern/pointcloud.c M source/blender/blenkernel/intern/volume.cc M source/blender/modifiers/intern/MOD_armature.c M source/blender/modifiers/intern/MOD_array.c M source/blender/modifiers/intern/MOD_bevel.c M source/blender/modifiers/intern/MOD_boolean.c M source/blender/modifiers/intern/MOD_build.c M source/blender/modifiers/intern/MOD_cast.c M source/blender/modifiers/intern/MOD_cloth.c M source/blender/modifiers/intern/MOD_collision.c M source/blender/modifiers/intern/MOD_correctivesmooth.c M source/blender/modifiers/intern/MOD_curve.c M source/blender/modifiers/intern/MOD_datatransfer.c M source/blender/modifiers/intern/MOD_decimate.c M source/blender/modifiers/intern/MOD_displace.c M source/blender/modifiers/intern/MOD_dynamicpaint.c M source/blender/modifiers/intern/MOD_edgesplit.c M source/blender/modifiers/intern/MOD_explode.c M source/blender/modifiers/intern/MOD_fluid.c M source/blender/modifiers/intern/MOD_hook.c M source/blender/modifiers/intern/MOD_laplaciandeform.c M source/blender/modifiers/intern/MOD_laplaciansmooth.c M source/blender/modifiers/intern/MOD_lattice.c M source/blender/modifiers/intern/MOD_mask.cc M source/blender/modifiers/intern/MOD_meshcache.c M source/blender/modifiers/intern/MOD_meshdeform.c M source/blender/modifiers/intern/MOD_meshsequencecache.c M source/blender/modifiers/intern/MOD_mirror.c M source/blender/modifiers/intern/MOD_multires.c M source/blender/modifiers/intern/MOD_none.c M source/blender/modifiers/intern/MOD_normal_edit.c M source/blender/modifiers/intern/MOD_ocean.c M source/blender/modifiers/intern/MOD_particleinstance.c M source/blender/modifiers/intern/MOD_particlesystem.c M source/blender/modifiers/intern/MOD_remesh.c M source/blender/modifiers/intern/MOD_screw.c M source/blender/modifiers/intern/MOD_shapekey.c M source/blender/modifiers/intern/MOD_shrinkwrap.c M source/blender/modifiers/intern/MOD_simpledeform.c M source/blender/modifiers/intern/MOD_skin.c M source/blender/modifiers/intern/MOD_smooth.c M source/blender/modifiers/intern/MOD_softbody.c M source/blender/modifiers/intern/MOD_solidify.c M source/blender/modifiers/intern/MOD_solidify_extrude.c M source/blender/modifiers/intern/MOD_solidify_nonmanifold.c M source/blender/modifiers/intern/MOD_solidify_util.h M source/blender/modifiers/intern/MOD_subsurf.c M source/blender/modifiers/intern/MOD_surface.c M source/blender/modifiers/intern/MOD_surfacedeform.c M source/blender/modifiers/intern/MOD_triangulate.c M source/blender/modifiers/intern/MOD_uvproject.c M source/blender/modifiers/intern/MOD_uvwarp.c M source/blender/modifiers/intern/MOD_warp.c M source/blender/modifiers/intern/MOD_wave.c M source/blender/modifiers/intern/MOD_weighted_normal.c M source/blender/modifiers/intern/MOD_weightvgedit.c M source/blender/modifiers/intern/MOD_weightvgmix.c M source/blender/modifiers/intern/MOD_weightvgproximity.c M source/blender/modifiers/intern/MOD_weld.c M source/blender/modifiers/intern/MOD_wireframe.c =================================================================== diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index c37e56149eb..3a3be7e82c2 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -100,7 +100,7 @@ typedef enum { /* For modifiers that use CD_PREVIEW_MCOL for preview. */ eModifierTypeFlag_UsesPreview = (1 << 9), - eModifierTypeFlag_AcceptsLattice = (1 << 10), + eModifierTypeFlag_AcceptsVertexCosOnly = (1 << 10), } ModifierTypeFlag; /* IMPORTANT! Keep ObjectWalkFunc and IDWalkFunc signatures compatible. */ @@ -211,18 +211,28 @@ typedef struct ModifierTypeInfo { /********************* Non-deform modifier functions *********************/ - /* For non-deform types: apply the modifier and return a mesh object. + /* For non-deform types: apply the modifier and return a mesh datablock. * - * The mesh argument should always be non-NULL; the modifier - * should read the object data from the mesh object instead of the - * actual object data. + * The mesh argument should always be non-NULL; the modifier should use the + * passed in mesh datablock rather than object->data, as it contains the mesh + * with modifier applied up to this point. * - * The modifier may reuse the mesh argument (i.e. return it in - * modified form), but must not release it. + * The modifier may modify and return the mesh argument, but must not free it + * and must ensure any referenced data layers are converted to non-referenced + * before modification. */ - struct Mesh *(*applyModifier)(struct ModifierData *md, - const struct ModifierEvalContext *ctx, - struct Mesh *mesh); + struct Mesh *(*modifyMesh)(struct ModifierData *md, + const struct ModifierEvalContext *ctx, + struct Mesh *mesh); + struct Hair *(*modifyHair)(struct ModifierData *md, + const struct ModifierEvalContext *ctx, + struct Hair *hair); + struct PointCloud *(*modifyPointCloud)(struct ModifierData *md, + const struct ModifierEvalContext *ctx, + struct PointCloud *pointcloud); + struct Volume *(*modifyVolume)(struct ModifierData *md, + const struct ModifierEvalContext *ctx, + struct Volume *volume); /********************* Optional functions *********************/ @@ -450,9 +460,9 @@ struct ModifierData *modifier_get_evaluated(struct Depsgraph *depsgraph, /* wrappers for modifier callbacks that ensure valid normals */ -struct Mesh *modwrap_applyModifier(ModifierData *md, - const struct ModifierEvalContext *ctx, - struct Mesh *me); +struct Mesh *modwrap_modifyMesh(ModifierData *md, + const struct ModifierEvalContext *ctx, + struct Mesh *me); void modwrap_deformVerts(ModifierData *md, const struct ModifierEvalContext *ctx, diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index baef2b2290e..f67e49aef06 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -907,10 +907,10 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, const bool sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm) && !use_render; /* Modifier evaluation contexts for different types of modifiers. */ - ModifierApplyFlag app_render = use_render ? MOD_APPLY_RENDER : 0; - ModifierApplyFlag app_cache = use_cache ? MOD_APPLY_USECACHE : 0; - const ModifierEvalContext mectx = {depsgraph, ob, app_render | app_cache}; - const ModifierEvalContext mectx_orco = {depsgraph, ob, app_render | MOD_APPLY_ORCO}; + ModifierApplyFlag apply_render = use_render ? MOD_APPLY_RENDER : 0; + ModifierApplyFlag apply_cache = use_cache ? MOD_APPLY_USECACHE : 0; + const ModifierEvalContext mectx = {depsgraph, ob, apply_render | apply_cache}; + const ModifierEvalContext mectx_orco = {depsgraph, ob, apply_render | MOD_APPLY_ORCO}; /* Get effective list of modifiers to execute. Some effects like shape keys * are added as virtual modifiers before the user created modifiers. */ @@ -1176,7 +1176,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, } } - Mesh *mesh_next = modwrap_applyModifier(md, &mectx, mesh_final); + Mesh *mesh_next = modwrap_modifyMesh(md, &mectx, mesh_final); ASSERT_IS_VALID_MESH(mesh_next); if (mesh_next) { @@ -1212,7 +1212,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, CustomData_MeshMasks_update(&temp_cddata_masks, &nextmask); mesh_set_only_copy(mesh_orco, &temp_cddata_masks); - mesh_next = modwrap_applyModifier(md, &mectx_orco, mesh_orco); + mesh_next = modwrap_modifyMesh(md, &mectx_orco, mesh_orco); ASSERT_IS_VALID_MESH(mesh_next); if (mesh_next) { @@ -1238,7 +1238,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, nextmask.pmask |= CD_MASK_ORIGINDEX; mesh_set_only_copy(mesh_orco_cloth, &nextmask); - mesh_next = modwrap_applyModifier(md, &mectx_orco, mesh_orco_cloth); + mesh_next = modwrap_modifyMesh(md, &mectx_orco, mesh_orco_cloth); ASSERT_IS_VALID_MESH(mesh_next); if (mesh_next) { @@ -1595,7 +1595,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph, mask.pmask |= CD_MASK_ORIGINDEX; mesh_set_only_copy(mesh_orco, &mask); - Mesh *mesh_next = modwrap_applyModifier(md, &mectx_orco, mesh_orco); + Mesh *mesh_next = modwrap_modifyMesh(md, &mectx_orco, mesh_orco); ASSERT_IS_VALID_MESH(mesh_next); if (mesh_next) { @@ -1626,7 +1626,7 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph, } } - Mesh *mesh_next = modwrap_applyModifier(md, &mectx, mesh_final); + Mesh *mesh_next = modwrap_modifyMesh(md, &mectx, mesh_final); ASSERT_IS_VALID_MESH(mesh_next); if (mesh_next) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 907e7eb66ec..a18579f9402 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -857,7 +857,7 @@ static void curve_calc_modifiers_pre( Curve *cu = ob->data; int numElems = 0, numVerts = 0; const bool editmode = (!for_render && (cu->editnurb || cu->editfont)); - ModifierApplyFlag app_flag = 0; + ModifierApplyFlag apply_flag = 0; float(*deformedVerts)[3] = NULL; float *keyVerts = NULL; int required_mode; @@ -865,17 +865,17 @@ static void curve_calc_modifiers_pre( modifiers_clearErrors(ob); if (editmode) { - app_flag |= MOD_APPLY_USECACHE; + apply_flag |= MOD_APPLY_USECACHE; } if (for_render) { - app_flag |= MOD_APPLY_RENDER; + apply_flag |= MOD_APPLY_RENDER; required_mode = eModifierMode_Render; } else { required_mode = eModifierMode_Realtime; } - const ModifierEvalContext mectx = {depsgraph, ob, app_flag}; + const ModifierEvalContext mectx = {depsgraph, ob, apply_flag}; pretessellatePoint = curve_get_tessellate_point(scene, ob, for_render, editmode); @@ -985,10 +985,10 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph, Mesh *modified = NULL, *mesh_applied; float(*vertCos)[3] = NULL; int useCache = !for_render; - ModifierApplyFlag app_flag = 0; + ModifierApplyFlag apply_flag = 0; if (for_render) { - app_flag |= MOD_APPLY_RENDER; + apply_flag |= MOD_APPLY_RENDER; required_mode = eModifierMode_Render; } else { @@ -996,9 +996,9 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph, } const ModifierEvalContext mectx_deform = { - depsgraph, ob, editmode ? app_flag | MOD_APPLY_USECACHE : app_flag}; + depsgraph, ob, editmode ? apply_flag | MOD_APPLY_USECACHE : apply_flag}; const ModifierEvalContext mectx_apply = { - depsgraph, ob, useCache ? app_flag | MOD_APPLY_USECACHE : app_flag}; + depsgraph, ob, useCache ? apply_flag | MOD_APPLY_USECACHE : apply_flag}; pretessellatePoint = curve_get_tessellate_point(scene, ob, for_render, editmode); @@ -1095,7 +1095,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph, if (need_normal) { BKE_mesh_ensure_normals(modified); } - mesh_applied = mti->applyModifier(md, &mectx_apply, modified); + mesh_applied = mti->modifyMesh(md, &mectx_apply, modified); if (mesh_applied) { /* Modifier returned a new derived mesh */ diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c index 5cdb7761540..9d66b509c72 100644 --- a/source/blender/blenkernel/intern/hair.c +++ b/source/blender/blenkernel/intern/hair.c @@ -247,12 +247,65 @@ Hair *BKE_hair_copy_for_eval(Hair *hair_src, bool reference) return result; } -static Hair *hair_evaluate_modifiers(struct Depsgraph *UNUSED(depsgraph), - struct Scene *UNUSED(scene), - Object *UNUSED(object), +static Hair *hair_evaluate_modifiers(struct Depsgraph *depsgraph, + struct Scene *scene, + Object *object, Hair *hair_input) { - return hair_input; + Hair *hair = hair_input; + + /* Modifier evaluation modes. */ + const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); + const int required_mode = use_render ? eModifierMode_Render : eModifierMode_Realtime; + ModifierApplyFlag apply_flag = use_render ? MOD_APPLY_RENDER : MOD_APPLY_USECACHE; + const ModifierEvalContext mectx = {depsgraph, object, apply_flag}; + + /* Get effective list of modifiers to execute. Some effects like shape keys + * are added as virtual modifiers before the user created modifiers. */ + Virtu @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] https://lists.blender.org/mailman/listinfo/bf-blender-cvs
