[Bf-blender-cvs] [a12f3d1] alembic_pointcache: Removed or disabled remaining BKE_pointcache calls in particle_system. Only DNA read(!) access to PointCache is allowed (otherwise would have to wrap all the flag checks etc., this could be done later still).

Lukas Tönne noreply at git.blender.org
Thu Oct 16 16:53:54 CEST 2014


Commit: a12f3d1e8633bbb8ca0675918b3548dd4578e19e
Author: Lukas Tönne
Date:   Sun Dec 1 15:49:21 2013 +0100
Branches: alembic_pointcache
https://developer.blender.org/rBa12f3d1e8633bbb8ca0675918b3548dd4578e19e

Removed or disabled remaining BKE_pointcache calls in particle_system.
Only DNA read(!) access to PointCache is allowed (otherwise would have
to wrap all the flag checks etc., this could be done later still).

Particle edit mode uses a lot of badly designed point cache DNA writing,
so for now is disabled (or broken).

===================================================================

M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/pointcache/PTC_api.cpp
M	source/blender/pointcache/PTC_api.h

===================================================================

diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index a9fc6e6..7831f08 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -52,6 +52,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
+#include "DNA_pointcache_types.h"
 #include "DNA_object_force.h"
 #include "DNA_object_types.h"
 #include "DNA_material_types.h"
@@ -90,7 +91,6 @@
 #include "BKE_cloth.h"
 #include "BKE_depsgraph.h"
 #include "BKE_lattice.h"
-#include "BKE_pointcache.h"
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_scene.h"
@@ -188,7 +188,7 @@ void psys_reset(ParticleSystem *psys, int mode)
 	psys_free_path_cache(psys, psys->edit);
 
 	/* reset point cache */
-	BKE_ptcache_invalidate(psys->pointcache);
+	PTC_invalidate(psys->pointcache);
 
 	if (psys->fluid_springs) {
 		MEM_freeN(psys->fluid_springs);
@@ -2169,14 +2169,16 @@ static void set_keyed_keys(ParticleSimulationData *sim)
 void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys)
 {
 	if (psys->mem_pointcache.first == NULL) {
-		PTCacheID pid;
-		BKE_ptcache_id_from_particles(&pid, ob, psys);
-		BKE_ptcache_to_mem(&pid, &psys->mem_pointcache);
+		/* XXX TODO */
+//		PTCacheID pid;
+//		BKE_ptcache_id_from_particles(&pid, ob, psys);
+//		BKE_ptcache_to_mem(&pid, &psys->mem_pointcache);
 	}
 }
 static void psys_clear_temp_pointcache(ParticleSystem *psys)
 {
-	BKE_ptcache_free_mem(&psys->mem_pointcache);
+	/* XXX TODO */
+//	BKE_ptcache_free_mem(&psys->mem_pointcache);
 }
 void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
 {
@@ -4662,7 +4664,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
 		if (cfra == startframe) {
 			/* XXX anything to do here? */
 //			BKE_ptcache_id_reset(sim->scene, pid, PTCACHE_RESET_OUTDATED);
-//			BKE_ptcache_validate(cache, startframe);
+			PTC_validate(cache, startframe);
 			cache->state.flag &= ~PTC_STATE_REDO_NEEDED;
 		}
 		
@@ -4700,7 +4702,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
 			update_children(sim);
 			psys_update_path_cache(sim, cfra);
 
-			BKE_ptcache_validate(cache, (int)cache_cfra);
+			PTC_validate(cache, (int)cache_cfra);
 
 			/* XXX TODO */
 //			if (cache_result == PTC_READ_SAMPLE_INTERPOLATED && cache->state.flag & PTC_STATE_REDO_NEEDED)
@@ -4724,7 +4726,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
 //			BKE_ptcache_write(pid, startframe);
 	}
 	else
-		BKE_ptcache_invalidate(cache);
+		PTC_invalidate(cache);
 
 /* 3. do dynamics */
 	/* set particles to be not calculated TODO: can't work with pointcache */
@@ -4909,7 +4911,9 @@ static void psys_prepare_physics(ParticleSimulationData *sim)
 }
 static int hair_needs_recalc(ParticleSystem *psys)
 {
-	if (!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) &&
+	/* XXX TODO */
+//	if (!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) &&
+	if (!(psys->flag & PSYS_EDITED) && (!psys->edit || true) &&
 	    ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET || (psys->part->flag & PART_HAIR_REGROW && !psys->edit)))
 	{
 		return 1;
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 968680e..c1efd65 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -28,6 +28,8 @@
 #include "util_path.h"
 
 extern "C" {
+#include "BLI_math.h"
+
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_pointcache_types.h"
@@ -37,6 +39,24 @@ extern "C" {
 
 using namespace PTC;
 
+void PTC_validate(PointCache *cache, int framenr)
+{
+	if (cache) {
+		cache->state.flag |= PTC_STATE_SIMULATION_VALID;
+		cache->state.simframe = framenr;
+	}
+}
+
+void PTC_invalidate(PointCache *cache)
+{
+	if (cache) {
+		cache->state.flag &= ~PTC_STATE_SIMULATION_VALID;
+		cache->state.simframe = 0;
+		cache->state.last_exact = min_ii(cache->startframe, 0);
+	}
+}
+
+
 void PTC_writer_free(PTCWriter *_writer)
 {
 	PTC::Writer *writer = (PTC::Writer *)_writer;
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index 867a6cd..3aa4aa7 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -29,23 +29,26 @@ struct Main;
 struct Scene;
 struct Object;
 struct ParticleSystem;
+struct PointCache;
 struct PointerRNA;
 
 struct PTCWriter;
 struct PTCReader;
 
+void PTC_validate(struct PointCache *cache, int framenr);
+void PTC_invalidate(struct PointCache *cache);
+
+void PTC_bake(struct Main *bmain, struct Scene *scene, struct PTCWriter *writer, int start_frame, int end_frame,
+              short *stop, short *do_update, float *progress);
+
+
 void PTC_writer_free(struct PTCWriter *writer);
 void PTC_write_sample(struct PTCWriter *writer);
 
 void PTC_reader_free(struct PTCReader *reader);
 PTCReadSampleResult PTC_read_sample(struct PTCReader *reader, float frame);
-
 void PTC_reader_get_frame_range(struct PTCReader *reader, int *start_frame, int *end_frame);
 
-void PTC_bake(struct Main *bmain, struct Scene *scene, struct PTCWriter *writer, int start_frame, int end_frame,
-              short *stop, short *do_update, float *progress);
-
-
 /* get writer/reader from RNA type */
 struct PTCWriter *PTC_writer_from_rna(struct Scene *scene, struct PointerRNA *ptr);
 struct PTCReader *PTC_reader_from_rna(struct Scene *scene, struct PointerRNA *ptr);




More information about the Bf-blender-cvs mailing list