Commit: be4df85919b42cb2cf8a01c904a8552c5c173944 Author: Mai Lavelle Date: Wed Apr 18 15:45:54 2018 +0200 Branches: blender2.8 https://developer.blender.org/rBbe4df85919b42cb2cf8a01c904a8552c5c173944
Modifiers: Add wrapper functions with Mesh / DerivedMesh conversion Makes the follow changes: - Add new `deform*` and `apply*` function pointers to `ModifierTypeInfo` that take `Mesh`, and rename the old functions to indicate that they take `DerivedMesh`. These new functions are currently set to `NULL` for all modifiers. - Add wrapper `modifier_deform*` and `modifier_apply*` functions in two variants: one that works with `Mesh` and the other which works with `DerivedMesh` that is named with `*_DM_depercated`. These functions check which type of data the modifier supports and converts if necessary - Update the rest of Blender to be aware and make use of these new functions The goal of these changes is to make it possible to port to using `Mesh` incrementally without ever needing to enter into a state where modifiers don't work. After everything has been ported over the old functions and wrappers could be removed. Reviewers: campbellbarton, sergey, mont29 Subscribers: sybren Tags: #bf_blender_2.8 Differential Revision: https://developer.blender.org/D3155 =================================================================== M source/blender/blenkernel/BKE_modifier.h M source/blender/blenkernel/intern/DerivedMesh.c M source/blender/blenkernel/intern/crazyspace.c M source/blender/blenkernel/intern/displist.c M source/blender/blenkernel/intern/lattice.c M source/blender/blenkernel/intern/modifier.c M source/blender/blenkernel/intern/multires.c M source/blender/editors/object/object_modifier.c 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_fluidsim.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.c 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_smoke.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_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_weightvgedit.c M source/blender/modifiers/intern/MOD_weightvgmix.c M source/blender/modifiers/intern/MOD_weightvgproximity.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 c81c0f7c4c0..09614a8e63f 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -35,6 +35,7 @@ struct ID; struct Depsgraph; struct DerivedMesh; +struct Mesh; struct Object; struct Scene; struct ViewLayer; @@ -156,37 +157,38 @@ typedef struct ModifierTypeInfo { */ void (*copyData)(struct ModifierData *md, struct ModifierData *target); - /********************* Deform modifier functions *********************/ + + /********************* Deform modifier functions *********************/ /* DEPRECATED */ /* Only for deform types, should apply the deformation * to the given vertex array. If the deformer requires information from * the object it can obtain it from the derivedData argument if non-NULL, * and otherwise the ob argument. */ - void (*deformVerts)(struct ModifierData *md, struct Depsgraph *depsgraph, + void (*deformVerts_DM)(struct ModifierData *md, struct Depsgraph *depsgraph, struct Object *ob, struct DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, ModifierApplyFlag flag); /* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */ - void (*deformMatrices)(struct ModifierData *md, struct Depsgraph *depsgraph, + void (*deformMatrices_DM)(struct ModifierData *md, struct Depsgraph *depsgraph, struct Object *ob, struct DerivedMesh *derivedData, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); /* Like deformVerts but called during editmode (for supporting modifiers) */ - void (*deformVertsEM)(struct ModifierData *md, struct Depsgraph *depsgraph, + void (*deformVertsEM_DM)(struct ModifierData *md, struct Depsgraph *depsgraph, struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts); /* Set deform matrix per vertex for crazyspace correction */ - void (*deformMatricesEM)(struct ModifierData *md, struct Depsgraph *depsgraph, + void (*deformMatricesEM_DM)(struct ModifierData *md, struct Depsgraph *depsgraph, struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *derivedData, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); - /********************* Non-deform modifier functions *********************/ + /********************* Non-deform modifier functions *********************/ /* DEPRECATED */ /* For non-deform types: apply the modifier and return a derived * data object (type is dependent on object type). @@ -207,7 +209,7 @@ typedef struct ModifierTypeInfo { * The modifier may reuse the derivedData argument (i.e. return it in * modified form), but must not release it. */ - struct DerivedMesh *(*applyModifier)(struct ModifierData *md, struct Depsgraph *depsgraph, + struct DerivedMesh *(*applyModifier_DM)(struct ModifierData *md, struct Depsgraph *depsgraph, struct Object *ob, struct DerivedMesh *derivedData, ModifierApplyFlag flag); @@ -218,11 +220,77 @@ typedef struct ModifierTypeInfo { * are expected from editmode objects. The same qualifications regarding * derivedData apply as for applyModifier. */ - struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, struct Depsgraph *depsgraph, + struct DerivedMesh *(*applyModifierEM_DM)(struct ModifierData *md, struct Depsgraph *depsgraph, struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *derivedData, ModifierApplyFlag flag); + /********************* Deform modifier functions *********************/ + + /* Only for deform types, should apply the deformation + * to the given vertex array. If the deformer requires information from + * the object it can obtain it from the mesh argument if non-NULL, + * and otherwise the ob argument. + */ + void (*deformVerts)(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct Mesh *mesh, + float (*vertexCos)[3], int numVerts, + ModifierApplyFlag flag); + + /* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */ + void (*deformMatrices)(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct Mesh *mesh, + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); + + /* Like deformVerts but called during editmode (for supporting modifiers) + */ + void (*deformVertsEM)(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct BMEditMesh *editData, + struct Mesh *mesh, + float (*vertexCos)[3], int numVerts); + + /* Set deform matrix per vertex for crazyspace correction */ + void (*deformMatricesEM)(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct BMEditMesh *editData, + struct Mesh *mesh, + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); + + /********************* Non-deform modifier functions *********************/ + + /* For non-deform types: apply the modifier and return a mesh object. + * + * 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 useRenderParams argument indicates if the modifier is being + * applied in the service of the renderer which may alter quality + * settings. + * + * The isFinalCalc parameter indicates if the modifier is being + * calculated for a final result or for something temporary + * (like orcos). This is a hack at the moment, it is meant so subsurf + * can know if it is safe to reuse its internal cache. + * + * The modifier may reuse the mesh argument (i.e. return it in + * modified form), but must not release it. + */ + struct Mesh *(*applyModifier)(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct Mesh *mesh, + ModifierApplyFlag flag); + + /* Like applyModifier but called during editmode (for supporting + * modifiers). + * + * The mesh object that is returned must support the operations that + * are expected from editmode objects. The same qualifications regarding + * mesh apply as for applyModifier. + */ + struct Mesh *(*applyModifierEM)(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct BMEditMesh *editData, + struct Mesh *mesh, ModifierApplyFlag flag); + + /********************* Optional functions *********************/ /* Initialize new instance data for this modifier type, this function @@ -419,7 +487,7 @@ void modifier_path_init(char *path, int path_maxlen, const char *name); const char *modifier_path_relbase(struct Object *ob); -/* wrappers for modifier callbacks */ +/* wrappers for modifier callbacks that ensure valid normals */ struct DerivedMesh *modwrap_applyModifier( ModifierData *md, struct Depsgraph *depsgraph, @@ -443,5 +511,59 @@ void modwrap_deformVertsEM( struct BMEditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts); +/* wrappers for modifier callbacks that accept Mesh and select the proper implementation + * depending on if the modifier has been ported to Mesh or is still using DerivedMesh + */ + +void modifier_deformVerts(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct Mesh *mesh, + float (*vertexCos)[3], int numVerts, + ModifierApplyFlag flag); + +void modifier_deformMatrices(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct Mesh *mesh, + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); + +void modifier_deformVertsEM(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct BMEditMesh *editData, struct Mesh *mesh, + float (*vertexCos)[3], int numVerts); + +void modifier_deformMatricesEM(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct BMEditMesh *editData, struct Mesh *mesh, + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); + +struct Mesh *modifier_applyModifier(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct Mesh *mesh, ModifierApplyFlag flag); + +struct Mesh *modifier_applyModifierEM(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct BMEditMesh *editData, + struct Mesh *mesh, ModifierApplyFlag flag); + +/* depricated variants of above that accept DerivedMesh */ + +void modifier_deformVerts_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct DerivedMesh *dm, + float (*vertexCos)[3], int numVerts, + ModifierApplyFlag flag); + +void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct DerivedMesh *dm, + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); + +void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *dm, + float (*vertexCos)[3], int numVerts); + +void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct BMEditMesh *editData, struct DerivedMesh *dm, + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); + +struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md, struct Depsgraph *depsgraph, + struct Object *ob, struct Derive @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] https://lists.blender.org/mailman/listinfo/bf-blender-cvs
