[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22175] branches/blender2.5/blender/source /blender: 2.5 - MetaBalls are now animateable

Joshua Leung aligorith at gmail.com
Mon Aug 3 15:09:23 CEST 2009


Revision: 22175
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22175
Author:   aligorith
Date:     2009-08-03 15:09:23 +0200 (Mon, 03 Aug 2009)

Log Message:
-----------
2.5 - MetaBalls are now animateable

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/mball.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
    branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_header.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_header.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_channels.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_draw.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_header.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_action_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_meta_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_sequence_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_meta.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c	2009-08-03 13:09:23 UTC (rev 22175)
@@ -71,7 +71,7 @@
 	switch (GS(id->name)) {
 			/* has AnimData */
 		case ID_OB:
-		case ID_CU:
+		case ID_MB: case ID_CU:
 		case ID_KE:
 		case ID_PA:
 		case ID_MA: case ID_TE: case ID_NT:
@@ -1442,6 +1442,9 @@
 		// TODO: we probably need the same hack as for curves (ctime-hack)
 	EVAL_ANIM_IDS(main->key.first, ADT_RECALC_ANIM);
 	
+	/* metaballs */
+	EVAL_ANIM_IDS(main->mball.first, ADT_RECALC_ANIM);
+	
 	/* curves */
 		/* we need to perform a special hack here to ensure that the ctime 
 		 * value of the curve gets set in case there's no animation for that

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/mball.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/mball.c	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/mball.c	2009-08-03 13:09:23 UTC (rev 22175)
@@ -55,6 +55,7 @@
 #include "BKE_main.h"
 
 /*  #include "BKE_object.h" */
+#include "BKE_animsys.h"
 #include "BKE_scene.h"
 #include "BKE_blender.h"
 #include "BKE_library.h"
@@ -90,6 +91,7 @@
 {
 	unlink_mball(mb);	
 	
+	if(mb->adt) BKE_free_animdata((ID *)mb);
 	if(mb->mat) MEM_freeN(mb->mat);
 	if(mb->bb) MEM_freeN(mb->bb);
 	BLI_freelistN(&mb->elems);

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-03 13:09:23 UTC (rev 22175)
@@ -2488,7 +2488,8 @@
 	mb= main->mball.first;
 	while(mb) {
 		if(mb->id.flag & LIB_NEEDLINK) {
-
+			if (mb->adt) lib_link_animdata(fd, &mb->id, mb->adt);
+			
 			for(a=0; a<mb->totcol; a++) mb->mat[a]= newlibadr_us(fd, mb->id.lib, mb->mat[a]);
 
 			mb->ipo= newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX depreceated - old animation system
@@ -2501,6 +2502,9 @@
 
 static void direct_link_mball(FileData *fd, MetaBall *mb)
 {
+	mb->adt= newdataadr(fd, mb->adt);
+	direct_link_animdata(fd, mb->adt);
+	
 	mb->mat= newdataadr(fd, mb->mat);
 	test_pointer_array(fd, (void **)&mb->mat);
 
@@ -9946,6 +9950,9 @@
 	for(a=0; a<mb->totcol; a++) {
 		expand_doit(fd, mainvar, mb->mat[a]);
 	}
+	
+	if(mb->adt)
+		expand_animdata(fd, mainvar, mb->adt);
 }
 
 static void expand_curve(FileData *fd, Main *mainvar, Curve *cu)

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c	2009-08-03 13:09:23 UTC (rev 22175)
@@ -1297,6 +1297,7 @@
 
 			/* direct data */
 			writedata(wd, DATA, sizeof(void *)*mb->totcol, mb->mat);
+			if (mb->adt) write_animdata(wd, mb->adt);
 
 			ml= mb->elems.first;
 			while(ml) {

Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c	2009-08-03 13:09:23 UTC (rev 22175)
@@ -56,6 +56,7 @@
 #include "DNA_key_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
+#include "DNA_meta_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_windowmanager_types.h"
@@ -1066,7 +1067,7 @@
 			case ANIMTYPE_DSPART:
 			{
 				ParticleSettings *part= (ParticleSettings*)ale->data;
-
+				
 				if (ASUBCHANNEL_SEL_OK(ale)) {
 					if (setting == ACHANNEL_SETTING_EXPAND) {
 						ACHANNEL_SET_FLAG(part, mode, PART_DS_EXPAND);
@@ -1074,7 +1075,18 @@
 				}
 			}
 				break;
+			case ANIMTYPE_DSMBALL:
+			{
+				MetaBall *mb= (MetaBall *)ale->data;
 				
+				if (ASUBCHANNEL_SEL_OK(ale)) {
+					if (setting == ACHANNEL_SETTING_EXPAND) {
+						ACHANNEL_SET_FLAG(mb, mode, MB_DS_EXPAND);
+					}
+				}
+			}
+				break;
+				
 			case ANIMTYPE_GROUP:
 			{
 				bActionGroup *agrp= (bActionGroup *)ale->data;
@@ -1688,6 +1700,13 @@
 			notifierFlags |= ND_ANIMCHAN_EDIT;
 		}
 			break;
+		case ANIMTYPE_DSMBALL:
+		{
+			MetaBall *mb= (MetaBall *)ale->data;
+			mb->flag2 ^= MB_DS_EXPAND;
+			notifierFlags |= ND_ANIMCHAN_EDIT;
+		}
+			break;
 			
 		case ANIMTYPE_GROUP: 
 		{

Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c	2009-08-03 13:09:23 UTC (rev 22175)
@@ -62,6 +62,7 @@
 #include "DNA_key_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
+#include "DNA_meta_types.h"
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_space_types.h"
@@ -1090,6 +1091,14 @@
 			expanded= FILTER_CUR_OBJD(cu);
 		}
 			break;
+		case OB_MBALL: /* ------- MetaBall ---------- */
+		{
+			MetaBall *mb= (MetaBall *)ob->data;
+			
+			type= ANIMTYPE_DSMBALL;
+			expanded= FILTER_MBALL_OBJD(mb);
+		}
+			break;
 	}
 	
 	/* special exception for drivers instead of action */
@@ -1273,12 +1282,25 @@
 			}
 		}
 			break;
+		case OB_MBALL: /* ------- MetaBall ---------- */
+		{
+			MetaBall *mb= (MetaBall *)ob->data;
+			
+			if ((ads->filterflag & ADS_FILTER_NOMBA) == 0) {
+				ANIMDATA_FILTER_CASES(mb,
+					{ /* AnimData blocks - do nothing... */ },
+					obdata_ok= 1;,
+					obdata_ok= 1;,
+					obdata_ok= 1;)
+			}
+		}
+			break;
 	}
 	if (obdata_ok) 
 		items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
 
 	/* particles */
-	if(ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART))
+	if (ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART))
 		items += animdata_filter_dopesheet_particles(anim_data, ads, base, filter_mode);
 	
 	/* return the number of items added to the list */
