Lattices now have AnimData

This allows manual (point by point) animation of their control verts,
although many other settings cannot really be animated with any
visible effects yet. Interestingly, lattices also had IPO block
pointers, though they were never really used (AFAIK).

Todo:
- Animation Editor support has yet to be added. I've got a few other
things to add to, so will group those changes together.
This commit is contained in:
Joshua Leung 2010-12-13 06:31:49 +00:00
parent dec4789571
commit 1474b32456
7 changed files with 60 additions and 8 deletions

@ -73,7 +73,7 @@ short id_type_can_have_animdata (ID *id)
switch (GS(id->name)) {
/* has AnimData */
case ID_OB:
case ID_ME: case ID_MB: case ID_CU: case ID_AR:
case ID_ME: case ID_MB: case ID_CU: case ID_AR: case ID_LT:
case ID_KE:
case ID_PA:
case ID_MA: case ID_TE: case ID_NT:
@ -1913,6 +1913,9 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
/* armatures */
EVAL_ANIM_IDS(main->armature.first, ADT_RECALC_ANIM);
/* lattices */
EVAL_ANIM_IDS(main->latt.first, ADT_RECALC_ANIM);
/* meshes */
EVAL_ANIM_IDS(main->mesh.first, ADT_RECALC_ANIM);

@ -49,6 +49,7 @@
#include "DNA_curve_types.h"
#include "DNA_key_types.h"
#include "BKE_animsys.h"
#include "BKE_anim.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_displist.h"
@ -204,10 +205,6 @@ Lattice *copy_lattice(Lattice *lt)
ltn= copy_libblock(lt);
ltn->def= MEM_dupallocN(lt->def);
#if 0 // XXX old animation system
id_us_plus((ID *)ltn->ipo);
#endif // XXX old animation system
ltn->key= copy_key(ltn->key);
if(ltn->key) ltn->key->from= (ID *)ltn;
@ -233,6 +230,12 @@ void free_lattice(Lattice *lt)
MEM_freeN(editlt);
MEM_freeN(lt->editlatt);
}
/* free animation data */
if (lt->adt) {
BKE_free_animdata(&lt->id);
lt->adt= NULL;
}
}

@ -86,7 +86,10 @@ void free_mball(MetaBall *mb)
{
unlink_mball(mb);
if(mb->adt) BKE_free_animdata((ID *)mb);
if(mb->adt) {
BKE_free_animdata((ID *)mb);
mb->adt = NULL;
}
if(mb->mat) MEM_freeN(mb->mat);
if(mb->bb) MEM_freeN(mb->bb);
BLI_freelistN(&mb->elems);

@ -3421,6 +3421,7 @@ static void lib_link_latt(FileData *fd, Main *main)
lt= main->latt.first;
while(lt) {
if(lt->id.flag & LIB_NEEDLINK) {
if(lt->adt) lib_link_animdata(fd, &lt->id, lt->adt);
lt->ipo= newlibadr_us(fd, lt->id.lib, lt->ipo); // XXX depreceated - old animation system
lt->key= newlibadr_us(fd, lt->id.lib, lt->key);
@ -3439,6 +3440,9 @@ static void direct_link_latt(FileData *fd, Lattice *lt)
direct_link_dverts(fd, lt->pntsu*lt->pntsv*lt->pntsw, lt->dvert);
lt->editlatt= NULL;
lt->adt = newdataadr(fd, lt->adt);
direct_link_animdata(fd, lt->adt);
}
@ -11766,6 +11770,9 @@ static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt)
{
expand_doit(fd, mainvar, lt->ipo); // XXX depreceated - old animation system
expand_doit(fd, mainvar, lt->key);
if (lt->adt)
expand_animdata(fd, mainvar, lt->adt);
}

@ -1558,6 +1558,9 @@ static void write_lattices(WriteData *wd, ListBase *idbase)
writestruct(wd, ID_LT, "Lattice", 1, lt);
if (lt->id.properties) IDP_WriteProperty(lt->id.properties, wd);
/* write animdata */
if (lt->adt) write_animdata(wd, lt->adt);
/* direct data */
writestruct(wd, DATA, "BPoint", lt->pntsu*lt->pntsv*lt->pntsw, lt->def);

@ -31,6 +31,7 @@
#include "DNA_ID.h"
struct AnimData;
struct BPoint;
struct Ipo;
struct Key;
@ -46,6 +47,7 @@ typedef struct EditLatt {
typedef struct Lattice {
ID id;
struct AnimData *adt;
short pntsu, pntsv, pntsw, flag;
short opntsu, opntsv, opntsw, pad2;
@ -56,7 +58,7 @@ typedef struct Lattice {
struct BPoint *def;
struct Ipo *ipo;
struct Ipo *ipo; /* XXX: depreceated... old animation system */
struct Key *key;
struct MDeformVert *dvert;

@ -180,6 +180,33 @@ static void rna_Lattice_vg_name_set(PointerRNA *ptr, const char *value)
strcpy(lt->editlatt->latt->vgroup, value);
}
/* annoying, but is a consequence of RNA structures... */
static char *rna_LatticePoint_path(PointerRNA *ptr)
{
Lattice *lt= (Lattice*)ptr->id.data;
void *point= ptr->data;
BPoint *points = NULL;
if (lt->editlatt && lt->editlatt->latt->def)
points = lt->editlatt->latt->def;
else
points = lt->def;
if (points && point) {
int tot= lt->pntsu*lt->pntsv*lt->pntsw;
/* only return index if in range */
if ((point >= (void *)points) && (point < (void *)(points + tot))) {
int pt_index = (int)((BPoint *)point - points);
return BLI_sprintfN("points[%d]", pt_index);
}
}
else {
return BLI_strdup("");
}
}
#else
@ -191,6 +218,7 @@ static void rna_def_latticepoint(BlenderRNA *brna)
srna= RNA_def_struct(brna, "LatticePoint", NULL);
RNA_def_struct_sdna(srna, "BPoint");
RNA_def_struct_ui_text(srna, "LatticePoint", "Point in the lattice grid");
RNA_def_struct_path_func(srna, "rna_LatticePoint_path");
prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 3);
@ -287,6 +315,9 @@ static void rna_def_lattice(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "LatticePoint");
RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0);
RNA_def_property_ui_text(prop, "Points", "Points of the lattice");
/* pointers */
rna_def_animdata_common(srna);
}
void RNA_def_lattice(BlenderRNA *brna)