[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14376] trunk/blender/source/blender:

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Apr 10 13:39:26 CEST 2008


Revision: 14376
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14376
Author:   blendix
Date:     2008-04-10 13:39:20 +0200 (Thu, 10 Apr 2008)

Log Message:
-----------

Point Cache Refactoring
=======================

Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.

Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).

Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.

Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.

Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.

Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_cloth.h
    trunk/blender/source/blender/blenkernel/BKE_depsgraph.h
    trunk/blender/source/blender/blenkernel/BKE_particle.h
    trunk/blender/source/blender/blenkernel/BKE_pointcache.h
    trunk/blender/source/blender/blenkernel/BKE_softbody.h
    trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
    trunk/blender/source/blender/blenkernel/intern/cloth.c
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/blenkernel/intern/modifier.c
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenkernel/intern/particle.c
    trunk/blender/source/blender/blenkernel/intern/particle_system.c
    trunk/blender/source/blender/blenkernel/intern/pointcache.c
    trunk/blender/source/blender/blenkernel/intern/softbody.c
    trunk/blender/source/blender/blenlib/intern/fileops.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/include/butspace.h
    trunk/blender/source/blender/makesdna/DNA_cloth_types.h
    trunk/blender/source/blender/makesdna/DNA_modifier_types.h
    trunk/blender/source/blender/makesdna/DNA_object_force.h
    trunk/blender/source/blender/makesdna/DNA_particle_types.h
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/buttons_object.c
    trunk/blender/source/blender/src/drawview.c
    trunk/blender/source/blender/src/edit.c
    trunk/blender/source/blender/src/editipo.c
    trunk/blender/source/blender/src/editmesh.c
    trunk/blender/source/blender/src/editnla.c
    trunk/blender/source/blender/src/editobject.c
    trunk/blender/source/blender/src/editparticle.c
    trunk/blender/source/blender/src/fluidsim.c
    trunk/blender/source/blender/src/header_time.c
    trunk/blender/source/blender/src/interface_panel.c
    trunk/blender/source/blender/src/poselib.c
    trunk/blender/source/blender/src/space.c
    trunk/blender/source/blender/src/toets.c
    trunk/blender/source/blender/src/transform.c
    trunk/blender/source/blender/src/transform_conversions.c
    trunk/blender/source/blender/src/transform_generics.c
    trunk/blender/source/blender/src/vpaint.c

Modified: trunk/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_cloth.h	2008-04-10 11:34:36 UTC (rev 14375)
+++ trunk/blender/source/blender/blenkernel/BKE_cloth.h	2008-04-10 11:39:20 UTC (rev 14376)
@@ -147,16 +147,18 @@
 /* These are the bits used in SimSettings.flags. */
 typedef enum
 {
-	CLOTH_SIMSETTINGS_FLAG_RESET = ( 1 << 1 ),	// The CM object requires a reinitializaiton.
+	//CLOTH_SIMSETTINGS_FLAG_RESET = ( 1 << 1 ),	// The CM object requires a reinitializaiton.
 	CLOTH_SIMSETTINGS_FLAG_COLLOBJ = ( 1 << 2 ),// object is only collision object, no cloth simulation is done
 	CLOTH_SIMSETTINGS_FLAG_GOAL = ( 1 << 3 ), 	// we have goals enabled
 	CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled
-	CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT = ( 1 << 5 ), // true if tearing is enabled
-	CLOTH_SIMSETTINGS_FLAG_EDITMODE = ( 1 << 6 ), // are we in editmode? -several things disabled
-	CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE = ( 1 << 7 ), /* force cache freeing */
+	//CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT = ( 1 << 5 ), // true if tearing is enabled
+	//CLOTH_SIMSETTINGS_FLAG_EDITMODE = ( 1 << 6 ), // are we in editmode? -several things disabled
+	//CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE = ( 1 << 7 ), /* force cache freeing */
 	CLOTH_SIMSETTINGS_FLAG_SCALING = ( 1 << 8 ), /* is advanced scaling active? */
-	CLOTH_SIMSETTINGS_FLAG_LOADED = ( 1 << 9 ), /* did we just got load? */
-	CLOTH_SIMSETTINGS_FLAG_AUTOPROTECT = ( 1 << 10 ), /* is autoprotect enabled? */
+	//CLOTH_SIMSETTINGS_FLAG_LOADED = ( 1 << 9 ), /* did we just got load? */
+	//CLOTH_SIMSETTINGS_FLAG_AUTOPROTECT = ( 1 << 10 ), /* is autoprotect enabled? */
+	//CLOTH_SIMSETTINGS_FLAG_CCACHE_OUTDATED = (1 << 11),	/* while protected, did cache get outdated? */
+	CLOTH_SIMSETTINGS_FLAG_CCACHE_EDIT = (1 << 12)	/* edit cache in editmode */
 } CLOTH_SIMSETTINGS_FLAGS;
 
 /* COLLISION FLAGS */