@@ -1595,6 +1617,23 @@
 							dataOk= !(ads->filterflag & ADS_FILTER_NOCUR);)
 					}
 						break;
+					case OB_MBALL: /* ------- MetaBall ---------- */
+					{
+						MetaBall *mb= (MetaBall *)ob->data;
+						dataOk= 0;
+						ANIMDATA_FILTER_CASES(mb, 
+							if ((ads->filterflag & ADS_FILTER_NOMBA)==0) {
+								/* for the special AnimData blocks only case, we only need to add
+								 * the block if it is valid... then other cases just get skipped (hence ok=0)
+								 */
+								ANIMDATA_ADD_ANIMDATA(mb);
+								dataOk=0;
+							},
+							dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);, 
+							dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);, 
+							dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);)
+					}
+						break;
 					default: /* --- other --- */
 						dataOk= 0;
 						break;
@@ -1671,6 +1710,12 @@
 						dataOk= ANIMDATA_HAS_KEYS(cu);	
 					}
 						break;
+					case OB_MBALL: /* -------- Metas ---------- */
+					{
+						MetaBall *mb= (MetaBall *)ob->data;
+						dataOk= ANIMDATA_HAS_KEYS(mb);	
+					}
+						break;
 					default: /* --- other --- */
 						dataOk= 0;
 						break;

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h	2009-08-03 13:09:23 UTC (rev 22175)
@@ -131,6 +131,7 @@
 	ANIMTYPE_DSSKEY,
 	ANIMTYPE_DSWOR,
 	ANIMTYPE_DSPART,
+	ANIMTYPE_DSMBALL,
 	
 	ANIMTYPE_SHAPEKEY,		// XXX probably can become depreceated???
 	
@@ -196,6 +197,7 @@
 #define FILTER_CAM_OBJD(ca) ((ca->flag & CAM_DS_EXPAND))
 #define FILTER_CUR_OBJD(cu) ((cu->flag & CU_DS_EXPAND))
 #define FILTER_PART_OBJD(part) ((part->flag & PART_DS_EXPAND))
+#define FILTER_MBALL_OBJD(mb) ((mb->flag2 & MB_DS_EXPAND))
 	/* 'Sub-object/Action' channels (flags stored in Action) */
 #define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED))
 #define EXPANDED_ACTC(actc) ((actc->flag & ACT_COLLAPSED)==0)

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c	2009-08-03 13:09:23 UTC (rev 22175)
@@ -60,6 +60,7 @@
 #include "DNA_key_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
+#include "DNA_meta_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_windowmanager_types.h"
@@ -653,7 +654,23 @@
 					strcpy(name, part->id.name+2);
 				}
 					break;
+				case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */
+				{
+					MetaBall *mb = (MetaBall *)ale->data;
 					
+					group = 4;
+					indent = 1;
+					special = ICON_META_DATA;
+					
+					if (FILTER_MBALL_OBJD(mb))
+						expand = ICON_TRIA_DOWN;
+					else
+						expand = ICON_TRIA_RIGHT;
+					
+					strcpy(name, mb->id.name+2);
+				}
+					break;
+					
 				
 				case ANIMTYPE_GROUP: /* action group */
 				{

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_header.c	2009-08-03 12:11:50 UTC (rev 22174)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_header.c	2009-08-03 13:09:23 UTC (rev 22175)
@@ -386,6 +386,7 @@
 				uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA,	(short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Lamps");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list