[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29845] branches/soc-2010-aligorith-2/ source/blender: Bullet SoC - WIP Commit (File IO)

Joshua Leung aligorith at gmail.com
Thu Jul 1 14:59:23 CEST 2010


Revision: 29845
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29845
Author:   aligorith
Date:     2010-07-01 14:59:23 +0200 (Thu, 01 Jul 2010)

Log Message:
-----------
Bullet SoC - WIP Commit (File IO)

I've started coding the File IO stuff. However, I've run into some problems trying to get the data to load again (which I've never ever seen before so far), which currently seem like they're caused by the data not being saved at all. Ideas on solving this are welcome.

Also fixed extra warning print for remove rigidbody operator.

Modified Paths:
--------------
    branches/soc-2010-aligorith-2/source/blender/blenkernel/BKE_rigidbody.h
    branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/object.c
    branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c
    branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/scene.c
    branches/soc-2010-aligorith-2/source/blender/blenloader/intern/readfile.c
    branches/soc-2010-aligorith-2/source/blender/blenloader/intern/writefile.c
    branches/soc-2010-aligorith-2/source/blender/editors/physics/rigidbody_object.c

Modified: branches/soc-2010-aligorith-2/source/blender/blenkernel/BKE_rigidbody.h
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/blenkernel/BKE_rigidbody.h	2010-07-01 11:58:48 UTC (rev 29844)
+++ branches/soc-2010-aligorith-2/source/blender/blenkernel/BKE_rigidbody.h	2010-07-01 12:59:23 UTC (rev 29845)
@@ -45,6 +45,10 @@
 
 void BKE_rigidbody_free_object(struct Object *ob);
 
+/* ...... */
+
+struct RigidBodyOb *BKE_rigidbody_copy_object(struct Object *ob);
+
 /* -------------- */
 /* Setup */
 

Modified: branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/object.c	2010-07-01 11:58:48 UTC (rev 29844)
+++ branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/object.c	2010-07-01 12:59:23 UTC (rev 29845)
@@ -1278,6 +1278,8 @@
 	obn->path= NULL;
 	obn->flag &= ~OB_FROMGROUP;
 	
+	obn->rigidbodySettings = BKE_rigidbody_copy_object(ob);
+	
 	obn->modifiers.first = obn->modifiers.last= NULL;
 	
 	for (md=ob->modifiers.first; md; md=md->next) {

Modified: branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c	2010-07-01 11:58:48 UTC (rev 29844)
+++ branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c	2010-07-01 12:59:23 UTC (rev 29845)
@@ -126,6 +126,17 @@
 	ob->rigidbodySettings = NULL;
 }
 
+/* Copying Methods --------------------- */
+
+/* Make a copy of Rigid Body settings for given Object, returning a new copy 
+ * that can be used later...
+ */
+RigidBodyOb *BKE_rigidbody_copy_object (Object *ob)
+{
+	// FIXME: this cannot be linked to scenes correctly... we need some correction logic!
+	return NULL;
+}
+
 /* ************************************** */
 /* Setup Utilities - Validate Sim Instances */
 

Modified: branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/scene.c	2010-07-01 11:58:48 UTC (rev 29844)
+++ branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/scene.c	2010-07-01 12:59:23 UTC (rev 29845)
@@ -171,6 +171,7 @@
 		BLI_duplicatelist(&(scen->markers), &(sce->markers));
 		BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces));
 		BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers));
+		BLI_duplicatelist(&(scen->rigidbody_worlds), &(sce->rigidbody_worlds));
 		BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets));
 		
 		scen->nodetree= ntreeCopyTree(sce->nodetree, 0);

Modified: branches/soc-2010-aligorith-2/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/blenloader/intern/readfile.c	2010-07-01 11:58:48 UTC (rev 29844)
+++ branches/soc-2010-aligorith-2/source/blender/blenloader/intern/readfile.c	2010-07-01 12:59:23 UTC (rev 29845)
@@ -85,6 +85,7 @@
 #include "DNA_packedFile_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_property_types.h"
+#include "DNA_rigidbody_types.h"
 #include "DNA_text_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_screen_types.h"
@@ -4015,7 +4016,18 @@
 	}
 	ob->bsoft= newdataadr(fd, ob->bsoft);
 	ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
-
+	
+	ob->rigidbodySettings = newdataadr(fd, ob->rigidbodySettings);
+	if (ob->rigidbodySettings) {
+		RigidBodyOb *rbo = ob->rigidbodySettings;
+		
+		/* must nullify the references to physics sim objects, since they no-longer exist 
+		 * (and will need to be recalculated) 
+		 */
+		rbo->physics_object = NULL;
+		rbo->physics_shape = NULL;
+	}
+	
 	link_list(fd, &ob->particlesystem);
 	direct_link_particlesystems(fd,&ob->particlesystem);
 	
