Pointcache:
*introducing unique ID's following brechts hint from ML Enhancements resulting from this: * multiple caches per modifier stack position
This commit is contained in:
@@ -115,6 +115,11 @@ void object_handle_update(struct Scene *scene, struct Object *ob);
|
||||
|
||||
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
|
||||
|
||||
@@ -307,6 +307,8 @@ void free_object(Object *ob)
|
||||
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 @@ Object *add_only_object(int type, char *name)
|
||||
ob->fluidsimFlag = 0;
|
||||
ob->fluidsimSettings = NULL;
|
||||
|
||||
ob->pc_ids.first = ob->pc_ids.last = NULL;
|
||||
|
||||
return ob;
|
||||
}
|
||||
|
||||
@@ -1268,7 +1272,8 @@ Object *copy_object(Object *ob)
|
||||
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 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
|
||||
|
||||
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
|
||||
@@ -391,8 +391,6 @@ static int ptcache_totpoint_cloth(void *cloth_v)
|
||||
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 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
|
||||
|
||||
if(sb->particles) {
|
||||
psmd= psys_get_modifier(ob, sb->particles);
|
||||
pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd);
|
||||
}
|
||||
else {
|
||||
for(a=0, md=ob->modifiers.first; md; md=md->next, a++) {
|
||||
if(md->type == eModifierType_Softbody) {
|
||||
pid->stack_index = a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); XXX TODO - get other index DG
|
||||
}
|
||||
else
|
||||
pid->stack_index = pid->cache->index;
|
||||
}
|
||||
|
||||
void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys)
|
||||
@@ -439,7 +431,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
|
||||
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 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
|
||||
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 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl
|
||||
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 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho
|
||||
}
|
||||
|
||||
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 @@ PointCache *BKE_ptcache_add(ListBase *ptcaches)
|
||||
cache->startframe= 1;
|
||||
cache->endframe= 250;
|
||||
cache->step= 10;
|
||||
cache->index = -1;
|
||||
|
||||
BLI_addtail(ptcaches, cache);
|
||||
|
||||
|
||||
@@ -3993,6 +3993,7 @@ static void direct_link_object(FileData *fd, Object *ob)
|
||||
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");
|
||||
|
||||
@@ -236,8 +236,7 @@ void draw_volume(Scene *scene, ARegion *ar, View3D *v3d, Base *base, GPUTexture
|
||||
|
||||
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]);
|
||||
|
||||
@@ -337,8 +337,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels)
|
||||
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);
|
||||
|
||||
@@ -237,6 +237,7 @@ typedef struct Object {
|
||||
int pad2;
|
||||
|
||||
ListBase gpulamp; /* runtime, for lamps only */
|
||||
ListBase pc_ids;
|
||||
} Object;
|
||||
|
||||
/* Warning, this is not used anymore because hooks are now modifiers */
|
||||
|
||||
Reference in New Issue
Block a user