Modified: trunk/blender/source/blender/blenkernel/BKE_depsgraph.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_depsgraph.h	2008-04-10 11:34:36 UTC (rev 14375)
+++ trunk/blender/source/blender/blenkernel/BKE_depsgraph.h	2008-04-10 11:39:20 UTC (rev 14376)
@@ -104,7 +104,7 @@
 void	DAG_object_update_flags(struct Scene *sce, struct Object *ob, unsigned int lay);
 
 		/* flushes all recalc flags in objects down the dependency tree */
-void	DAG_scene_flush_update(struct Scene *sce, unsigned int lay);
+void	DAG_scene_flush_update(struct Scene *sce, unsigned int lay, int time);
 		/* flushes all recalc flags for this object down the dependency tree */
 void	DAG_object_flush_update(struct Scene *sce, struct Object *ob, short flag);
 

Modified: trunk/blender/source/blender/blenkernel/BKE_particle.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_particle.h	2008-04-10 11:34:36 UTC (rev 14375)
+++ trunk/blender/source/blender/blenkernel/BKE_particle.h	2008-04-10 11:39:20 UTC (rev 14376)
@@ -41,6 +41,7 @@
 struct ParticleSystemModifierData;
 struct ParticleSystem;
 struct ParticleKey;
+struct ParticleSettings;
 struct HairKey;
 
 struct Main;
@@ -222,9 +223,6 @@
 int psys_render_simplify_distribution(struct ParticleThreadContext *ctx, int tot);
 int psys_render_simplify_params(struct ParticleSystem *psys, struct ChildParticle *cpa, float *params);
 
-void clear_particles_from_cache(struct Object *ob, struct ParticleSystem *psys, int cfra);
-//void psys_remove_from_particle_list(struct Object *ob, short nbr, struct ParticleSystem *psys);
-
 void psys_interpolate_uvs(struct MTFace *tface, int quad, float *uv, float *uvco);
 void psys_interpolate_mcol(struct MCol *mcol, int quad, float *uv, struct MCol *mc);
 
@@ -237,6 +235,10 @@
 struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part);
 void psys_flush_settings(struct ParticleSettings *part, int event, int hair_recalc);
 
+struct LinkNode *psys_using_settings(struct ParticleSettings *part, int flush_update);
+void psys_changed_type(struct ParticleSystem *psys);
+void psys_reset(struct ParticleSystem *psys, int mode);
+
 void psys_find_parents(struct Object *ob, struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys);
 
 void psys_cache_paths(struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate);
@@ -251,7 +253,7 @@
 void psys_get_dupli_texture(struct Object *ob, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, float *uv, float *orco);
 void psys_get_dupli_path_transform(struct Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[][4], float *scale);
 
-ParticleThread *psys_threads_create(struct Object *ob, struct ParticleSystem *psys, int totthread);
+ParticleThread *psys_threads_create(struct Object *ob, struct ParticleSystem *psys);
 int psys_threads_init_distribution(ParticleThread *threads, struct DerivedMesh *dm, int from);
 int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate);
 void psys_threads_free(ParticleThread *threads);
@@ -298,6 +300,11 @@
 void psys_calc_dmcache(struct Object *ob, struct DerivedMesh *dm, struct ParticleSystem *psys);
 int psys_particle_dm_face_lookup(struct Object *ob, struct DerivedMesh *dm, int index, float *fw, struct LinkNode *node);
 
+/* psys_reset */
+#define PSYS_RESET_ALL			1
+#define PSYS_RESET_DEPSGRAPH 	2
+#define PSYS_RESET_CHILDREN 	3
+
 /* ParticleEffectorCache->type */
 #define PSYS_EC_EFFECTOR	1
 #define PSYS_EC_DEFLECT		2

Modified: trunk/blender/source/blender/blenkernel/BKE_pointcache.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_pointcache.h	2008-04-10 11:34:36 UTC (rev 14375)
+++ trunk/blender/source/blender/blenkernel/BKE_pointcache.h	2008-04-10 11:39:20 UTC (rev 14376)
@@ -31,24 +31,84 @@
 
 #include "DNA_ID.h"
 