@@ -4133,6 +4145,7 @@
 	Sequence *seq;
 	SceneRenderLayer *srl;
 	TimeMarker *marker;
+	RigidBodyWorld *rbw;
 	
 	sce= main->scene.first;
 	while(sce) {
@@ -4201,7 +4214,13 @@
 				}
 			}
 #endif
-
+			
+			/* rigidbody worlds rely on their linked groups */
+			for (rbw= sce->rigidbody_worlds.first; rbw; rbw= rbw->next) {
+				if (rbw->group)
+					rbw->group= newlibadr(fd, sce->id.lib, rbw->group);
+			}
+			
 			if(sce->ed)
 				seq_update_muting(sce, sce->ed);
 			
@@ -4433,6 +4452,25 @@
 	if(sce->nodetree)
 		direct_link_nodetree(fd, sce->nodetree);
 	
+	printf("rbws pre relink - %p %p \n", sce->rigidbody_worlds.first, sce->rigidbody_worlds.last);
+	link_list(fd, &sce->rigidbody_worlds);
+	if (sce->rigidbody_worlds.first) {
+		RigidBodyWorld *rbw;
+		
+		printf("rbw's read in - %p %p \n", sce->rigidbody_worlds.first, sce->rigidbody_worlds.last);
+		
+		for (rbw = sce->rigidbody_worlds.first; rbw; rbw= rbw->next) {
+			/* must nullify the references to physics sim objects, since they no-longer exist 
+			 * (and will need to be recalculated) 
+			 */
+			rbw->physics_world = NULL;
+			
+			/* also, set flag to have world rebuilt on first refresh... */
+			rbw->recalc = RBW_RECALC_REBUILD|RBW_RECALC_REQUIRED;
+		}
+	}
+	else
+		printf("no rbw read in... - %p %p\n", sce->rigidbody_worlds.first, sce->rigidbody_worlds.last);
 }
 
 /* ************ READ WM ***************** */
@@ -11808,6 +11846,7 @@
 {
 	Base *base;
 	SceneRenderLayer *srl;
+	RigidBodyWorld *rbw;
 
 	for(base= sce->base.first; base; base= base->next) {
 		expand_doit(fd, mainvar, base->object);
@@ -11846,6 +11885,9 @@
 		}
 		SEQ_END
 	}
+	
+	for(rbw= sce->rigidbody_worlds.first; rbw; rbw= rbw->next)
+		expand_doit(fd, mainvar, rbw->group);
 
 #ifdef DURIAN_CAMERA_SWITCH
 	{

Modified: branches/soc-2010-aligorith-2/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/blenloader/intern/writefile.c	2010-07-01 11:58:48 UTC (rev 29844)
+++ branches/soc-2010-aligorith-2/source/blender/blenloader/intern/writefile.c	2010-07-01 12:59:23 UTC (rev 29845)
@@ -123,6 +123,7 @@
 #include "DNA_packedFile_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_property_types.h"
+#include "DNA_rigidbody_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_sdna_types.h"
 #include "DNA_sequence_types.h"
@@ -1288,6 +1289,11 @@
 			}
 			writestruct(wd, DATA, "BulletSoftBody", 1, ob->bsoft);
 			
+			if (ob->rigidbodySettings) {
+				// TODO: if any extra data is added to handle duplis, will need separate function then
+				writestruct(wd, DATA, "RigidBodyOb", 1, ob->rigidbodySettings);
+			}
+			
 			write_particlesystems(wd, &ob->particlesystem);
 			write_modifiers(wd, &ob->modifiers);
 		}
@@ -1787,6 +1793,7 @@
 	TransformOrientation *ts;
 	SceneRenderLayer *srl;
 	ToolSettings *tos;
+	RigidBodyWorld *rbw;
 	
 	sce= scebase->first;
 	while(sce) {
@@ -1918,6 +1925,12 @@
 			write_nodetree(wd, sce->nodetree);
 		}
 		
+		/* writing dynamic list of RigidBodyWorlds to the blend file */
+		for(rbw = sce->rigidbody_worlds.first; rbw; rbw = rbw->next) {
+			printf("RigidBodyWorld saved...\n");
+			writestruct(wd, DATA, "RigidBodyWorld", 1, rbw);
+		}
+		
 		sce= sce->id.next;
 	}
 	/* flush helps the compression for undo-save */

Modified: branches/soc-2010-aligorith-2/source/blender/editors/physics/rigidbody_object.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/editors/physics/rigidbody_object.c	2010-07-01 11:58:48 UTC (rev 29844)
+++ branches/soc-2010-aligorith-2/source/blender/editors/physics/rigidbody_object.c	2010-07-01 12:59:23 UTC (rev 29845)
@@ -186,7 +186,6 @@
 {
 	Scene *scene = CTX_data_scene(C);
 	Object *ob = OBACT;
-	int type = RNA_enum_get(op->ptr, "type");
 	
 	/* sanity checks */
 	if (scene == NULL) 





More information about the Bf-blender-cvs mailing list