diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-08-11 07:31:33 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-08-11 07:31:33 +0400 |
commit | 75bcb4cd9805d58d4f79d5668860f47bf6f17194 (patch) | |
tree | 2ffccd1ed22d02e6706957077e3c782d39e46907 /source/blender/blenkernel | |
parent | ac3ed0f92a8e8fab50312c716c8cbdf3f38616d9 (diff) |
- added modifiers_getVirtualModifierList, returns pointer to first modifier
but including "virtual" modifiers (for example, an object skel-parented
to a lattice has a virtual first lattice modifier)
- removed mesh_modifier(), all functionality has been incorporated into
modifier stack (well, keys still don't exist as a modifier, but I am
not sure if they should).
- added interface option to convert a virtual modifier into a real modifier
- added option to parent to lattice object or lattice with deform
- bug fix, patch of hook indices patched all hooks (oops) not just ones
for edited mesh
NOTE: Files saved with 2.38 that include an object parented to a lattice
will not load correctly, because it will look like the object is parented
only to the object (i.e. without deform). Can be simply fixed by reparenting
or adding a lattice modifier. Older files are handled automatically.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_deform.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 51 |
5 files changed, 58 insertions, 29 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index a06940e883c..a151cff8879 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -48,7 +48,6 @@ struct bDeformGroup *get_named_vertexgroup (Object *ob, char *name); int get_defgroup_num (struct Object *ob, struct bDeformGroup *dg); int curve_modifier(struct Object *ob, char mode); -void mesh_modifier(struct Object *ob, float (**vertexCos_r)[3]); int lattice_modifier(struct Object *ob, char mode); diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 574f7b313b4..ce3082fc9b4 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -37,6 +37,7 @@ struct DerivedMesh; struct DagForest; struct DagNode; struct Object; +struct ListBase; typedef enum { /* Should not be used, only for None modifier type */ @@ -201,5 +202,7 @@ int modifiers_getCageIndex (struct Object *ob, int *lastPossibleCageIndex_r) int modifiers_isSoftbodyEnabled (struct Object *ob); +ModifierData* modifiers_getVirtualModifierList (struct Object *ob); + #endif diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 574ff1fd31a..e46bf147b73 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -60,6 +60,7 @@ #include "BKE_subsurf.h" #include "BKE_deform.h" #include "BKE_modifier.h" +#include "BKE_key.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -1388,8 +1389,8 @@ DerivedMesh *mesh_create_derived_for_modifier(Object *ob, ModifierData *md) static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform) { Mesh *me = ob->data; - ModifierData *md= ob->modifiers.first; - float (*deformedVerts)[3]; + ModifierData *md= modifiers_getVirtualModifierList(ob); + float (*deformedVerts)[3] = NULL; DerivedMesh *dm; int numVerts = me->totvert; @@ -1399,7 +1400,7 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedM *final_r = NULL; if (useDeform) { - mesh_modifier(ob, &deformedVerts); + do_mesh_key(me); /* Apply all leading deforming modifiers */ for (; md; md=md->next) { diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index e2cb842e16d..d89cca72728 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -156,31 +156,6 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) /* *************** HOOK ****************** */ -void mesh_modifier(Object *ob, float (**vertexCos_r)[3]) -{ - Mesh *me= ob->data; - float (*vertexCos)[3] = NULL; - - do_mesh_key(me); - - if (ob->parent && me->totvert) { - if(ob->parent->type==OB_CURVE && ob->partype==PARSKEL) { - if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); - curve_deform_verts(ob->parent, ob, vertexCos, me->totvert); - } - else if(ob->parent->type==OB_LATTICE) { - if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); - lattice_deform_verts(ob->parent, ob, vertexCos, me->totvert); - } - else if(ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) { - if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); - armature_deform_verts(ob->parent, ob, vertexCos, me->totvert); - } - } - - *vertexCos_r = vertexCos; -} - int curve_modifier(Object *ob, char mode) { static ListBase nurb={NULL, NULL}; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index f306986a8ef..6dc7cb5ca27 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -1468,3 +1468,54 @@ int modifiers_isSoftbodyEnabled(Object *ob) return (md && md->mode&(eModifierMode_Realtime|eModifierMode_Render)); } + +ModifierData *modifiers_getVirtualModifierList(Object *ob) +{ + /* Kinda hacky, but should be fine since we are never + * reentrant and avoid free hassles. + */ + static ArmatureModifierData amd; + static CurveModifierData cmd; + static LatticeModifierData lmd; + static int init = 1; + + if (init) { + ModifierData *md; + + md = modifier_new(eModifierType_Armature); + amd = *((ArmatureModifierData*) md); + modifier_free(md); + + md = modifier_new(eModifierType_Curve); + cmd = *((CurveModifierData*) md); + modifier_free(md); + + md = modifier_new(eModifierType_Lattice); + lmd = *((LatticeModifierData*) md); + modifier_free(md); + + amd.modifier.mode |= eModifierMode_Virtual; + cmd.modifier.mode |= eModifierMode_Virtual; + lmd.modifier.mode |= eModifierMode_Virtual; + + init = 0; + } + + if (ob->parent) { + if(ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) { + amd.object = ob->parent; + amd.modifier.next = ob->modifiers.first; + return &amd.modifier; + } else if(ob->parent->type==OB_CURVE && ob->partype==PARSKEL) { + cmd.object = ob->parent; + cmd.modifier.next = ob->modifiers.first; + return &cmd.modifier; + } else if(ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { + lmd.object = ob->parent; + lmd.modifier.next = ob->modifiers.first; + return &lmd.modifier; + } + } + + return ob->modifiers.first; +} |