[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22774] branches/blender2.5/blender/source /blender: Pointcache:
Daniel Genrich
daniel.genrich at gmx.net
Tue Aug 25 20:41:36 CEST 2009
Revision: 22774
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22774
Author: genscher
Date: 2009-08-25 20:41:36 +0200 (Tue, 25 Aug 2009)
Log Message:
-----------
Pointcache:
*introducing unique ID's following brechts hint from ML
Enhancements resulting from this:
* multiple caches per modifier stack position
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/BKE_object.h
branches/blender2.5/blender/source/blender/blenkernel/intern/object.c
branches/blender2.5/blender/source/blender/blenkernel/intern/pointcache.c
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
branches/blender2.5/blender/source/blender/editors/space_view3d/drawvolume.c
branches/blender2.5/blender/source/blender/gpu/intern/gpu_extensions.c
branches/blender2.5/blender/source/blender/makesdna/DNA_object_types.h
Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_object.h 2009-08-25 17:32:01 UTC (rev 22773)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_object.h 2009-08-25 18:41:36 UTC (rev 22774)
@@ -115,6 +115,11 @@
float give_timeoffset(struct Object *ob);
int give_obdata_texspace(struct Object *ob, int **texflag, float **loc, float **size, float **rot);
+
+int object_insert_pc(struct Object *ob);
+// void object_delete_pc(struct Object *ob, int index);
+
+
#ifdef __cplusplus
}
#endif
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/object.c 2009-08-25 17:32:01 UTC (rev 22773)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/object.c 2009-08-25 18:41:36 UTC (rev 22774)
@@ -307,6 +307,8 @@
if(ob->gpulamp.first) GPU_lamp_free(ob);
free_sculptsession(&ob->sculpt);
+
+ if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
}
static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin)
@@ -1016,6 +1018,8 @@
ob->fluidsimFlag = 0;
ob->fluidsimSettings = NULL;
+ ob->pc_ids.first = ob->pc_ids.last = NULL;
+
return ob;
}
@@ -1268,7 +1272,8 @@
obn->derivedFinal = NULL;
obn->gpulamp.first = obn->gpulamp.last = NULL;
-
+ obn->pc_ids.first = obn->pc_ids.last = NULL;
+
return obn;
}
@@ -2535,3 +2540,61 @@
return result;
}
+
+static int pc_cmp(void *a, void *b)
+{
+ LinkData *ad = a, *bd = b;
+ if((int)ad->data > (int)bd->data)
+ return 1;
+ else return 0;
+}
+
+int object_insert_pc(Object *ob)
+{
+ LinkData *link = NULL;
+ int i = 0;
+
+ BLI_sortlist(&ob->pc_ids, pc_cmp);
+
+ for(link=ob->pc_ids.first, i = 0; link; link=link->next, i++)
+ {
+ int index =(int)link->data;
+
+ if(i < index)
+ break;
+ }
+
+ link = MEM_callocN(sizeof(LinkData), "PCLink");
+ link->data = (void *)i;
+ BLI_addtail(&ob->pc_ids, link);
+
+ return i;
+}
+
+static int pc_findindex(ListBase *listbase, int index)
+{
+ LinkData *link= NULL;
+ int number= 0;
+
+ if (listbase == NULL) return -1;
+
+ link= listbase->first;
+ while (link) {
+ if ((int)link->data == index)
+ return number;
+
+ number++;
+ link= link->next;
+ }
+
+ return -1;
+}
+
+#if 0
+void object_delete_pc(Object *ob, int index)
+{
+ int list_index = pc_findindex(&ob->pc_ids, index);
+ LinkData *link = BLI_findlink(&ob->pc_ids, list_index);
+ BLI_freelinkN(&ob->pc_ids, link);
+}
+#endif
\ No newline at end of file
Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/pointcache.c 2009-08-25 17:32:01 UTC (rev 22773)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/pointcache.c 2009-08-25 18:41:36 UTC (rev 22774)
@@ -391,8 +391,6 @@
void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
{
ParticleSystemModifierData *psmd;
- ModifierData *md;
- int a;
memset(pid, 0, sizeof(PTCacheID));
@@ -418,16 +416,10 @@
if(sb->particles) {
psmd= psys_get_modifier(ob, sb->particles);
- pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd);
+ // pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); XXX TODO - get other index DG
}
- else {
- for(a=0, md=ob->modifiers.first; md; md=md->next, a++) {
- if(md->type == eModifierType_Softbody) {
- pid->stack_index = a;
- break;
- }
- }
- }
+ else
+ pid->stack_index = pid->cache->index;
}
void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys)
@@ -439,7 +431,7 @@
pid->ob= ob;
pid->calldata= psys;
pid->type= PTCACHE_TYPE_PARTICLES;
- pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)psmd);
+ pid->stack_index= psys->pointcache->index;
pid->cache= psys->pointcache;
pid->cache_ptr= &psys->pointcache;
pid->ptcaches= &psys->ptcaches;
@@ -728,7 +720,7 @@
pid->calldata= smd;
pid->type= PTCACHE_TYPE_SMOKE_DOMAIN;
- pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)smd);
+ pid->stack_index= sds->point_cache->index;
pid->cache= sds->point_cache;
pid->cache_ptr= &sds->point_cache;
@@ -758,7 +750,7 @@
pid->ob= ob;
pid->calldata= clmd;
pid->type= PTCACHE_TYPE_CLOTH;
- pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)clmd);
+ pid->stack_index= clmd->point_cache->index;
pid->cache= clmd->point_cache;
pid->cache_ptr= &clmd->point_cache;
pid->ptcaches= &clmd->ptcaches;
@@ -901,6 +893,10 @@
}
if (do_ext) {
+
+ if(pid->cache->index < 0)
+ pid->cache->index = pid->stack_index = object_insert_pc(pid->ob);
+
if(pid->cache->flag & PTCACHE_EXTERNAL) {
if(pid->cache->index >= 0)
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
@@ -1952,6 +1948,7 @@
cache->startframe= 1;
cache->endframe= 250;
cache->step= 10;
+ cache->index = -1;
BLI_addtail(ptcaches, cache);
Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c 2009-08-25 17:32:01 UTC (rev 22773)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c 2009-08-25 18:41:36 UTC (rev 22774)
@@ -3993,6 +3993,7 @@
ob->derivedDeform= NULL;
ob->derivedFinal= NULL;
ob->gpulamp.first= ob->gpulamp.last= NULL;
+ link_list(fd, &ob->pc_ids);
if(ob->sculpt)
ob->sculpt= MEM_callocN(sizeof(SculptSession), "reload sculpt session");
Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/drawvolume.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/drawvolume.c 2009-08-25 17:32:01 UTC (rev 22773)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/drawvolume.c 2009-08-25 18:41:36 UTC (rev 22774)
@@ -236,8 +236,7 @@
GPU_texture_bind(tex, 0);
- if (!GLEW_ARB_texture_non_power_of_two)
- {
+ if (!GLEW_ARB_texture_non_power_of_two) {
cor[0] = (float)res[0]/(float)larger_pow2(res[0]);
cor[1] = (float)res[1]/(float)larger_pow2(res[1]);
cor[2] = (float)res[2]/(float)larger_pow2(res[2]);
Modified: branches/blender2.5/blender/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- branches/blender2.5/blender/source/blender/gpu/intern/gpu_extensions.c 2009-08-25 17:32:01 UTC (rev 22773)
+++ branches/blender2.5/blender/source/blender/gpu/intern/gpu_extensions.c 2009-08-25 18:41:36 UTC (rev 22774)
@@ -337,8 +337,7 @@
return NULL;
}
- if (!GLEW_ARB_texture_non_power_of_two)
- {
+ if (!GLEW_ARB_texture_non_power_of_two) {
tex->w = larger_pow2(tex->w);
tex->h = larger_pow2(tex->h);
tex->depth = larger_pow2(tex->depth);
Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_object_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_object_types.h 2009-08-25 17:32:01 UTC (rev 22773)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_object_types.h 2009-08-25 18:41:36 UTC (rev 22774)
@@ -237,6 +237,7 @@
int pad2;
ListBase gpulamp; /* runtime, for lamps only */
+ ListBase pc_ids;
} Object;
/* Warning, this is not used anymore because hooks are now modifiers */
More information about the Bf-blender-cvs
mailing list