-/* options for clearing pointcache - used for BKE_ptcache_id_clear
- Before and after are non inclusive (they wont remove the cfra) */
+/* Point cache clearing option, for BKE_ptcache_id_clear, before
+ * and after are non inclusive (they wont remove the cfra) */
 #define PTCACHE_CLEAR_ALL		0
 #define PTCACHE_CLEAR_FRAME		1
 #define PTCACHE_CLEAR_BEFORE	2
 #define PTCACHE_CLEAR_AFTER		3
 
+/* Point cache reset options */
+#define PTCACHE_RESET_DEPSGRAPH		0
+#define PTCACHE_RESET_BAKED			1
+#define PTCACHE_RESET_OUTDATED		2
+
 /* Add the blendfile name after blendcache_ */
 #define PTCACHE_EXT ".bphys"
 #define PTCACHE_PATH "blendcache_"
 
+/* File open options, for BKE_ptcache_file_open */
+#define PTCACHE_FILE_READ	0
+#define PTCACHE_FILE_WRITE	1
+
+/* PTCacheID types */
+#define PTCACHE_TYPE_SOFTBODY	0
+#define PTCACHE_TYPE_PARTICLES	1
+#define PTCACHE_TYPE_CLOTH		2
+
+/* Structs */
+struct Object;
+struct SoftBody;
+struct ParticleSystem;
+struct ClothModifierData;
+struct PointCache;
+struct ListBase;
+
+typedef struct PTCacheFile {
+	FILE *fp;
+} PTCacheFile;
+
+typedef struct PTCacheID {
+	struct PTCacheID *next, *prev;
+
+	struct Object *ob;
+	void *data;
+	int type;
+	int stack_index;
+
+	struct PointCache *cache;
+} PTCacheID;
+
+/* Creating ID's */
+void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb);
+void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys);
+void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd);
+
+void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob);
+
 /* Global funcs */
 void BKE_ptcache_remove(void);
 
-/* Object spesific funcs */
-int		BKE_ptcache_id_filename(struct ID *id, char *filename, int cfra, int stack_index, short do_path, short do_ext);
-FILE *	BKE_ptcache_id_fopen(struct ID *id, char mode, int cfra, int stack_index);
-void	BKE_ptcache_id_clear(struct ID *id, char mode, int cfra, int stack_index);
-int		BKE_ptcache_id_exist(struct ID *id, int cfra, int stack_index);
+/* ID specific functions */
+void	BKE_ptcache_id_clear(PTCacheID *id, int mode, int cfra);
+int		BKE_ptcache_id_exist(PTCacheID *id, int cfra);
+int		BKE_ptcache_id_reset(PTCacheID *id, int mode);
+void	BKE_ptcache_id_time(PTCacheID *pid, float cfra, int *startframe, int *endframe, float *timescale);
+int		BKE_ptcache_object_reset(struct Object *ob, int mode);
 
+/* File reading/writing */
+PTCacheFile	*BKE_ptcache_file_open(PTCacheID *id, int mode, int cfra);
+void         BKE_ptcache_file_close(PTCacheFile *pf);
+int          BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot);
+int          BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot);
+
+/* Continue physics */
+void BKE_ptcache_set_continue_physics(int enable);
+int BKE_ptcache_get_continue_physics(void);
+
+/* Point Cache */
+struct PointCache *BKE_ptcache_add(void);
+void BKE_ptcache_free(struct PointCache *cache);
+struct PointCache *BKE_ptcache_copy(struct PointCache *cache);
+
 #endif

Modified: trunk/blender/source/blender/blenkernel/BKE_softbody.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_softbody.h	2008-04-10 11:34:36 UTC (rev 14375)
+++ trunk/blender/source/blender/blenkernel/BKE_softbody.h	2008-04-10 11:39:20 UTC (rev 14376)
@@ -55,7 +55,8 @@
 /* frees internal data and softbody itself */
 extern void				sbFree(struct SoftBody *sb);
 
-extern void				softbody_clear_cache(struct Object *ob, float framenr);
+/* frees simulation data to reset simulation */
+extern void				sbFreeSimulation(struct SoftBody *sb);
 
 /* do one simul step, reading and writing vertex locs from given array */
 extern void				sbObjectStep(struct Object *ob, float framnr, float (*vertexCos)[3], int numVerts);
@@ -67,6 +68,8 @@
 /* pass NULL to unlink again */
 extern void             sbSetInterruptCallBack(int (*f)(void));
 
+/* writing to cache for bake editing */
+extern void 			sbWriteCache(struct Object *ob, int framenr);
 
 #endif
 

Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list