started implementing linked lists
This commit is contained in:
@ -11,37 +11,6 @@
|
||||
using namespace std;
|
||||
using namespace rw;
|
||||
|
||||
Frame*
|
||||
findHierCB(Frame *f, void *p)
|
||||
{
|
||||
HAnimData *hanim = PLUGINOFFSET(HAnimData, f, hAnimOffset);
|
||||
if(hanim->hierarchy){
|
||||
*(HAnimHierarchy**)p = hanim->hierarchy;
|
||||
return NULL;
|
||||
}
|
||||
f->forAllChildren(findHierCB, p);
|
||||
return f;
|
||||
}
|
||||
|
||||
HAnimHierarchy*
|
||||
getHierarchy(Clump *c)
|
||||
{
|
||||
HAnimHierarchy *hier = NULL;
|
||||
findHierCB((Frame*)c->parent, &hier);
|
||||
return hier;
|
||||
}
|
||||
|
||||
void
|
||||
fixLcsHier(HAnimHierarchy *hier)
|
||||
{
|
||||
hier->maxInterpKeyFrameSize = findAnimInterpolatorInfo(1)->keyFrameSize;
|
||||
for(int32 i = 0; i < hier->numNodes; i++){
|
||||
int32 id = hier->nodeInfo[i].id;
|
||||
if(id == 255) hier->nodeInfo[i].id = -1;
|
||||
else if(id > 0x80) hier->nodeInfo[i].id |= 0x1300;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -54,10 +23,6 @@ main(int argc, char *argv[])
|
||||
rw::platform = PLATFORM_D3D8;
|
||||
// rw::version = 0x30200;
|
||||
|
||||
int lcs = 1;
|
||||
matFXGlobals.hack = lcs;
|
||||
skinGlobals.forceSkipUsedBones = lcs;
|
||||
|
||||
gta::attachPlugins();
|
||||
|
||||
rw::Clump *c;
|
||||
@ -104,25 +69,10 @@ main(int argc, char *argv[])
|
||||
readChunkHeaderInfo(&in, &header);
|
||||
}
|
||||
assert(header.type == ID_CLUMP);
|
||||
if(lcs)
|
||||
c = clumpStreamReadRsl(&in);
|
||||
else
|
||||
c = Clump::streamRead(&in);
|
||||
c = Clump::streamRead(&in);
|
||||
assert(c != NULL);
|
||||
}
|
||||
|
||||
if(lcs){
|
||||
HAnimHierarchy *hier = getHierarchy(c);
|
||||
if(hier)
|
||||
fixLcsHier(hier);
|
||||
for(int32 i = 0; i < c->numAtomics; i++){
|
||||
Skin *skin = *PLUGINOFFSET(Skin*, c->atomicList[i]->geometry, skinGlobals.offset);
|
||||
convertRslGeometry(c->atomicList[i]->geometry);
|
||||
if(skin)
|
||||
c->atomicList[i]->pipeline = skinGlobals.pipelines[rw::platform];
|
||||
}
|
||||
}
|
||||
|
||||
if(rw::version == 0){
|
||||
rw::version = header.version;
|
||||
rw::build = header.build;
|
||||
@ -159,10 +109,7 @@ main(int argc, char *argv[])
|
||||
out.open(argv[2], "wb");
|
||||
else
|
||||
out.open("out.dff", "wb");
|
||||
// if(lcs)
|
||||
// clumpStreamWriteRsl(&out, c);
|
||||
// else
|
||||
c->streamWrite(&out);
|
||||
c->streamWrite(&out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
@ -28,17 +28,11 @@ RslMatrixSetIdentity(RslMatrix *matrix)
|
||||
void
|
||||
rslObjectHasFrameSetFrame(RslObjectHasFrame *object, RslFrame *f)
|
||||
{
|
||||
if(object->object.parent){
|
||||
object->lFrame.prev->next = object->lFrame.next;
|
||||
object->lFrame.next->prev = object->lFrame.prev;
|
||||
}
|
||||
object->object.parent = f;
|
||||
if(object->object.parent)
|
||||
rslLinkListRemoveLLLink(&object->lFrame);
|
||||
rslObjectSetParent(object, f);
|
||||
if(f){
|
||||
object->lFrame.prev = &f->objectList.link;
|
||||
object->lFrame.next = f->objectList.link.next;
|
||||
f->objectList.link.next->prev = &object->lFrame;
|
||||
f->objectList.link.next = &object->lFrame;
|
||||
|
||||
rslLinkListAddLLLink(&f->objectList, &object->lFrame);
|
||||
f->root->object.privateFlags |= 1;
|
||||
f->object.privateFlags |= 2;
|
||||
}
|
||||
@ -49,8 +43,7 @@ RslFrameCreate(void)
|
||||
{
|
||||
RslFrame *f = new RslFrame;
|
||||
rslObjectInitialize(&f->object, 0, 0);
|
||||
f->objectList.link.prev = &f->objectList.link;
|
||||
f->objectList.link.next = &f->objectList.link;
|
||||
rslLinkListInitialize(&f->objectList);
|
||||
RslMatrixSetIdentity(&f->modelling);
|
||||
RslMatrixSetIdentity(&f->ltm);
|
||||
f->child = NULL;
|
||||
@ -327,8 +320,7 @@ RslClumpCreate(void)
|
||||
{
|
||||
RslClump *clump = new RslClump;
|
||||
rslObjectInitialize(&clump->object, 2, 0);
|
||||
clump->atomicList.link.prev = &clump->atomicList.link;
|
||||
clump->atomicList.link.next = &clump->atomicList.link;
|
||||
rslLinkListInitialize(&clump->atomicList);
|
||||
return clump;
|
||||
}
|
||||
|
||||
@ -373,10 +365,7 @@ RslClumpStreamRead(Stream *stream)
|
||||
RslClump*
|
||||
RslClumpAddAtomic(RslClump *clump, RslAtomic *a)
|
||||
{
|
||||
a->inClumpLink.prev = &clump->atomicList.link;
|
||||
a->inClumpLink.next = clump->atomicList.link.next;
|
||||
clump->atomicList.link.next->prev = &a->inClumpLink;
|
||||
clump->atomicList.link.next = &a->inClumpLink;
|
||||
rslLinkListAddLLLink(&clump->atomicList, &a->inClumpLink);
|
||||
a->clump = clump;
|
||||
return clump;
|
||||
}
|
||||
@ -387,7 +376,7 @@ RslClumpForAllAtomics(RslClump *clump, RslAtomicCallBack callback, void *pData)
|
||||
RslAtomic *a;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&clump->atomicList.link);
|
||||
link != &clump->atomicList.link;
|
||||
link != rslLinkListGetTerminator(&clump->atomicList);
|
||||
link = link->next){
|
||||
a = rslLLLinkGetData(link, RslAtomic, inClumpLink);
|
||||
if(callback(a, pData) == NULL)
|
||||
@ -402,7 +391,7 @@ RslClumpGetNumAtomics(RslClump *clump)
|
||||
int32 n = 0;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&clump->atomicList.link);
|
||||
link != &clump->atomicList.link;
|
||||
link != rslLinkListGetTerminator(&clump->atomicList);
|
||||
link = link->next)
|
||||
n++;
|
||||
return n;
|
||||
@ -561,23 +550,17 @@ RslTexDictionaryCreate(void)
|
||||
RslTexDictionary *dict = new RslTexDictionary;
|
||||
memset(dict, 0, sizeof(RslTexDictionary));
|
||||
rslObjectInitialize(&dict->object, 6, 0);
|
||||
dict->texturesInDict.link.prev = &dict->texturesInDict.link;
|
||||
dict->texturesInDict.link.next = &dict->texturesInDict.link;
|
||||
rslLinkListInitialize(&dict->texturesInDict);
|
||||
return dict;
|
||||
}
|
||||
|
||||
RslTexture*
|
||||
RslTexDictionaryAddTexture(RslTexDictionary *dict, RslTexture *tex)
|
||||
{
|
||||
if(tex->dict){
|
||||
tex->lInDictionary.prev->next = tex->lInDictionary.next;
|
||||
tex->lInDictionary.next->prev = tex->lInDictionary.prev;
|
||||
}
|
||||
if(tex->dict)
|
||||
rslLinkListRemoveLLLink(&tex->lInDictionary);
|
||||
tex->dict = dict;
|
||||
tex->lInDictionary.prev = &dict->texturesInDict.link;
|
||||
tex->lInDictionary.next = dict->texturesInDict.link.next;
|
||||
dict->texturesInDict.link.next->prev = &tex->lInDictionary;
|
||||
dict->texturesInDict.link.next = &tex->lInDictionary;
|
||||
rslLinkListAddLLLink(&dict->texturesInDict, &tex->lInDictionary);
|
||||
return tex;
|
||||
}
|
||||
|
||||
@ -587,7 +570,7 @@ RslTexDictionaryForAllTextures(RslTexDictionary *dict, RslTextureCallBack fpCall
|
||||
RslTexture *t;
|
||||
RslLLLink *link;
|
||||
for(link = rslLLLinkGetNext(&dict->texturesInDict.link);
|
||||
link != &dict->texturesInDict.link;
|
||||
link != rslLinkListGetTerminator(&dict->texturesInDict);
|
||||
link = link->next){
|
||||
t = rslLLLinkGetData(link, RslTexture, lInDictionary);
|
||||
if(fpCallBack(t, pData) == NULL)
|
||||
|
@ -75,26 +75,43 @@ struct RslLLLink
|
||||
RslLLLink *prev;
|
||||
};
|
||||
|
||||
#define rslLLLinkGetData(linkvar,type,entry) \
|
||||
((type*)(((uint8*)(linkvar))-offsetof(type,entry)))
|
||||
#define rslLLLinkGetNext(linkvar) \
|
||||
((linkvar)->next)
|
||||
#define rslLLLinkGetPrevious(linkvar) \
|
||||
((linkvar)->prev)
|
||||
#define rslLLLinkInitialize(linkvar) \
|
||||
((linkvar)->prev = (RslLLLink*)NULL, \
|
||||
(linkvar)->next = (RslLLLink*)NULL)
|
||||
#define rslLLLinkAttached(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
struct RslLinkList
|
||||
{
|
||||
RslLLLink link;
|
||||
};
|
||||
|
||||
#define rslLLLinkGetData(linkvar,type,entry) \
|
||||
((type *)(((uint8 *)(linkvar))-offsetof(type,entry)))
|
||||
#define rslLinkListInitialize(list) \
|
||||
((list)->link.next = ((RslLLLink*)(list)), \
|
||||
(list)->link.prev = ((RslLLLink*)(list)))
|
||||
#define rslLinkListEmpty(list) \
|
||||
(((list)->link.next) == (&(list)->link))
|
||||
#define rslLinkListAddLLLink(list, linkvar) \
|
||||
((linkvar)->next = (list)->link.next, \
|
||||
(linkvar)->prev = (&(list)->link), \
|
||||
((list)->link.next)->prev = (linkvar), \
|
||||
(list)->link.next = (linkvar) )
|
||||
#define rslLinkListRemoveLLLink(linkvar) \
|
||||
(((linkvar)->prev)->next = (linkvar)->next, \
|
||||
((linkvar)->next)->prev = (linkvar)->prev)
|
||||
#define rslLinkListGetFirstLLLink(list) \
|
||||
((list)->link.next)
|
||||
#define rslLinkListGetLastLLLink(list) \
|
||||
((list)->link.prev)
|
||||
#define rslLinkListGetTerminator(list) \
|
||||
(&((list)->link))
|
||||
|
||||
#define rslLLLinkGetNext(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
#define rslLLLinkGetPrevious(linkvar) \
|
||||
((linkvar)->prev)
|
||||
|
||||
#define rslLLLinkInitialize(linkvar) \
|
||||
( (linkvar)->prev = (RslLLLink *)NULL, \
|
||||
(linkvar)->next = (RslLLLink *)NULL )
|
||||
|
||||
#define rslLLLinkAttached(linkvar) \
|
||||
((linkvar)->next)
|
||||
|
||||
struct RslObject {
|
||||
uint8 type;
|
||||
|
@ -407,7 +407,7 @@ convertClump(RslClump *c)
|
||||
if(parent >= 0)
|
||||
rwframes[parent]->addChild(rwf);
|
||||
}
|
||||
rwc->parent = rwframes[0];
|
||||
rwc->object.parent = rwframes[0];
|
||||
|
||||
rwc->numAtomics = RslClumpGetNumAtomics(c);
|
||||
rwc->atomicList = new Atomic*[rwc->numAtomics];
|
||||
@ -418,7 +418,7 @@ convertClump(RslClump *c)
|
||||
rwa = convertAtomic(alist[i]);
|
||||
rwc->atomicList[i] = rwa;
|
||||
int32 fi = findPointer(alist[i]->object.object.parent, (void**)frameList.frames, frameList.numFrames);
|
||||
rwa->frame = rwframes[fi];
|
||||
rwa->object.parent = rwframes[fi];
|
||||
rwa->clump = rwc;
|
||||
}
|
||||
|
||||
@ -823,14 +823,14 @@ main(int argc, char *argv[])
|
||||
rslstr->relocate();
|
||||
|
||||
bool32 largefile;
|
||||
largefile = rslstr->dataSize > 0x100000;
|
||||
largefile = rslstr->dataSize > 0x1000000;
|
||||
|
||||
if(rslstr->ident == WRLD_IDENT && largefile){ // hack
|
||||
world = (World*)rslstr->data;
|
||||
|
||||
int len = strlen(argv[1])+1;
|
||||
int len = strlen(argv[0])+1;
|
||||
char filename[1024];
|
||||
strncpy(filename, argv[1], len);
|
||||
strncpy(filename, argv[0], len);
|
||||
filename[len-3] = 'i';
|
||||
filename[len-2] = 'm';
|
||||
filename[len-1] = 'g';
|
||||
@ -874,16 +874,21 @@ main(int argc, char *argv[])
|
||||
stream.close();
|
||||
}else if(rslstr->ident == WRLD_IDENT){ // sector
|
||||
sector = (Sector*)rslstr->data;
|
||||
printf("resources\n");
|
||||
for(uint32 i = 0; i < sector->numResources; i++){
|
||||
OverlayResource *r = §or->resources[i];
|
||||
printf(" %d %p\n", r->id, r->raw);
|
||||
}
|
||||
printf("placement\n");
|
||||
fprintf(stderr, "%d\n",sector->unk1);
|
||||
//printf("resources\n");
|
||||
//for(uint32 i = 0; i < sector->numResources; i++){
|
||||
// OverlayResource *r = §or->resources[i];
|
||||
// printf(" %d %p\n", r->id, r->raw);
|
||||
//}
|
||||
//printf("placement\n");
|
||||
if(sector->unk1 == 0)
|
||||
return 0;
|
||||
Placement *p;
|
||||
for(p = sector->sectionA; p < sector->sectionEnd; p++){
|
||||
printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
}
|
||||
//for(p = sector->sectionA; p < sector->sectionEnd; p++){
|
||||
// printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
//}
|
||||
for(p = sector->sectionA; p < sector->sectionEnd; p++)
|
||||
printf("%f %f %f\n", p->matrix[12], p->matrix[13], p->matrix[14]);
|
||||
}else if(rslstr->ident == MDL_IDENT){
|
||||
uint8 *p;
|
||||
p = *rslstr->hashTab;
|
||||
|
Reference in New Issue
Block a user