Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_ipo.h2
-rw-r--r--source/blender/blenkernel/BKE_key.h14
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c7
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c32
-rw-r--r--source/blender/blenkernel/intern/displist.c7
-rw-r--r--source/blender/blenkernel/intern/ipo.c11
-rw-r--r--source/blender/blenkernel/intern/key.c186
-rw-r--r--source/blender/blenkernel/intern/lattice.c2
-rw-r--r--source/blender/blenkernel/intern/scene.c12
9 files changed, 163 insertions, 110 deletions
diff --git a/source/blender/blenkernel/BKE_ipo.h b/source/blender/blenkernel/BKE_ipo.h
index 4d23be16804..c0a5be27bcf 100644
--- a/source/blender/blenkernel/BKE_ipo.h
+++ b/source/blender/blenkernel/BKE_ipo.h
@@ -59,6 +59,8 @@ void make_local_obipo(struct Ipo *ipo);
void make_local_matipo(struct Ipo *ipo);
void make_local_keyipo(struct Ipo *ipo);
void make_local_ipo(struct Ipo *ipo);
+struct IpoCurve *find_ipocurve(struct Ipo *ipo, int adrcode);
+
void calchandles_ipocurve(struct IpoCurve *icu);
void testhandles_ipocurve(struct IpoCurve *icu);
void sort_time_ipocurve(struct IpoCurve *icu);
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index 59984389f21..94ba1cbd69d 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -48,19 +48,17 @@ struct Key *add_key(struct ID *id);
struct Key *copy_key(struct Key *key);
void make_local_key(struct Key *key);
void sort_keys(struct Key *key);
+
void set_four_ipo(float d, float *data, int type);
void set_afgeleide_four_ipo(float d, float *data, int type);
-void cp_key(int start, int end, int tot, char *poin, struct Key *key, struct KeyBlock *k, int mode);
+
+/* only exported to curve.c! */
void cp_cu_key(struct Curve *cu, struct KeyBlock *kb, int start, int end);
-void do_mesh_key(struct Mesh *me);
-void do_curve_key(struct Curve *cu);
-void do_latt_key(struct Lattice *lt);
-void do_ob_key(struct Object *ob);
-void do_spec_key(struct Key *key);
-void unlock_all_keys(void);
+int do_ob_key(struct Object *ob);
-struct KeyBlock *key_get_active(struct Key *keyData);
+struct Key *ob_get_key(struct Object *ob);
+struct KeyBlock *ob_get_keyblock(struct Object *ob);
#endif
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index fda0e39df93..e63fe3ab163 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1474,8 +1474,9 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedM
*final_r = NULL;
if (useDeform) {
- do_mesh_key(me);
-
+ if(do_ob_key(ob)) /* shape key makes deform verts */
+ deformedVerts = mesh_getVertexCos(me, &numVerts);
+
/* Apply all leading deforming modifiers */
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1601,7 +1602,7 @@ static vec3f *editmesh_getVertexCos(EditMesh *em, int *numVerts_r)
VECCOPY(cos[i], eve->co);
}
- return cos;
+ return (vec3f *)cos;
}
static void editmesh_calc_modifiers(DerivedMesh **cage_r, DerivedMesh **final_r)
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index f23a30fba7f..61a0ea20a2e 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -60,6 +60,7 @@
#include "BKE_action.h"
#include "BKE_global.h"
+#include "BKE_key.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
#include "BKE_utildefines.h"
@@ -1437,7 +1438,12 @@ void DAG_scene_update_flags(Scene *sce, unsigned int lay)
switch(ob->type) {
case OB_MESH:
me= ob->data;
- if(me->key) ob->recalc |= OB_RECALC_DATA;
+ if(me->key) {
+ if(!(ob->shapeflag & OB_SHAPE_LOCK)) {
+ ob->recalc |= OB_RECALC_DATA;
+ ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
+ }
+ }
else if(ob->effect.first) {
Effect *eff= ob->effect.first;
if(eff->type==EFF_WAVE) ob->recalc |= OB_RECALC_DATA;
@@ -1452,11 +1458,21 @@ void DAG_scene_update_flags(Scene *sce, unsigned int lay)
case OB_CURVE:
case OB_SURF:
cu= ob->data;
- if(cu->key) ob->recalc |= OB_RECALC_DATA;
+ if(cu->key) {
+ if(!(ob->shapeflag & OB_SHAPE_LOCK)) {
+ ob->recalc |= OB_RECALC_DATA;
+ ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
+ }
+ }
break;
case OB_LATTICE:
lt= ob->data;
- if(lt->key) ob->recalc |= OB_RECALC_DATA;
+ if(lt->key) {
+ if(!(ob->shapeflag & OB_SHAPE_LOCK)) {
+ ob->recalc |= OB_RECALC_DATA;
+ ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
+ }
+ }
break;
case OB_MBALL:
if(ob->transflag & OB_DUPLI) ob->recalc |= OB_RECALC_DATA;
@@ -1481,9 +1497,13 @@ void DAG_object_flush_update(Scene *sce, Object *ob, short flag)
if(flag & OB_RECALC_DATA) {
ID *id= ob->data;
if(id && id->us>1) {
- for (base= sce->base.first; base; base= base->next) {
- if (ob->data==base->object->data) {
- base->object->recalc |= OB_RECALC_DATA;
+ /* except when there's a key and shapes are locked */
+ if(ob_get_key(ob) && (ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK)));
+ else {
+ for (base= sce->base.first; base; base= base->next) {
+ if (ob->data==base->object->data) {
+ base->object->recalc |= OB_RECALC_DATA;
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index d18c205d825..02d9f7be007 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1446,6 +1446,11 @@ void curve_calc_modifiers_pre(Object *ob, ListBase *nurb, int forRender, float (
float (*originalVerts)[3] = NULL;
float (*deformedVerts)[3] = NULL;
+ if(ob!=G.obedit && do_ob_key(ob)) {
+ deformedVerts = curve_getVertexCos(ob->data, nurb, &numVerts);
+ originalVerts = MEM_dupallocN(deformedVerts);
+ }
+
if (preTesselatePoint) {
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1522,7 +1527,6 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
nubase= &editNurb;
}
else {
- do_curve_key(cu);
nubase= &cu->nurb;
}
@@ -1606,7 +1610,6 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
if(ob->type==OB_FONT) text_to_curve(ob, 0);
- if(!obedit && !forOrco) do_curve_key(cu);
if(!forOrco) curve_calc_modifiers_pre(ob, nubase, 0, &originalVerts, &deformedVerts, &numVerts);
makeBevelList(ob);
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index a926e8f67a7..60685518238 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -386,6 +386,17 @@ void make_local_ipo(Ipo *ipo)
}
+IpoCurve *find_ipocurve(Ipo *ipo, int adrcode)
+{
+ if(ipo) {
+ IpoCurve *icu= ipo->curve.first;
+ while(icu) {
+ if(icu->adrcode==adrcode) return icu;
+ icu= icu->next;
+ }
+ }
+ return NULL;
+}
void calchandles_ipocurve(IpoCurve *icu)
{
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 81670214055..c32874f69c5 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -38,27 +38,28 @@
#include "MEM_guardedalloc.h"
-#include "DNA_key_types.h"
+#include "DNA_curve_types.h"
#include "DNA_ipo_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_lattice_types.h"
-#include "BLI_blenlib.h"
-#include "BKE_utildefines.h"
#include "BKE_bad_level_calls.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_library.h"
#include "BKE_blender.h"
#include "BKE_curve.h"
-#include "BKE_object.h"
-#include "BKE_mesh.h"
-#include "BKE_key.h"
+#include "BKE_global.h"
#include "BKE_ipo.h"
+#include "BKE_key.h"
#include "BKE_lattice.h"
+#include "BKE_library.h"
+#include "BKE_mesh.h"
+#include "BKE_main.h"
+#include "BKE_object.h"
+#include "BKE_utildefines.h"
+
+#include "BLI_blenlib.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -191,23 +192,20 @@ void sort_keys(Key *key)
while(doit) {
doit= 0;
- kb= key->block.first;
- while(kb) {
+ for(kb= key->block.first; kb; kb= kb->next) {
if(kb->next) {
if(kb->pos > kb->next->pos) {
BLI_remlink(&key->block, kb);
- /* insertlink(lb, prevlink, newlink): newlink komt na prevlink */
BLI_insertlink(&key->block, kb->next, kb);
doit= 1;
break;
}
}
- kb= kb->next;
}
}
-
+
}
/**************** do the key ****************/
@@ -407,7 +405,7 @@ static void flerp(int aantal, float *in, float *f0, float *f1, float *f2, float
}
}
-void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *k, int mode)
+static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *k, int mode)
{
float ktot = 0.0, kd = 0.0;
int elemsize, poinsize = 0, a, *ofsp, ofs[32], flagflo=0;
@@ -578,7 +576,6 @@ static void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, f
{
KeyBlock *kb;
IpoCurve *icu;
- float fac[KEY_TOTIPO], fval;
int *ofsp, ofs[3], elemsize, a, b;
char *cp, *poin, *reffrom, *from, elemstr[8];
@@ -611,30 +608,23 @@ static void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, f
elemsize= key->elemsize;
if(mode==KEY_BEZTRIPLE) elemsize*= 3;
- /* step one: fetch ipo values */
- icu= key->ipo->curve.first;
- for(a=0; a<KEY_TOTIPO; a++) fac[a]= 0.0;
- while(icu) {
- fac[icu->adrcode]= icu->curval;
- icu= icu->next;
- }
-
- /* step 2 init */
+ /* step 1 init */
cp_key(start, end, tot, basispoin, key, key->refkey, mode);
- /* step 3: do it */
+ /* step 2: do it */
a= 1;
kb= key->block.first;
while(kb) {
if(kb!=key->refkey) {
- fval= fac[a];
+ icu= find_ipocurve(key->ipo, kb->adrcode);
+
a++;
- if(a==32) break;
+ if(a==64) break;
- /* no difference allowed */
- if(kb->totelem==tot) {
+ /* only with ipocurve, and no difference allowed */
+ if(icu && kb->totelem==tot) {
poin= basispoin;
reffrom= key->refkey->data;
@@ -655,16 +645,16 @@ static void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, f
switch(cp[1]) {
case IPO_FLOAT:
- rel_flerp(cp[0], (float *)poin, (float *)reffrom, (float *)from, fval);
+ rel_flerp(cp[0], (float *)poin, (float *)reffrom, (float *)from, icu->curval);
break;
case IPO_BPOINT:
- rel_flerp(3, (float *)poin, (float *)reffrom, (float *)from, fval);
- rel_flerp(1, (float *)(poin+16), (float *)(reffrom+16), (float *)(from+16), fval);
+ rel_flerp(3, (float *)poin, (float *)reffrom, (float *)from, icu->curval);
+ rel_flerp(1, (float *)(poin+16), (float *)(reffrom+16), (float *)(from+16), icu->curval);
break;
case IPO_BEZTRIPLE:
- rel_flerp(9, (float *)poin, (float *)reffrom, (float *)from, fval);
+ rel_flerp(9, (float *)poin, (float *)reffrom, (float *)from, icu->curval);
break;
}
@@ -898,16 +888,15 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *
}
}
-void do_mesh_key(Mesh *me)
+static int do_mesh_key(Mesh *me)
{
KeyBlock *k[4];
float cfra, ctime, t[4], delta, loc[3], size[3];
int a, flag = 0, step;
- if(me->totvert==0) return;
- if(me->key==NULL) return;
- if(me->key->flag & KEY_LOCKED) return;
- if(me->key->block.first==NULL) return;
+ if(me->totvert==0) return 0;
+ if(me->key==NULL) return 0;
+ if(me->key->block.first==NULL) return 0;
if(me->key->slurph && me->key->type!=KEY_RELATIVE ) {
delta= me->key->slurph;
@@ -969,6 +958,7 @@ void do_mesh_key(Mesh *me)
else boundbox_mesh(me, loc, size);
}
}
+ return 1;
}
static void do_cu_key(Curve *cu, KeyBlock **k, float *t)
@@ -1042,7 +1032,7 @@ static void do_rel_cu_key(Curve *cu, float ctime)
}
}
-void do_curve_key(Curve *cu)
+static int do_curve_key(Curve *cu)
{
KeyBlock *k[4];
float cfra, ctime, t[4], delta;
@@ -1050,10 +1040,9 @@ void do_curve_key(Curve *cu)
tot= count_curveverts(&cu->nurb);
- if(tot==0) return;
- if(cu->key==NULL) return;
- if(cu->key->flag & KEY_LOCKED) return;
- if(cu->key->block.first==NULL) return;
+ if(tot==0) return 0;
+ if(cu->key==NULL) return 0;
+ if(cu->key->block.first==NULL) return 0;
if(cu->key->slurph) {
delta= cu->key->slurph;
@@ -1110,17 +1099,18 @@ void do_curve_key(Curve *cu)
if(flag && k[2]==cu->key->refkey) tex_space_curve(cu);
}
}
+
+ return 1;
}
-void do_latt_key(Lattice *lt)
+static int do_latt_key(Lattice *lt)
{
KeyBlock *k[4];
float delta, cfra, ctime, t[4];
int a, tot, flag;
- if(lt->key==NULL) return;
- if(lt->key->flag & KEY_LOCKED) return;
- if(lt->key->block.first==0) return;
+ if(lt->key==NULL) return 0;
+ if(lt->key->block.first==NULL) return 0;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
@@ -1171,51 +1161,79 @@ void do_latt_key(Lattice *lt)
}
if(lt->flag & LT_OUTSIDE) outside_lattice(lt);
-}
-
-
-/* going to be removed */
-void unlock_all_keys()
-{
- Key *key;
- key= G.main->key.first;
- while(key) {
- key->flag &= ~KEY_LOCKED;
- key= key->id.next;
- }
+ return 1;
}
-void do_ob_key(Object *ob)
+/* returns 1 when key applied */
+int do_ob_key(Object *ob)
{
- if(ob->type==OB_MESH) do_mesh_key( ob->data);
- else if(ob->type==OB_CURVE) do_curve_key( ob->data);
- else if(ob->type==OB_SURF) do_curve_key( ob->data);
- else if(ob->type==OB_LATTICE) do_latt_key( ob->data);
+ if(ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK)) {
+ Key *key= ob_get_key(ob);
+ if(key) {
+ KeyBlock *kb= BLI_findlink(&key->block, ob->shapenr-1);
+
+ if(kb==NULL) {
+ kb= key->block.first;
+ ob->shapenr= 1;
+ }
+
+ if(ob->type==OB_MESH) {
+ Mesh *me= ob->data;
+
+ cp_key(0, me->totvert, me->totvert, (char *)me->mvert->co, key, kb, 0);
+ }
+ else if(ob->type==OB_LATTICE) {
+ Lattice *lt= ob->data;
+ int tot= lt->pntsu*lt->pntsv*lt->pntsw;
+
+ cp_key(0, tot, tot, (char *)lt->def->vec, key, kb, 0);
+ }
+ else if ELEM(ob->type, OB_CURVE, OB_SURF) {
+ Curve *cu= ob->data;
+ int tot= count_curveverts(&cu->nurb);
+
+ cp_cu_key(cu, kb, 0, tot);
+ }
+ return 1;
+ }
+ }
+ else {
+ if(ob->type==OB_MESH) return do_mesh_key( ob->data);
+ else if(ob->type==OB_CURVE) return do_curve_key( ob->data);
+ else if(ob->type==OB_SURF) return do_curve_key( ob->data);
+ else if(ob->type==OB_LATTICE) return do_latt_key( ob->data);
+ }
+
+ return 0;
}
-void do_spec_key(Key *key)
+Key *ob_get_key(Object *ob)
{
- int idcode;
-
- if(key==0) return;
-
- idcode= GS(key->from->name);
-
- if(idcode==ID_ME) do_mesh_key( (Mesh *)key->from);
- else if(idcode==ID_CU) do_curve_key( (Curve *)key->from);
- else if(idcode==ID_LT) do_latt_key( (Lattice *)key->from);
+ if(ob->type==OB_MESH) {
+ Mesh *me= ob->data;
+ return me->key;
+ }
+ else if ELEM(ob->type, OB_CURVE, OB_SURF) {
+ Curve *cu= ob->data;
+ return cu->key;
+ }
+ else if(ob->type==OB_LATTICE) {
+ Lattice *lt= ob->data;
+ return lt->key;
+ }
+ return NULL;
}
-KeyBlock *key_get_active(Key *keyData)
+/* only the active keyblock */
+KeyBlock *ob_get_keyblock(Object *ob)
{
- if (keyData) {
- KeyBlock *key;
-
- for (key=keyData->block.first; key; key= key->next)
- if (key->flag&SELECT)
- return key;
+ Key *key= ob_get_key(ob);
+
+ if (key) {
+ KeyBlock *kb= BLI_findlink(&key->block, ob->shapenr-1);
+ return kb;
}
return NULL;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index df0f9e7d8f8..940bd865185 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -707,7 +707,7 @@ void lattice_calc_modifiers(Object *ob)
freedisplist(&ob->disp);
if (!editmode) {
- do_latt_key(ob->data);
+ do_ob_key(ob);
}
for (; md; md=md->next) {
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 8cfcdd41169..fdbfa081f32 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -436,6 +436,7 @@ void scene_select_base(Scene *sce, Base *selbase)
void scene_update_for_newframe(Scene *sce, unsigned int lay)
{
Base *base;
+ Object *ob;
int setcount=0;
/* object ipos are calculated in where_is_object */
@@ -443,9 +444,6 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay)
if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
- /* if keys were activated, disable the locks */
- unlock_all_keys();
-
/* for time being; sets otherwise can be cyclic */
while(sce && setcount<2) {
if(sce->theDag==NULL)
@@ -454,11 +452,13 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay)
DAG_scene_update_flags(sce, lay); // only stuff that moves
for(base= sce->base.first; base; base= base->next) {
- object_handle_update(base->object); // bke_object.h
+ ob= base->object;
+
+ object_handle_update(ob); // bke_object.h
/* only update layer when an ipo */
- if(base->object->ipo && has_ipo_code(base->object->ipo, OB_LAY) ) {
- base->lay= base->object->lay;
+ if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) {
+ base->lay= ob->lay;
}
}
sce= sce->set;