different way of attaching hanim nodes to frames

This commit is contained in:
aap 2018-03-18 22:45:24 +01:00
parent dbb131d92b
commit 2721f48793
2 changed files with 23 additions and 1 deletions

View File

@ -78,11 +78,23 @@ findById(Frame *f, int32 id)
return findById(f->child, id);
}
static Frame*
findUnattachedById(HAnimHierarchy *hier, Frame *f, int32 id)
{
if(f == nil) return nil;
HAnimData *hanim = HAnimData::get(f);
if(hanim->id >= 0 && hanim->id == id && hier->getIndex(f) == -1) return f;
Frame *ff = findUnattachedById(hier, f->next, id);
if(ff) return ff;
return findUnattachedById(hier, f->child, id);
}
void
HAnimHierarchy::attachByIndex(int32 idx)
{
int32 id = this->nodeInfo[idx].id;
Frame *f = findById(this->parentFrame, id);
// Frame *f = findById(this->parentFrame, id);
Frame *f = findUnattachedById(this, this->parentFrame, id);
this->nodeInfo[idx].frame = f;
}
@ -102,6 +114,15 @@ HAnimHierarchy::getIndex(int32 id)
return -1;
}
int32
HAnimHierarchy::getIndex(Frame *f)
{
for(int32 i = 0; i < this->numNodes; i++)
if(this->nodeInfo[i].frame == f)
return i;
return -1;
}
HAnimHierarchy*
HAnimHierarchy::get(Frame *f)
{

View File

@ -45,6 +45,7 @@ struct HAnimHierarchy
void attachByIndex(int32 id);
void attach(void);
int32 getIndex(int32 id);
int32 getIndex(Frame *f);
void updateMatrices(void);
static HAnimHierarchy *get(Frame *f);