diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-19 12:00:20 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-19 12:00:20 +0400 |
commit | d9ec2efe8fc8d19628ebf425b8cc61c16f82bab1 (patch) | |
tree | d09ad3197e9d289477b205c733c7c19cc2f583e7 | |
parent | b3757069351ac5eab4e6c0e772f1cfbc83421c81 (diff) |
move modifier callback wrappers into modifier.c
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 63 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 65 |
3 files changed, 89 insertions, 64 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 6b9392a4169..3f3a5739d55 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -391,5 +391,30 @@ void modifier_mdef_compact_influences(struct ModifierData *md); void modifier_path_init(char *path, int path_maxlen, const char *name); const char *modifier_path_relbase(struct Object *ob); + +/* wrappers for modifier callbacks */ + +struct DerivedMesh *modwrap_applyModifier( + ModifierData *md, struct Object *ob, + struct DerivedMesh *dm, + ModifierApplyFlag flag); + +struct DerivedMesh *modwrap_applyModifierEM( + ModifierData *md, struct Object *ob, + struct BMEditMesh *em, + struct DerivedMesh *dm, + ModifierApplyFlag flag); + +void modwrap_deformVerts( + ModifierData *md, struct Object *ob, + struct DerivedMesh *dm, + float (*vertexCos)[3], int numVerts, + ModifierApplyFlag flag); + +void modwrap_deformVertsEM( + ModifierData *md, struct Object *ob, + struct BMEditMesh *em, struct DerivedMesh *dm, + float (*vertexCos)[3], int numVerts); + #endif diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 6a21f33ac15..c9c33014aa5 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -845,69 +845,6 @@ DerivedMesh *mesh_create_derived(Mesh *me, Object *ob, float (*vertCos)[3]) return dm; } -/***/ - -/* wrapper around ModifierTypeInfo.applyModifier that ensures valid normals */ - -static DerivedMesh *modwrap_applyModifier( - ModifierData *md, Object *ob, - DerivedMesh *dm, - ModifierApplyFlag flag) -{ - ModifierTypeInfo *mti = modifierType_getInfo(md->type); - BLI_assert(CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); - - if (mti->dependsOnNormals && mti->dependsOnNormals(md)) { - DM_ensure_normals(dm); - } - return mti->applyModifier(md, ob, dm, flag); -} - -static DerivedMesh *modwrap_applyModifierEM( - ModifierData *md, Object *ob, - BMEditMesh *em, - DerivedMesh *dm, - ModifierApplyFlag flag) -{ - ModifierTypeInfo *mti = modifierType_getInfo(md->type); - BLI_assert(CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); - - if (mti->dependsOnNormals && mti->dependsOnNormals(md)) { - DM_ensure_normals(dm); - } - return mti->applyModifierEM(md, ob, em, dm, flag); -} - -static void modwrap_deformVerts( - ModifierData *md, Object *ob, - DerivedMesh *dm, - float (*vertexCos)[3], int numVerts, - ModifierApplyFlag flag) -{ - ModifierTypeInfo *mti = modifierType_getInfo(md->type); - BLI_assert(!dm || CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); - - if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) { - DM_ensure_normals(dm); - } - mti->deformVerts(md, ob, dm, vertexCos, numVerts, flag); -} - -static void modwrap_deformVertsEM( - ModifierData *md, Object *ob, - BMEditMesh *em, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) -{ - ModifierTypeInfo *mti = modifierType_getInfo(md->type); - BLI_assert(!dm || CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); - - if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) { - DM_ensure_normals(dm); - } - mti->deformVertsEM(md, ob, em, dm, vertexCos, numVerts); -} -/* end modifier callback wrappers */ - DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, ModifierData *md, int build_shapekey_layers) { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c17830639e4..a0fa3317297 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -36,7 +36,7 @@ * \ingroup bke */ - +#include <stdlib.h> #include <stddef.h> #include <string.h> #include <stdarg.h> @@ -60,6 +60,7 @@ #include "BKE_cloth.h" #include "BKE_key.h" #include "BKE_multires.h" +#include "BKE_DerivedMesh.h" /* may move these, only for modifier_path_relbase */ #include "BKE_global.h" /* ugh, G.main->name only */ @@ -693,3 +694,65 @@ void modifier_path_init(char *path, int path_maxlen, const char *name) G.relbase_valid ? "//" : BLI_temporary_dir(), name); } + + +/* wrapper around ModifierTypeInfo.applyModifier that ensures valid normals */ + +struct DerivedMesh *modwrap_applyModifier( + ModifierData *md, Object *ob, + struct DerivedMesh *dm, + ModifierApplyFlag flag) +{ + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + BLI_assert(CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); + + if (mti->dependsOnNormals && mti->dependsOnNormals(md)) { + DM_ensure_normals(dm); + } + return mti->applyModifier(md, ob, dm, flag); +} + +struct DerivedMesh *modwrap_applyModifierEM( + ModifierData *md, Object *ob, + struct BMEditMesh *em, + DerivedMesh *dm, + ModifierApplyFlag flag) +{ + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + BLI_assert(CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); + + if (mti->dependsOnNormals && mti->dependsOnNormals(md)) { + DM_ensure_normals(dm); + } + return mti->applyModifierEM(md, ob, em, dm, flag); +} + +void modwrap_deformVerts( + ModifierData *md, Object *ob, + DerivedMesh *dm, + float (*vertexCos)[3], int numVerts, + ModifierApplyFlag flag) +{ + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + BLI_assert(!dm || CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); + + if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) { + DM_ensure_normals(dm); + } + mti->deformVerts(md, ob, dm, vertexCos, numVerts, flag); +} + +void modwrap_deformVertsEM( + ModifierData *md, Object *ob, + struct BMEditMesh *em, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) +{ + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + BLI_assert(!dm || CustomData_has_layer(&dm->polyData, CD_NORMAL) == false); + + if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) { + DM_ensure_normals(dm); + } + mti->deformVertsEM(md, ob, em, dm, vertexCos, numVerts); +} +/* end modifier callback wrappers */ |