Modifier: add non derived mesh modifier wrappers
Rename modifier_deformVerts_ensure_normals & modifier_applyModifier_ensure_normals with wrappers that match 2.7x convention.
This commit is contained in:
parent
c8c3bbaade
commit
75ac83610b
|
@ -427,20 +427,34 @@ const char *modifier_path_relbase_from_global(struct Object *ob);
|
|||
struct DerivedMesh *modwrap_applyModifier_DM_deprecated(
|
||||
ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm);
|
||||
struct Mesh *modwrap_applyModifier(
|
||||
ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct Mesh *me);
|
||||
|
||||
struct DerivedMesh *modwrap_applyModifierEM_DM_deprecated(
|
||||
ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *em, struct DerivedMesh *dm);
|
||||
struct Mesh *modwrap_applyModifierEM(
|
||||
ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *em, struct Mesh *me);
|
||||
|
||||
void modwrap_deformVerts_DM_deprecated(
|
||||
ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], int numVerts);
|
||||
void modwrap_deformVerts(
|
||||
ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct Mesh *me,
|
||||
float (*vertexCos)[3], int numVerts);
|
||||
|
||||
void modwrap_deformVertsEM_DM_deprecated(
|
||||
ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *em, struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], int numVerts);
|
||||
void modwrap_deformVertsEM(
|
||||
ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *em, struct Mesh *me,
|
||||
float (*vertexCos)[3], int numVerts);
|
||||
|
||||
#define applyModifier_DM_wrapper(NEW_FUNC_NAME, OLD_FUNC_NAME) \
|
||||
static Mesh *NEW_FUNC_NAME(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) \
|
||||
|
@ -456,16 +470,6 @@ void modwrap_deformVertsEM_DM_deprecated(
|
|||
* depending on if the modifier has been ported to Mesh or is still using DerivedMesh
|
||||
*/
|
||||
|
||||
void modifier_deformVerts_ensure_normals(
|
||||
struct ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct Mesh *mesh, float (*vertexCos)[3], int numVerts);
|
||||
|
||||
struct Mesh *modifier_applyModifier_ensure_normals(
|
||||
struct ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct Mesh *mesh);
|
||||
|
||||
/* deprecated variants of above that accept DerivedMesh */
|
||||
|
||||
void modifier_deformVerts_DM_deprecated(
|
||||
struct ModifierData *md, const struct ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts);
|
||||
|
|
|
@ -1560,7 +1560,7 @@ static void mesh_calc_modifiers(
|
|||
if (!deformedVerts)
|
||||
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
|
||||
|
||||
modifier_deformVerts_ensure_normals(md, &mectx_deform, NULL, deformedVerts, numVerts);
|
||||
modwrap_deformVerts(md, &mectx_deform, NULL, deformedVerts, numVerts);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
|
@ -1700,7 +1700,7 @@ static void mesh_calc_modifiers(
|
|||
}
|
||||
}
|
||||
|
||||
modifier_deformVerts_ensure_normals(md, &mectx_deform, mesh, deformedVerts, numVerts);
|
||||
modwrap_deformVerts(md, &mectx_deform, mesh, deformedVerts, numVerts);
|
||||
}
|
||||
else {
|
||||
/* determine which data layers are needed by following modifiers */
|
||||
|
@ -1767,7 +1767,7 @@ static void mesh_calc_modifiers(
|
|||
}
|
||||
}
|
||||
|
||||
Mesh *new_mesh = modifier_applyModifier_ensure_normals(md, &mectx_apply, mesh);
|
||||
Mesh *new_mesh = modwrap_applyModifier(md, &mectx_apply, mesh);
|
||||
ASSERT_IS_VALID_MESH(new_mesh);
|
||||
|
||||
if (new_mesh) {
|
||||
|
@ -1798,7 +1798,7 @@ static void mesh_calc_modifiers(
|
|||
(mti->requiredDataMask ?
|
||||
mti->requiredDataMask(ob, md) : 0));
|
||||
|
||||
new_mesh = modifier_applyModifier_ensure_normals(md, &mectx_orco, orco_mesh);
|
||||
new_mesh = modwrap_applyModifier(md, &mectx_orco, orco_mesh);
|
||||
ASSERT_IS_VALID_MESH(new_mesh);
|
||||
|
||||
if (new_mesh) {
|
||||
|
@ -1821,7 +1821,7 @@ static void mesh_calc_modifiers(
|
|||
nextmask &= ~CD_MASK_CLOTH_ORCO;
|
||||
mesh_set_only_copy(cloth_orco_mesh, nextmask | CD_MASK_ORIGINDEX);
|
||||
|
||||
new_mesh = modifier_applyModifier_ensure_normals(md, &mectx_orco, cloth_orco_mesh);
|
||||
new_mesh = modwrap_applyModifier(md, &mectx_orco, cloth_orco_mesh);
|
||||
ASSERT_IS_VALID_DM(new_mesh);
|
||||
|
||||
if (new_mesh) {
|
||||
|
|
|
@ -838,6 +838,18 @@ struct DerivedMesh *modwrap_applyModifier_DM_deprecated(
|
|||
}
|
||||
return modifier_applyModifier_DM_deprecated(md, ctx, dm);
|
||||
}
|
||||
struct Mesh *modwrap_applyModifier(
|
||||
ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct Mesh *me)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
BLI_assert(CustomData_has_layer(&me->pdata, CD_NORMAL) == false);
|
||||
|
||||
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
BKE_mesh_calc_normals(me);
|
||||
}
|
||||
return mti->applyModifier(md, ctx, me);
|
||||
}
|
||||
|
||||
struct DerivedMesh *modwrap_applyModifierEM_DM_deprecated(
|
||||
ModifierData *md, const ModifierEvalContext *ctx,
|
||||
|
@ -851,6 +863,18 @@ struct DerivedMesh *modwrap_applyModifierEM_DM_deprecated(
|
|||
}
|
||||
return modifier_applyModifierEM_DM_deprecated(md, ctx, em, dm);
|
||||
}
|
||||
struct Mesh *modwrap_applyModifierEM(
|
||||
ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *em, Mesh *me)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
BLI_assert(CustomData_has_layer(&me->pdata, CD_NORMAL) == false);
|
||||
|
||||
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
BKE_mesh_calc_normals(me);
|
||||
}
|
||||
return mti->applyModifierEM(md, ctx, em, me);
|
||||
}
|
||||
|
||||
void modwrap_deformVerts_DM_deprecated(
|
||||
ModifierData *md, const ModifierEvalContext *ctx,
|
||||
|
@ -864,6 +888,18 @@ void modwrap_deformVerts_DM_deprecated(
|
|||
}
|
||||
modifier_deformVerts_DM_deprecated(md, ctx, dm, vertexCos, numVerts);
|
||||
}
|
||||
void modwrap_deformVerts(
|
||||
ModifierData *md, const ModifierEvalContext *ctx,
|
||||
Mesh *me, float (*vertexCos)[3], int numVerts)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
BLI_assert(!me || CustomData_has_layer(&me->pdata, CD_NORMAL) == false);
|
||||
|
||||
if (me && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
BKE_mesh_calc_normals(me);
|
||||
}
|
||||
mti->deformVerts(md, ctx, me, vertexCos, numVerts);
|
||||
}
|
||||
|
||||
void modwrap_deformVertsEM_DM_deprecated(
|
||||
ModifierData *md, const ModifierEvalContext *ctx,
|
||||
|
@ -878,6 +914,20 @@ void modwrap_deformVertsEM_DM_deprecated(
|
|||
}
|
||||
modifier_deformVertsEM_DM_deprecated(md, ctx, em, dm, vertexCos, numVerts);
|
||||
}
|
||||
void modwrap_deformVertsEM(
|
||||
ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *em, Mesh *me,
|
||||
float (*vertexCos)[3], int numVerts)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
BLI_assert(!me || CustomData_has_layer(&me->pdata, CD_NORMAL) == false);
|
||||
|
||||
if (me && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
BKE_mesh_calc_normals(me);
|
||||
}
|
||||
mti->deformVertsEM(md, ctx, em, me, vertexCos, numVerts);
|
||||
}
|
||||
|
||||
/* end modifier callback wrappers */
|
||||
|
||||
|
||||
|
@ -885,36 +935,12 @@ void modwrap_deformVertsEM_DM_deprecated(
|
|||
* depending on if the modifier has been ported to Mesh or is still using DerivedMesh
|
||||
*/
|
||||
|
||||
void modifier_deformVerts_ensure_normals(struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct Mesh *mesh,
|
||||
float (*vertexCos)[3], int numVerts)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
BLI_assert(!mesh || CustomData_has_layer(&mesh->pdata, CD_NORMAL) == false);
|
||||
|
||||
if (mesh && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
BKE_mesh_calc_normals(mesh);
|
||||
}
|
||||
mti->deformVerts(md, ctx, mesh, vertexCos, numVerts);
|
||||
}
|
||||
|
||||
struct Mesh *modifier_applyModifier_ensure_normals(struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct Mesh *mesh)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
BLI_assert(CustomData_has_layer(&mesh->pdata, CD_NORMAL) == false);
|
||||
|
||||
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
|
||||
BKE_mesh_calc_normals(mesh);
|
||||
}
|
||||
return mti->applyModifier(md, ctx, mesh);
|
||||
}
|
||||
|
||||
/* deprecated variants of above that accept DerivedMesh */
|
||||
|
||||
void modifier_deformVerts_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], int numVerts)
|
||||
void modifier_deformVerts_DM_deprecated(
|
||||
struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], int numVerts)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
|
@ -932,9 +958,10 @@ void modifier_deformVerts_DM_deprecated(struct ModifierData *md, const ModifierE
|
|||
}
|
||||
}
|
||||
|
||||
void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
|
||||
void modifier_deformMatrices_DM_deprecated(
|
||||
struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
|
||||
{
|
||||
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
@ -953,9 +980,10 @@ void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, const Modifi
|
|||
}
|
||||
}
|
||||
|
||||
void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *editData, struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], int numVerts)
|
||||
void modifier_deformVertsEM_DM_deprecated(
|
||||
struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *editData, struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], int numVerts)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
|
@ -973,9 +1001,10 @@ void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, const Modifie
|
|||
}
|
||||
}
|
||||
|
||||
void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *editData, struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
|
||||
void modifier_deformMatricesEM_DM_deprecated(
|
||||
struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *editData, struct DerivedMesh *dm,
|
||||
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
|
@ -993,8 +1022,9 @@ void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, const Modi
|
|||
}
|
||||
}
|
||||
|
||||
struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm)
|
||||
struct DerivedMesh *modifier_applyModifier_DM_deprecated(
|
||||
struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct DerivedMesh *dm)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
|
@ -1021,9 +1051,10 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md
|
|||
|
||||
}
|
||||
|
||||
struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *editData,
|
||||
struct DerivedMesh *dm)
|
||||
struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(
|
||||
struct ModifierData *md, const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *editData,
|
||||
struct DerivedMesh *dm)
|
||||
{
|
||||
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
|
|
|
@ -944,7 +944,7 @@ bool multiresModifier_reshapeFromDeformModifier(
|
|||
.depsgraph = depsgraph,
|
||||
.object = object,
|
||||
.flag = MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY};
|
||||
modifier_deformVerts_ensure_normals(
|
||||
modwrap_deformVerts(
|
||||
md, &modifier_ctx, multires_mesh, deformed_verts,
|
||||
multires_mesh->totvert);
|
||||
BKE_id_free(NULL, multires_mesh);
|
||||
|
|
Loading…
Reference in New Issue