Fixed some of the data container functions

This commit is contained in:
theclub654 2024-01-28 11:56:25 -05:00
parent 9e85b9e48a
commit c72522d00b
59 changed files with 8299 additions and 6120 deletions

View File

@ -1,5 +1,8 @@
#include "alo.h"
std::vector <GEOM*> allcollisionModels;
extern std::vector<ALO*> allSWAloObjs;
DLI* s_pdliFirst = nullptr;
void* NewAlo()
{
@ -8,42 +11,51 @@ void* NewAlo()
void InitAlo(ALO* palo)
{
//void* test = &palo->dleOid;
InitDl(&palo->dlChild, offsetof(LO, dleChild));
InitDl(&palo->dlFreeze, offsetof(ALO, dleFreeze));
InitDl(&palo->dlChild, 0x38);
InitDl(&palo->dlFreeze, 0xD0);
void* temp = &palo->xf.posWorld;
InitLo(palo);
palo->sCelBorderMRD = 2139095039;
palo->sMRD = 2139095039;
palo->grfzon = -1;
palo->xf.mat = glm::identity<glm::mat3>();
palo->xf.matWorld = glm::identity<glm::mat3>();
palo->matOrig = glm::identity<glm::mat3>();
InitDl(&palo->dlAct, 0x230);
allSWAloObjs.push_back(palo);
}
void RemoveAloHierarchy(ALO *palo)
{
DLI plo;
DLI dliChild{};
// Loading objects child
plo.m_pdl = &palo->dlChild;
// Loading object's chile base offset to object child entry
plo.m_ibDle = palo->dlChild.ibDle;
dliChild.m_pdl = &palo->dlChild;
plo.m_pdliNext = s_pdliFirst;
dliChild.m_ibDle = palo->dlChild.ibDle;
// Storing parent object in global parent list
s_pdliFirst = &plo;
plo.m_ppv = (void**)plo.m_pdl;
dliChild.m_pdliNext = s_pdliFirst;
// Loading object header from object
LO *LocalObject = (LO*)palo;
s_pdliFirst = &dliChild;
dliChild.m_ppv = (void**)(uintptr_t)dliChild.m_pdl;
while (true)
{
palo->pvtlo->pfnOnLoRemove(palo);
break;
// Loading next object
void* nextParentObject = *dliChild.m_ppv;
dliChild.m_ppv = (void**)((uintptr_t)nextParentObject + dliChild.m_ibDle);
// If parent doesnt have a child break
if (nextParentObject == nullptr) break;
}
s_pdliFirst = dliChild.m_pdliNext;
}
void OnAloAdd(ALO* palo)
@ -125,7 +137,7 @@ void CloneAloHierarchy(ALO* palo, ALO* paloBase)
s_pdliFirst = &parentPalo;
// Storing ptr to next ALO to clone
parentPalo.m_ppv = (void**)parentPalo.m_pdl;
parentPalo.m_ppv = (void**)(uintptr_t)parentPalo.m_pdl;
// Clones paloBase to palo
palo->pvtlo->pfnCloneLo(palo, paloBase);
@ -133,13 +145,15 @@ void CloneAloHierarchy(ALO* palo, ALO* paloBase)
// Loading next ALO to clone
LO* plo = (LO*)*parentPalo.m_ppv;
// Loading up next ALO to clone after than one above
parentPalo.m_ppv = (void**) ((uint64_t)&plo->pvtlo + parentPalo.m_ibDle);
parentPalo.m_ppv = (void**) ((uintptr_t)plo + parentPalo.m_ibDle);
while (plo != nullptr)
{
// Clones ALO object
PloCloneLo(plo, palo->psw, palo);
// Loads next ALO object to clone
plo = (LO*)*parentPalo.m_ppv;
// Loads next ALO object to clone after this one
parentPalo.m_ppv = (void**) ((uintptr_t)plo + parentPalo.m_ibDle);
}
@ -163,9 +177,27 @@ void ResolveAlo(ALO* palo)
palo->paloRoot->cframeStatic = 0;
}
void SetAloParent(ALO* palo, ALO* paloParent)
{
if (palo->paloParent == paloParent)
return;
glm::vec3 posWorld = palo->xf.posWorld;
glm::mat3 matWorld = palo->xf.matWorld;
palo->pvtalo->pfnRemoveLo(palo);
ConvertAloPos(nullptr, paloParent, posWorld, palo->xf.pos);
ConvertAloMat(nullptr, paloParent, matWorld, palo->xf.mat);
palo->paloParent = paloParent;
palo->pvtlo->pfnAddLo(palo);
}
void ApplyAloProxy(ALO* palo, PROXY* pproxyApply)
{
glm::vec3 posWorld;
glm::vec3 posWorld{};
ConvertAloPos((ALO*)pproxyApply, nullptr, palo->xf.pos, posWorld);
palo->pvtalo->pfnTranslateAloToPos(palo, posWorld);
@ -184,13 +216,83 @@ void UpdateAloXfWorld(ALO* palo)
void UpdateAloXfWorldHierarchy(ALO* palo)
{
palo->xf.posWorld = palo->xf.pos;
palo->xf.matWorld = palo->xf.mat;
if (palo->palox == nullptr)
{
UpdateTrans:
if (palo->paloParent == nullptr)
{
palo->xf.posWorld = palo->xf.pos;
palo->xf.matWorld = palo->xf.mat;
}
else
{
palo->xf.pos = palo->paloParent->xf.matWorld * palo->xf.pos;
palo->xf.posWorld = palo->paloParent->xf.posWorld + palo->xf.pos;
palo->xf.mat = palo->xf.mat * palo->paloParent->xf.matWorld;
palo->xf.matWorld = palo->xf.mat;
}
}
else
{
if ((palo->palox->grfalox & 0xCU) == 0)
{
palo->paloParent = palo->paloParent;
goto UpdateTrans;
}
if (palo->paloParent == nullptr)
{
palo->xf.posWorld = palo->xf.pos;
}
else
{
palo->xf.pos = palo->xf.pos * palo->paloParent->xf.matWorld;
palo->xf.posWorld = palo->xf.pos + palo->paloParent->xf.posWorld;
}
if (palo->paloParent != nullptr)
{
palo->xf.matWorld = palo->xf.mat * palo->paloParent->xf.matWorld;
goto UpdateTrans;
}
palo->xf.matWorld = palo->xf.mat;
}
ALO* object = palo->dlChild.paloFirst;
if (object == nullptr)
{
palo->palox = palo->palox;
}
else
{
while (true)
{
if (object->pvtalo->pfnUpdateAloXfWorldHierarchy == nullptr)
object = object->dleChild.paloNext;
else
{
object->pvtalo->pfnUpdateAloXfWorldHierarchy(object);
object = object->dleChild.paloNext;
}
if (object == nullptr)
break;
}
}
}
void TranslateAloToPos(ALO* palo, glm::vec3 &ppos)
{
palo->xf.pos = ppos;
palo->pvtalo->pfnUpdateAloXfWorld(palo);
}
@ -200,12 +302,16 @@ void ConvertAloPos(ALO* paloFrom, ALO* paloTo, glm::vec3 &pposFrom, glm::vec3 &p
{
if (paloFrom != nullptr)
{
pposFrom = paloFrom->xf.posWorld;
pposFrom = pposFrom * paloFrom->xf.matWorld;
pposFrom = pposFrom + paloFrom->xf.posWorld;
}
if (paloTo != nullptr)
{
pposTo = paloTo->xf.posWorld;
pposFrom = pposFrom - paloTo->xf.posWorld;
pposFrom = pposFrom * paloTo->xf.matWorld;
pposTo = pposFrom;
return;
}
}
@ -225,12 +331,13 @@ void ConvertAloMat(ALO* paloFrom, ALO* paloTo, glm::mat3 &pmatFrom, glm::mat3 &p
{
if (paloFrom != nullptr)
{
pmatFrom = paloFrom->xf.mat;
pmatFrom = pmatFrom * paloFrom->xf.matWorld;
}
if (paloTo != nullptr)
{
pmatTo = pmatFrom * paloTo->xf.matWorld;
return;
}
}
@ -249,7 +356,7 @@ void AddAloHierarchy(ALO* palo)
s_pdliFirst = &plo;
plo.m_ppv = (void**)plo.m_pdl;
plo.m_ppv = (void**)(uintptr_t)plo.m_pdl;
// Looping through all the child objects
while (true)
@ -286,7 +393,7 @@ void LoadAloFromBrx(ALO* palo, CBinaryInputStream* pbis)
palo->sRadiusRenderAll = pbis->F32Read();
LoadOptionFromBrx(palo, pbis);
LoadGlobsetFromBrx(&palo->globset ,pbis, palo);
LoadAloAloxFromBrx(pbis);
LoadAloAloxFromBrx(palo, pbis);
palo->pvtalo->pfnUpdateAloXfWorld(palo);
@ -305,33 +412,38 @@ void LoadAloFromBrx(ALO* palo, CBinaryInputStream* pbis)
LoadSwObjectsFromBrx(palo->psw, palo, pbis);
}
void LoadAloAloxFromBrx(CBinaryInputStream* pbis)
void LoadAloAloxFromBrx(ALO* palo, CBinaryInputStream* pbis)
{
uint32_t unk_0 = pbis->U32Read();
uint32_t grfalox = pbis->U32Read();
if (unk_0 != 0)
if (grfalox != 0)
{
ALOX alox;
palo->palox = &alox;
palo->palox->grfalox = grfalox;
int unk_1;
if (unk_0 & 1)
if (grfalox & 1)
{
pbis->ReadMatrix();
}
if (unk_0 & 2)
if (grfalox & 2)
{
pbis->ReadMatrix();
}
if (((unk_0 & 0xc) != 0) && (unk_1 = pbis->S16Read() != -1))
if (((grfalox & 0xc) != 0) && (unk_1 = pbis->S16Read() != -1))
{
}
if ((unk_0 & 0x10) != 0)
if ((grfalox & 0x10) != 0)
unk_1 = pbis->S16Read();
if ((unk_0 & 0x20) != 0)
if ((grfalox & 0x20) != 0)
{
unk_1 = pbis->S16Read();
pbis->ReadVector(); // Read Vector
@ -339,18 +451,18 @@ void LoadAloAloxFromBrx(CBinaryInputStream* pbis)
pbis->F32Read();
}
if ((unk_0 & 0x40) != 0)
if ((grfalox & 0x40) != 0)
{
unk_1 = pbis->S16Read();
unk_1 = pbis->S16Read();
}
if ((unk_0 & 0x80) != 0)
if ((grfalox & 0x80) != 0)
{
pbis->ReadVector();
pbis->F32Read();
if ((unk_0 & 0x100) != 0)
if ((grfalox & 0x100) != 0)
{
pbis->S16Read();
pbis->S16Read();
@ -360,13 +472,13 @@ void LoadAloAloxFromBrx(CBinaryInputStream* pbis)
}
}
if ((unk_0 & 0x200) != 0)
if ((grfalox & 0x200) != 0)
{
pbis->S16Read();
pbis->S16Read();
}
if ((unk_0 & 0x400) != 0)
if ((grfalox & 0x400) != 0)
{
pbis->U8Read();
}

View File

@ -15,17 +15,20 @@ struct XF
glm::vec3 dv;
glm::vec3 dw;
};
struct RO
{
glm::mat4 mat;
float uAlpha;
float uAlphaCelBorder;
};
struct POSEC
{
OID oid;
std::vector <float> agPoses;
};
struct RSMG
{
OID oidRoot;
@ -33,6 +36,7 @@ struct RSMG
OID oidTriggerGoal;
OID oidUntriggerGoal;
};
enum ACK
{
ACK_Nil = -1,
@ -49,6 +53,11 @@ enum ACK
ACK_Max = 10
};
struct ALOX
{
int grfalox;
};
class ALO : public LO
{
public:
@ -109,12 +118,12 @@ class ALO : public LO
};
// Create ALO
void* NewAlo();
void*NewAlo();
// Initialize ALO object
void InitAlo(ALO* palo); // NOT FINISHED
// Adds ALO parent and all the alo childs into the world
void AddAloHierarchy(ALO *palo);
void RemoveAloHierarchy(ALO *palo); // NOT FINISHED
void RemoveAloHierarchy(ALO *palo);
// Adds ALO to Hierarchy
void OnAloAdd(ALO* palo); // NOT FINISHED
// Removes ALO from Hierarchy
@ -124,10 +133,12 @@ void CloneAloHierarchy(ALO* palo, ALO* paloBase);
// Makes a copy of ALO
void CloneAlo(ALO* palo, ALO* paloBase);
void ResolveAlo(ALO *palo);
// Sets a Alo object to a parent
void SetAloParent(ALO* palo, ALO* paloParent);
void ApplyAloProxy(ALO* palo, PROXY* pproxyApply);
// Updates the ALO objects world coordinates
// Updates the ALO objects transformations
void UpdateAloXfWorld(ALO* palo);
// Updates the ALO objects world coordinate hierarchy
// Updates the ALO objects world transformation hierarchy
void UpdateAloXfWorldHierarchy(ALO* palo);
void TranslateAloToPos(ALO* palo, glm::vec3& ppos);
void ConvertAloPos(ALO* paloFrom, ALO* paloTo, glm::vec3 &pposFrom, glm::vec3 &pposTo);
@ -136,7 +147,7 @@ void ConvertAloMat(ALO* paloFrom, ALO* paloTo, glm::mat3 &pmatFrom, glm::mat3 &p
// Loads ALO object from binary file
void LoadAloFromBrx(ALO* palo, CBinaryInputStream* pbis);
// Loads bone data from binary file
void LoadAloAloxFromBrx(CBinaryInputStream* pbis);
void LoadAloAloxFromBrx(ALO* palo, CBinaryInputStream* pbis);
void UpdateAlo(ALO *palo, float dt);
void RenderAloAll(ALO* palo, CM* pcm, RO* proDup);
void RenderAloSelf(ALO* palo, CM* pcm, RO* pro);

11938
Sly1/basic.h

File diff suppressed because it is too large Load Diff

View File

@ -89,6 +89,7 @@ void CloneBreak(BREAK* pbreak, BREAK* pbreakBase)
{
LO lo = *pbreak;
*pbreak = *pbreakBase;
memcpy(pbreak, &lo, sizeof(LO));
CloneLo(pbreak, pbreakBase);

View File

@ -1,7 +1,5 @@
#include "brx.h"
std::vector<void*> allSwLights;
void StartupBrx()
{
BuildEopids();
@ -38,13 +36,10 @@ LO* PloNew(CID cid, SW* psw, ALO* paloParent, OID oid, int isplice)
// Initializing local object
localObject->pvtlo->pfnInitLo(localObject);
// Storing pointer to object in global vector
allWorldObjs.push_back(localObject);
if (cid == CID_LIGHT)
allSwLights.push_back(localObject);
// Returining newly made objects
return (LO*)localObject;
}

View File

@ -46,6 +46,12 @@ void OnCrfodAdd(CRFOD* pcrfod)
AppendDlEntry(&pcrfod->psw->dlCrfod, pcrfod);
}
void OnCrfodRemove(CRFOD* pcrfod)
{
OnStepguardRemove(pcrfod);
RemoveDlEntry(&pcrfod->psw->dlCrfod, pcrfod);
}
void CloneCrfod(CRFOD* pcrfod, CRFOD* pcrfodBase)
{
LO lo = *pcrfod;
@ -128,4 +134,4 @@ void CloneCrbrain(CRBRAIN* pcrbrain, CRBRAIN* pcrbrainBase)
void DeleteCrbrain(LO* plo)
{
delete(CRBRAIN*)plo;
}
}

View File

@ -4,6 +4,7 @@
class CRFOD : public STEPGUARD
{
public:
DLE dleCrfod;
};
class CRFODB :public CRFOD
@ -34,6 +35,7 @@ void DeleteCrfodb(LO* plo);
void*NewCrfod();
void OnCrfodAdd(CRFOD* pcrfod);
void OnCrfodRemove(CRFOD* pcrfod);
void CloneCrfod(CRFOD* pcrfod, CRFOD* pcrfodBase);
int GetCrfodSize();
void DeleteCrfod(LO* plo);

View File

@ -20,6 +20,12 @@ void OnDartAdd(DART* pdart)
OnSoAdd(pdart);
}
void RemoveDart(DART* pdart)
{
RemoveLo(pdart);
AppendDlEntry(&pdart->psw->dlDartFree, pdart);
}
void CloneDart(DART* pdart, DART* pdartBase)
{
LO lo = *pdart;

View File

@ -37,6 +37,7 @@ void*NewDart();
void InitDart(DART* pdart);
int GetDartSize();
void OnDartAdd(DART* pdart);
void RemoveDart(DART* pdart);
void CloneDart(DART* pdart, DART* pdartBase);
void LoadDartFromBrx(DART* pdart, CBinaryInputStream* pbis);
void DeleteDart(LO* plo);

View File

@ -48,6 +48,7 @@ void UpdateAloXfWorld(ALO* palo);
void UpdateAloXfWorldHierarchy(ALO* palo);
void TranslateAloToPos(ALO* palo, glm::vec3& ppos);
void RotateAloToMat(ALO* palo, glm::mat3& pmat);
void SetAloParent(ALO* palo, ALO* paloParent);
void ApplyAloProxy(ALO* palo, PROXY* pproxyApply);
void LoadAloFromBrx(ALO* palo, CBinaryInputStream* pbis);
void UpdateAlo(ALO* palo, float dt);
@ -63,7 +64,9 @@ struct SOP;
void*NewSo();
void InitSo(SO* pso);
void OnSoAdd(SO* pso);
void OnSoRemove(SO* pso);
void CloneSo(SO* pso, SO* psoBase);
void SetSoParent(SO* pso, ALO* paloParent);
void ApplySoProxy(SO* pso, PROXY* pproxyApply);
void UpdateSoXfWorldHierarchy(SO* pso);
void UpdateSoXfWorld(SO* pso);
@ -86,6 +89,7 @@ class PO;
void*NewPo();
void InitPo(PO* ppo);
void OnPoAdd(PO* ppo);
void OnPoRemove(PO* ppo);
void ClonePo(PO* ppo, PO* ppoBase);
int GetPoSize();
void DeletePo(LO* plo);
@ -116,6 +120,7 @@ class STEPGUARD;
void*NewStepguard();
void InitStepGuard(STEPGUARD *pstepguard);
void OnStepguardAdd(STEPGUARD* pstepguard);
void OnStepguardRemove(STEPGUARD* pstepguard);
void CloneStepguard(STEPGUARD* pstepguard, STEPGUARD* pstepguardBase);
void LoadStepGuardFromBrx(STEPGUARD *pstepguard, CBinaryInputStream* pbis);
void RenderStepguardSelf(STEPGUARD* pstepguard, CM* pcm, RO* pro);
@ -173,6 +178,7 @@ void DeletePuffc(LO* plo);
class CRFOD;
void*NewCrfod();
void OnCrfodAdd(CRFOD* pcrfod);
void OnCrfodRemove(CRFOD* pcrfod);
void CloneCrfod(CRFOD* pcrfod, CRFOD* pcrfodBase);
int GetCrfodSize();
void DeleteCrfod(LO* plo);
@ -509,6 +515,7 @@ class HBSK;
void*NewHbsk();
void InitHbsk(HBSK* phbsk);
void OnHbskAdd(HBSK* phbsk);
void OnHbskRemove(HBSK* phbsk);
int GetHbskSize();
void CloneHbsk(HBSK* phbsk, HBSK* phbskBase);
void LoadHbskFromBrx(HBSK* phbsk, CBinaryInputStream* pbis);
@ -527,6 +534,7 @@ class MISSILE;
void*NewMissile();
void InitMissile(MISSILE* pmissile);
int GetMissileSize();
void OnMissileRemove(MISSILE* pmissile);
void LoadMissileFromBrx(MISSILE* pmissile, CBinaryInputStream* pbis);
void CloneMissile(MISSILE* pmissile, MISSILE* pmissileBase);
void RenderMissileAll(MISSILE* pmissile, CM* pcm, RO* pro);
@ -572,6 +580,7 @@ void*NewRat();
void InitRat(RAT* prat);
int GetRatSize();
void OnRatAdd(RAT* prat);
void OnRatRemove(RAT* prat);
void CloneRat(RAT* prat, RAT* pratBase);
void LoadRatFromBrx(RAT* prat, CBinaryInputStream* pbis);
void RenderRatAll(RAT* prat, CM* pcm, RO* pro);
@ -614,6 +623,7 @@ void*NewDart();
void InitDart(DART* pdart);
int GetDartSize();
void OnDartAdd(DART* pdart);
void RemoveDart(DART* pdart);
void CloneDart(DART* pdart, DART* pdartBase);
void LoadDartFromBrx(DART* pdart, CBinaryInputStream* pbis);
void DeleteDart(LO* plo);
@ -704,6 +714,7 @@ void*NewLight();
void InitLight(LIGHT* plight);
int GetLightSize();
void OnLightAdd(LIGHT* plight);
void OnLightRemove(LIGHT* plight);
void UpdateLightXfWorldHierarchy(LIGHT* plight);
void CloneLight(LIGHT* plight, LIGHT* plightBase);
void DeleteLight(LO* plo);
@ -835,6 +846,7 @@ class TN;
void*NewTn();
void InitTn(TN* ptn);
int GetTnSize();
void OnTnRemove(TN* ptn);
void LoadTnFromBrx(TN* ptn, CBinaryInputStream* pbis);
void CloneTn(TN* ptn, TN* ptnBase);
void LoadTbspFromBrx(CBinaryInputStream* pbis);
@ -943,6 +955,7 @@ void*NewShape();
void InitShape(SHAPE* pshape);
int GetShapeSize();
void CloneShape(SHAPE* pshape, SHAPE* pshapeBase);
void SetShapeParent(SHAPE* pshape, ALO* paloParent);
void LoadShapeFromBrx(SHAPE* pshape, CBinaryInputStream* pbis);
void DeleteShape(LO* plo);
@ -951,6 +964,7 @@ void*NewHshape();
void InitHshape(HSHAPE* phshape);
int GetHshapeSize();
void OnHshapeAdd(HSHAPE* phshape);
void OnHshapeRemove(HSHAPE* phshape);
void CloneHshape(HSHAPE* phshape, HSHAPE* phshapeBase);
void DeleteHshape(LO* plo);
@ -959,14 +973,15 @@ void*NewPipe();
void InitPipe(PIPE* ppipe);
int GetPipeSize();
void OnPipeAdd(PIPE* ppipe);
void ClonePipe(PIPE* ppipe, PIPE* ppipeBase);
void OnPipeRemove(PIPE* ppipe);
void ClonePipe(PIPE* ppipe, PIPE* ppipeBase);
void DeletePipe(LO* plo);
class RAIL;
void*NewRail();
int GetRailSize();
void OnRailAdd(RAIL* prail);
void OnRailRemove(RAIL* prail);
void CloneRail(RAIL* prail, RAIL* prailBase);
void DeleteRail(LO* plo);
@ -974,6 +989,7 @@ class LANDING;
void*NewLanding();
int GetLandingSize();
void OnLandingAdd(LANDING* planding);
void OnLandingRemove(LANDING* planding);
void CloneLanding(LANDING* planding, LANDING* plandingBase);
void DeleteLanding(LO* plo);
@ -983,6 +999,7 @@ void InitXfm(XFM* pxfm);
int GetXfmSize();
void CloneXfm(XFM* pxfm, XFM* pxfmBase);
void LoadXfmFromBrx(XFM* pxfm, CBinaryInputStream* pbis);
void SetXfmParent(XFM* pxfm, ALO* paloParent);
void ApplyXfmProxy(XFM* pxfm, PROXY* pproxyApply);
void DeleteXfm(LO* plo);
@ -998,6 +1015,7 @@ void*NewTarget();
void InitTarget(TARGET* ptarget);
int GetTargetSize();
void OnTargetAdd(TARGET* ptarget);
void OnTargetRemove(TARGET* ptarget);
void CloneTarget(TARGET* ptarget, TARGET* ptargetBase);
void DeleteTarget(LO* plo);
@ -1048,6 +1066,7 @@ class RATHOLE;
void*NewRathole();
int GetRatholeSize();
void OnRatholeAdd(RATHOLE* prathole);
void OnRatholeRemove(RATHOLE* prathole);
void CloneRathole(RATHOLE* prathole, RATHOLE* pratholeBase);
void DeleteRathole(LO* plo);
@ -1070,6 +1089,7 @@ void*NewPnt();
int GetPntSize();
void LoadPntFromBrx(PNT* pnt, CBinaryInputStream* pbis);
void ClonePnt(PNT* pnt, PNT* pntBase);
void SetPntParent(PNT* ppnt, ALO* paloParent);
void ApplyPntProxy(PNT* ppnt, PROXY* pproxyApply);
void DeletePnt(LO* plo);
@ -1078,6 +1098,7 @@ void*NewHpnt();
void InitHpnt(HPNT* phpnt);
int GetHpntSize();
void OnHpntAdd(HPNT* phpnt);
void OnHpntRemove(HPNT* phpnt);
void CloneHpnt(HPNT* phpnt, HPNT* phpntBase);
void DeleteHpnt(LO* plo);
@ -1085,6 +1106,7 @@ class JMT;
void*NewJmt();
int GetJmtSize();
void OnJmtAdd(JMT* pjmt);
void OnJmtRemove(JMT* pjmt);
void CloneJmt(JMT* pjmt, JMT* pjmtBase);
void DeleteJmt(LO* plo);
@ -1092,6 +1114,7 @@ class SPIRE;
void*NewSpire();
int GetSpireSize();
void OnSpireAdd(SPIRE* pspire);
void OnSpireRemove(SPIRE* pspire);
void CloneSpire(SPIRE* pspire, SPIRE* pspireBase);
void DeleteSpire(LO* plo);
@ -1152,6 +1175,7 @@ class PATHZONE;
void*NewPathzone();
int GetPathzoneSize();
void OnPathzoneAdd(PATHZONE* ppathzone);
void OnPathzoneRemove(PATHZONE* ppathzone);
void ClonePathzone(PATHZONE* ppathzone, PATHZONE* ppathzoneBase);
void LoadPathZoneFromBrx(PATHZONE* ppathzone, CBinaryInputStream* pbis);
void DeletePathzone(LO* plo);

View File

@ -2,33 +2,33 @@
void InitDl(DL *pdl, int ibDle)
{
// Setting base offset to data entry linked list
// Setting base offset to data entry
pdl->ibDle = ibDle;
}
void ClearDl(DL *pdl)
{
// Nulling DL
pdl->pvFirst = (void*)0x0;
pdl->pvLast = (void*)0x0;
pdl->pvFirst = nullptr;
pdl->pvLast = nullptr;
}
void ClearDle(DLE *pdle)
{
// Nulling entry list
pdle->pvNext = (void*)0x0;
pdle->pvPrev = (void*)0x0;
pdle->pvNext = nullptr;
pdle->pvPrev = nullptr;
}
DLE* PdleFromDlEntry(DL *pdl, void *pv)
{
// Returning the offset to entry
// Returning the offset to entry list
return (DLE*)((uintptr_t)pv + pdl->ibDle);
}
void AppendDlEntry(DL *pdl, void *pv)
{
// Loading entry from DL
// Loading entry from data list
DLE *entry0 = PdleFromDlEntry(pdl, pv);
// Checking to see if list is empty
@ -38,9 +38,9 @@ void AppendDlEntry(DL *pdl, void *pv)
else
{
// Loading last data's entry from list
// Loading last entry from list
DLE *entry1 = PdleFromDlEntry(pdl, pdl->pvLast);
entry0 = (DLE*)pdl;
entry0->pvPrev = (DLE*)pdl->pvLast;
// Storing the new next data entry in entry list
entry1->pvNext = pv;
}
@ -55,17 +55,17 @@ void PrependDlEntry(DL* pdl, void* pv)
DLE *entry0 = PdleFromDlEntry(pdl, pv);
// Storing data in DL list if DL list is empty
if (pdl->pvFirst == 0)
if (pdl->pvFirst == nullptr)
{
pdl->pvFirst = pv;
pdl->pvLast = pv;
pdl->pvLast = pv;
}
else
{
// Loading first entry linked list from list
DLE* entry1 = PdleFromDlEntry(pdl, pdl->pvFirst);
entry0 = (DLE*)pdl;
entry0->pvNext = (DLE*)pdl->pvFirst;
// Storing data in first DL entry node
entry1->pvPrev = pv;
// Storing data in first DL list since where tryna insert in front
@ -75,19 +75,23 @@ void PrependDlEntry(DL* pdl, void* pv)
void RemoveDlEntry(DL *pdl, void *pv)
{
void* pv_1 = nullptr;
DLE* entry0;
DLE* entry1;
DLI* entry2;
// Holds ptr to previous entry
void* prevEntry{};
// Data entry to be removed
DLE* entry0{};
DLE* entry1{};
DLI* entry2{};
// Loading entry thats being removed
// Loading data's entry thats being removed
entry0 = PdleFromDlEntry(pdl, pv);
if (s_pdliFirst == nullptr)
pv = entry0->pvPrev;
if (s_pdliFirst == (DLI*)nullptr)
// Loads ptr to previous entry data list
prevEntry = entry0->pvPrev;
else
{
// Loads previous entry's data list
entry1 = (DLE*)s_pdliFirst->m_ppv;
entry2 = s_pdliFirst;
@ -95,12 +99,12 @@ void RemoveDlEntry(DL *pdl, void *pv)
{
if (entry1 == entry0)
{
if (entry0->pvPrev == 0x0)
entry2->m_ppv = (void**)pdl;
if (entry0->pvPrev == nullptr)
entry2->m_ppv = (void**)(uintptr_t)pdl;
else
{
entry1 = PdleFromDlEntry(pdl, entry0->pvPrev);
entry2->m_ppv = (void**)entry1;
entry2->m_ppv = (void**)(uintptr_t)entry1;
}
entry2 = entry2->m_pdliNext;
}
@ -108,34 +112,35 @@ void RemoveDlEntry(DL *pdl, void *pv)
else
entry2 = entry2->m_pdliNext;
if (entry2 == 0x0) break;
if (entry2 == nullptr)
break;
entry1 = (DLE*)entry2->m_ppv;
}
pv_1 = entry0->pvPrev;
prevEntry = entry0->pvPrev;
}
if (pv_1 == (void*)0x0)
pdl = (DL*)entry0;
if (prevEntry == nullptr)
pdl->pvFirst = (DL*)entry0->pvNext;
else
{
entry1 = PdleFromDlEntry(pdl, pv_1);
entry1 = entry0;
entry1 = PdleFromDlEntry(pdl, prevEntry);
entry1->pvNext = entry0->pvNext;
}
if (entry0->pvNext == nullptr)
pdl = (DL*)entry0;
pdl->pvLast = (DL*)entry0->pvPrev;
else
{
entry1 = PdleFromDlEntry(pdl, entry0->pvNext);
entry1 = entry0;
entry1->pvPrev = entry0->pvPrev;
}
entry0->pvPrev = 0x0;
entry0->pvNext = 0x0;
entry0->pvPrev = nullptr;
entry0->pvNext = nullptr;
}
int FFindDlEntry(DL *pdl, void *pv)
@ -153,7 +158,7 @@ int FFindDlEntry(DL *pdl, void *pv)
int FIsDlEmpty(DL* pdl)
{
// Seeing if DL list is empty
if (pdl->pvFirst == (void*)0x0)
if (pdl->pvFirst == nullptr)
return 1;
else
return 0;

View File

@ -11,7 +11,7 @@ struct DL
void* pvFirst;
class LO* ploFirst;
class ALO* paloFirst;
class SO* psoFirst;
/*class SO* psoFirst;
class ASEGA* pasegaFirst;
class ACTSEG* pactsegFirst;
class AMB* pambFirst;
@ -53,7 +53,7 @@ struct DL
class JLOVOL* pjlovolFirst;
class EMITTER* pemitterFirst;
class MGCO* pmgcoFirst;
class JMT* pjmtFirst;
class JMT* pjmtFirst;*/
};
union
@ -62,7 +62,7 @@ struct DL
void* pvLast;
class LO* ploLast;
class ALO* paloLast;
class SO* psoLast;
/*class SO* psoLast;
class ASEGA* pasegaLast;
class ACTSEG* pactsegLast;
class AMB* pambLast;
@ -104,7 +104,7 @@ struct DL
class JLOVOL* pjlovolLast;
class EMITTER* pemitterLast;
class MGCO* pmgcoLast;
class JMT* pjmtLast;
class JMT* pjmtLast;*/
};
// Base offset to DL entry (DLE)
@ -123,7 +123,7 @@ struct DLE
void* pvNext;
class LO* ploNext;
class ALO* paloNext;
class SO* psoNext;
/*class SO* psoNext;
class ASEGA* pasegaNext;
class ACTSEG* pactsegNext;
class AMB* pambNext;
@ -165,7 +165,7 @@ struct DLE
class JLOVOL* pjlovolNext;
class EMITTER* pemitterNext;
class MGCO* pmgcoNext;
class JMT* pjmtNext;
class JMT* pjmtNext;*/
};
union
@ -174,7 +174,7 @@ struct DLE
void* pvPrev;
class LO* ploPrev;
class ALO* paloPrev;
class SO* psoPrev;
/*class SO* psoPrev;
class ASEGA* pasegaPrev;
class ACTSEG* pactsegPrev;
class AMB* pambPrev;
@ -216,7 +216,7 @@ struct DLE
class JLOVOL* pjlovolPrev;
class EMITTER* pemitterPrev;
class MGCO* pmgcoPrev;
class JMT* pjmtPrev;
class JMT* pjmtPrev;*/
};
};
@ -224,13 +224,13 @@ struct DLE
struct DLI
{
// List address value
DL *m_pdl;
DL* m_pdl;
// Parent pointer value
void **m_ppv;
void** m_ppv;
// Used for base offset to entry for parent object
uint64_t m_ibDle;
// Pointer to next parent object
DLI *m_pdliNext;
DLI* m_pdliNext;
};
// Initializing list
@ -252,6 +252,4 @@ int FFindDlEntry(DL *pdl, void *pv);
// Returns whether DL list is empty or not
int FIsDlEmpty(DL *pdl);
// Global DLI pointer to a parent object
static DLI* s_pdliFirst{};
extern DLI* s_pdliFirst;

View File

@ -83,6 +83,17 @@ class EXPLO : public EXPL
class EXPLS : public EXPLO
{
public:
struct SFX* psfx;
struct LM lmcParticle;
OID oidRender;
OID oidNextRender;
OID oidTouch;
float dtDelay;
int fGrouped;
struct RIPG* pripg;
struct BLIPG* pblipg;
float tExplodeNext;
int fExplodeSiblings;
};
void*NewExplo();

View File

@ -41,8 +41,8 @@ void LoadGlobsetFromBrx(GLOBSET* pglobset ,CBinaryInputStream* pbis, ALO* palo)
int instanceIndex = pbis->S16Read();
glm::mat4 pdmat = pbis->ReadMatrix4();
//if(instanceIndex != 0)
pglobset->aglob[instanceIndex].pdmat.push_back(pdmat);
if(instanceIndex != 0)
pglobset->aglob[instanceIndex].pdmat.push_back(pdmat);
}
if ((unk_5 & 2) != 0)
@ -254,8 +254,6 @@ void LoadGlobsetFromBrx(GLOBSET* pglobset ,CBinaryInputStream* pbis, ALO* palo)
}
}
}
allSWAloObjs.push_back(palo);
}
void BuildSubGlob(GLOBSET* pglobset, SHD* pshd, std::vector<VERTICE>& vertices, std::vector <glm::vec3>& vertexes, std::vector <glm::vec3>& normals, std::vector <RGBA>& vertexColors, std::vector <glm::vec2>& texcoords, std::vector <VTXFLG>& indexes, std::vector<uint16_t>& indices)

View File

@ -10,5 +10,10 @@ uniform sampler2D Texture;
void main()
{
FragColor = texture(Texture, aTexcoord);
vec4 texColor = texture(Texture, aTexcoord);
if(texColor.a < 0.1)
discard;
FragColor = texColor;
}

View File

@ -20,6 +20,12 @@ void OnHbskAdd(HBSK* phbsk)
OnSoAdd(phbsk);
}
void OnHbskRemove(HBSK* phbsk)
{
OnSoRemove(phbsk);
//RemoveDlEntry(&g_dlHbsk, phbsk);
}
void LoadHbskFromBrx(HBSK* phbsk, CBinaryInputStream* pbis)
{
LoadSoFromBrx(phbsk, pbis);
@ -65,6 +71,12 @@ void OnHshapeAdd(HSHAPE* phshape)
OnLoAdd(phshape);
}
void OnHshapeRemove(HSHAPE* phshape)
{
OnLoRemove(phshape);
//RemoveDlEntry(&g_dlHshape, phshape);
}
void CloneHshape(HSHAPE* phshape, HSHAPE* phshapeBase)
{
LO lo = *phshape;
@ -99,6 +111,12 @@ void OnHpntAdd(HPNT* phpnt)
OnLoAdd(phpnt);
}
void OnHpntRemove(HPNT* phpnt)
{
OnLoRemove(phpnt);
//RemoveDlEntry(&g_dlHpnt, phpnt);
}
void CloneHpnt(HPNT* phpnt, HPNT* phpntBase)
{
LO lo = *phpnt;

View File

@ -63,6 +63,7 @@ void*NewHbsk();
void InitHbsk(HBSK* phbsk);
int GetHbskSize();
void OnHbskAdd(HBSK* phbsk);
void OnHbskRemove(HBSK* phbsk);
void LoadHbskFromBrx(HBSK* phbsk, CBinaryInputStream* pbis);
void CloneHbsk(HBSK* phbsk, HBSK* phbskBase);
void DeleteHbsk(LO* plo);
@ -71,6 +72,7 @@ void*NewHshape();
void InitHshape(HSHAPE* phshape);
int GetHshapeSize();
void OnHshapeAdd(HSHAPE* phshape);
void OnHshapeRemove(HSHAPE* phshape);
void CloneHshape(HSHAPE* phshape, HSHAPE* phshapeBase);
void DeleteHshape(LO* plo);
@ -78,5 +80,6 @@ void*NewHpnt();
void InitHpnt(HPNT* phpnt);
int GetHpntSize();
void OnHpntAdd(HPNT* phpnt);
void OnHpntRemove(HPNT* phpnt);
void CloneHpnt(HPNT* phpnt, HPNT* phpntBase);
void DeleteHpnt(LO* plo);

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,12 @@ void OnJmtAdd(JMT* pjmt)
OnLoAdd(pjmt);
}
void OnJmtRemove(JMT* pjmt)
{
OnLoRemove(pjmt);
//RemoveDlEntry(&g_dlJmt, pjmt);
}
void CloneJmt(JMT* pjmt, JMT* pjmtBase)
{
LO lo = *pjmt;

View File

@ -13,5 +13,6 @@ class JMT : public PNT
void*NewJmt();
int GetJmtSize();
void OnJmtAdd(JMT* pjmt);
void OnJmtRemove(JMT* pjmt);
void CloneJmt(JMT* pjmt, JMT* pjmtBase);
void DeleteJmt(LO* plo);

View File

@ -16,6 +16,12 @@ void OnLandingAdd(LANDING* planding)
AppendDlEntry(&planding->psw->dlLanding, planding);
}
void OnLandingRemove(LANDING* planding)
{
OnLoRemove(planding);
RemoveDlEntry(&planding->psw->dlLanding, planding);
}
void CloneLanding(LANDING* planding, LANDING* plandingBase)
{
LO lo = *planding;
@ -28,4 +34,4 @@ void CloneLanding(LANDING* planding, LANDING* plandingBase)
void DeleteLanding(LO* plo)
{
delete(LANDING*)plo;
}
}

View File

@ -10,5 +10,6 @@ class LANDING : public SHAPE
void*NewLanding();
int GetLandingSize();
void OnLandingAdd(LANDING* planding);
void OnLandingRemove(LANDING* planding);
void CloneLanding(LANDING* planding, LANDING* plandingBase);
void DeleteLanding(LO* plo);

View File

@ -16,6 +16,8 @@ void InitLight(LIGHT* plight)
plight->degHighlight = 180.0;
InitAlo(plight);
allSwLights.push_back(plight);
}
int GetLightSize()
@ -29,6 +31,12 @@ void OnLightAdd(LIGHT* plight)
AddLightToSw(plight);
}
void OnLightRemove(LIGHT* plight)
{
OnAloRemove(plight);
RemoveLightFromSw(plight);
}
void UpdateLightXfWorldHierarchy(LIGHT* plight)
{
UpdateAloXfWorldHierarchy(plight);
@ -60,4 +68,4 @@ void RemoveLightFromSw(LIGHT* plight)
void DeleteLight(LO* plo)
{
delete(LIGHT*)plo;
}
}

View File

@ -48,6 +48,7 @@ void*NewLight();
void InitLight(LIGHT* plight);
int GetLightSize();
void OnLightAdd(LIGHT* plight);
void OnLightRemove(LIGHT* plight);
void UpdateLightXfWorldHierarchy(LIGHT* plight);
void CloneLight(LIGHT* plight, LIGHT* plightBase);
void AddLightToSw(LIGHT* plight);

View File

@ -48,6 +48,7 @@ void AddLoHierarchy(LO *plo)
void RemoveLoHierarchy(LO* plo)
{
plo->pvtlo->pfnOnLoRemove(plo);
SendLoMessage(plo, MSGID_removed, plo);
}
@ -88,17 +89,15 @@ void LoadLoFromBrx(LO* plo, CBinaryInputStream* pbis)
void RemoveLo(LO* plo)
{
// Loading objects parent
ALO* objectParent = plo->paloParent;
// Loading objects parent child list
DL* objectChild = &plo->paloParent->dlChild;
DL* objectChildList = &plo->paloParent->dlChild;
// If object doesnt have a parent load up the static world dlChild
if (objectParent == nullptr)
objectChild = &plo->psw->dlChild;
if (plo->paloParent == nullptr)
objectChildList = &plo->psw->dlChild;
// Returns if parent LO or SW has a child object or not
bool isFound = FFindDlEntry(objectChild, plo);
bool isFound = FFindDlEntry(objectChildList, plo);
if (isFound != 0)
{
@ -106,11 +105,11 @@ void RemoveLo(LO* plo)
isFound = FIsLoInWorld(plo);
if (isFound == 0)
RemoveDlEntry(objectChild, plo);
RemoveDlEntry(objectChildList, plo);
else
{
RemoveDlEntry(objectChild, plo);
RemoveDlEntry(objectChildList, plo);
plo->pvtlo->pfnRemoveLoHierarchy(plo);
}
}
@ -163,7 +162,9 @@ void PostLoLoad(LO* plo)
void SetLoParent(LO *plo, ALO *paloParent)
{
plo->pvtlo->pfnRemoveLo(plo);
plo->paloParent = paloParent;
plo->pvtlo->pfnAddLo(plo);
}
void SubscribeLoObject(LO* plo, LO* ploTarget)

View File

@ -67,6 +67,7 @@ struct PSL
};
// Proxy Root
// Stores all info about the proxy source object.
struct PXR
{
struct LO* plo;

View File

@ -15,6 +15,11 @@ int GetMissileSize()
return sizeof(MISSILE);
}
void OnMissileRemove(MISSILE* pmissile)
{
OnSoRemove(pmissile);
}
void LoadMissileFromBrx(MISSILE* pmissile, CBinaryInputStream* pbis)
{
LoadBombFromBrx(pmissile, pbis);

View File

@ -45,6 +45,7 @@ class GROUNDMISS : public MISSILE
void*NewMissile();
void InitMissile(MISSILE* pmissile);
int GetMissileSize();
void OnMissileRemove(MISSILE* pmissile);
void LoadMissileFromBrx(MISSILE* pmissile, CBinaryInputStream* pbis);
void CloneMissile(MISSILE* pmissile, MISSILE* pmissileBase);
void RenderMissileAll(MISSILE* pmissile, CM* pcm, RO* pro);

View File

@ -16,6 +16,12 @@ void OnPathzoneAdd(PATHZONE* ppathzone)
AppendDlEntry(&ppathzone->psw->dlPathzone, ppathzone);
}
void OnPathzoneRemove(PATHZONE* ppathzone)
{
OnLoRemove(ppathzone);
RemoveDlEntry(&ppathzone->psw->dlPathzone, ppathzone);
}
void LoadPathZoneFromBrx(PATHZONE* ppathzone, CBinaryInputStream* pbis)
{
LoadLoFromBrx(ppathzone, pbis);

View File

@ -24,6 +24,7 @@ class PATHZONE : public LO
void*NewPathzone();
int GetPathzoneSize();
void OnPathzoneAdd(PATHZONE* ppathzone);
void OnPathzoneRemove(PATHZONE* ppathzone);
void LoadPathZoneFromBrx(PATHZONE* ppathzone, CBinaryInputStream* pbis);
void ClonePathzone(PATHZONE* ppathzone, PATHZONE* ppathzoneBase);
void DeletePathzone(LO* plo);

View File

@ -20,6 +20,12 @@ void OnPipeAdd(PIPE* ppipe)
OnLoAdd(ppipe);
}
void OnPipeRemove(PIPE* ppipe)
{
OnLoRemove(ppipe);
//RemoveDlEntry(&g_dlPipe, ppipe);
}
void ClonePipe(PIPE* ppipe, PIPE* ppipeBase)
{
LO lo = *ppipe;
@ -29,11 +35,6 @@ void ClonePipe(PIPE* ppipe, PIPE* ppipeBase)
CloneLo(ppipe, ppipeBase);
}
void OnPipeRemove(PIPE* ppipe)
{
OnLoRemove(ppipe);
}
void DeletePipe(LO* plo)
{
delete(PIPE*)plo;

View File

@ -17,6 +17,6 @@ void*NewPipe();
void InitPipe(PIPE* ppipe);
int GetPipeSize();
void OnPipeAdd(PIPE* ppipe);
void ClonePipe(PIPE* ppipe, PIPE* ppipeBase);
void OnPipeRemove(PIPE* ppipe);
void ClonePipe(PIPE* ppipe, PIPE* ppipeBase);
void DeletePipe(LO* plo);

View File

@ -25,6 +25,12 @@ void ClonePnt(PNT* pnt, PNT* pntBase)
CloneLo(pnt, pntBase);
}
void SetPntParent(PNT* ppnt, ALO* paloParent)
{
ConvertAloPos(ppnt->paloParent, paloParent, ppnt->posLocal, ppnt->posLocal);
SetLoParent(ppnt, paloParent);
}
void ApplyPntProxy(PNT* ppnt, PROXY* pproxyApply)
{

View File

@ -11,5 +11,6 @@ void*NewPnt();
int GetPntSize();
void LoadPntFromBrx(PNT *pnt, CBinaryInputStream *pbis);
void ClonePnt(PNT* pnt, PNT* pntBase);
void SetPntParent(PNT* ppnt, ALO* paloParent);
void ApplyPntProxy(PNT* ppnt, PROXY* pproxyApply);
void DeletePnt(LO* plo);

View File

@ -15,6 +15,11 @@ void OnPoAdd(PO* ppo)
OnSoAdd(ppo);
}
void OnPoRemove(PO* ppo)
{
OnSoRemove(ppo);
}
void ClonePo(PO* ppo, PO* ppoBase)
{
LO lo = *ppo;

View File

@ -25,6 +25,7 @@ class PO : public SO
void*NewPo();
void InitPo(PO *ppo); //NOT FINISHED
void OnPoAdd(PO* ppo);
void OnPoRemove(PO* ppo);
void ClonePo(PO* ppo, PO* ppoBase);
int GetPoSize();
void DeletePo(LO* plo);

View File

@ -18,9 +18,13 @@ int GetProxySize()
void LoadProxyFromBrx(PROXY* pproxy, CBinaryInputStream* pbis)
{
/*ProxyCount++;
std::cout << "ProxyCount: " << ProxyCount<<"\n";*/
// Proxy source objects to keep track of
std::vector <LO*> proxyObjs;
InitDl(&pproxy->dlProxyRoot, 0x16);
InitDl(&pproxy->dlProxyRoot, offsetof(PXR, dleProxyRoot));
pproxy->xf.mat = pbis->ReadMatrix();
pproxy->xf.pos = pbis->ReadVector();
@ -31,7 +35,7 @@ void LoadProxyFromBrx(PROXY* pproxy, CBinaryInputStream* pbis)
for (int i = 0; i < numProxyObjs; i++)
{
LO* object{};
LO* object = nullptr;
// Loads class ID
CID cid = (CID)pbis->S16Read();
@ -39,8 +43,9 @@ void LoadProxyFromBrx(PROXY* pproxy, CBinaryInputStream* pbis)
{
// Loads proxy source index from file
uint16_t ipsl = pbis->S16Read();
// Returns proxy source object based of proxy source index
// Returns proxy source object
object = PloGetSwProxySource(pproxy->psw, ipsl);
proxyObjs.push_back(object);
}
else
@ -85,11 +90,41 @@ void LoadProxyFromBrx(PROXY* pproxy, CBinaryInputStream* pbis)
}
for (int i = 0; i < proxyObjs.size(); i++)
{
proxyObjs[i]->pvtalo->pfnApplyAloProxy((ALO*)proxyObjs[i], pproxy);
proxyObjs[i]->pvtlo->pfnSetLoParent(proxyObjs[i], pproxy->paloParent);
}
if (numProxyObjs == 1)
{
LoadSwObjectsFromBrx(pproxy->psw, pproxy, pbis);
byte isEmpty = FIsDlEmpty(&pproxy->dlChild);
if (isEmpty == false)
{
DLI proxyDLI{};
proxyDLI.m_ibDle = pproxy->dlChild.ibDle;
proxyDLI.m_pdliNext = s_pdliFirst;
LO* object = pproxy->dlChild.ploFirst;
proxyDLI.m_ppv = (void**)((uint64_t)&object->pvtlo + proxyDLI.m_ibDle);
s_pdliFirst = &proxyDLI;
proxyDLI.m_pdl = &pproxy->dlChild;
for (int i = 0; i < proxyObjs.size(); i++)
{
object->pvtlo->pfnSetLoParent(object, (ALO*)proxyObjs[i]);
object = (LO*)*proxyDLI.m_ppv;
proxyDLI.m_ppv = (void**)((uint64_t)&object->pvtlo + proxyDLI.m_ibDle);
}
s_pdliFirst = proxyDLI.m_pdliNext;
}
}
pproxy->pvtlo->pfnRemoveLo(pproxy);
pproxy->pvtlo->pfnAddLo(pproxy);
proxyObjs.clear();
proxyObjs.shrink_to_fit();
}

View File

@ -148,7 +148,8 @@ void* NewClue()
void InitClue(CLUE* pclue)
{
InitSprize(pclue);
pclue->psw->cclueAll;
pclue->ibit = pclue->psw->cclueAll;
pclue->psw->cclueAll++;
}
int GetClueSize()

View File

@ -16,6 +16,12 @@ void OnRailAdd(RAIL* prail)
AppendDlEntry(&prail->psw->dlRail, prail);
}
void OnRailRemove(RAIL* prail)
{
OnLoRemove(prail);
RemoveDlEntry(&prail->psw->dlRail, prail);
}
void CloneRail(RAIL* prail, RAIL* prailBase)
{
LO lo = *prail;
@ -28,4 +34,4 @@ void CloneRail(RAIL* prail, RAIL* prailBase)
void DeleteRail(LO* plo)
{
delete(RAIL*)plo;
}
}

View File

@ -13,5 +13,6 @@ class RAIL : public SHAPE
void*NewRail();
int GetRailSize();
void OnRailAdd(RAIL* prail);
void OnRailRemove(RAIL* prail);
void CloneRail(RAIL* prail, RAIL* prailBase);
void DeleteRail(LO* plo);

View File

@ -21,6 +21,12 @@ void OnRatAdd(RAT* prat)
AppendDlEntry(&prat->psw->dlRat, prat);
}
void OnRatRemove(RAT* prat)
{
OnSoRemove(prat);
RemoveDlEntry(&prat->psw->dlRat, prat);
}
void CloneRat(RAT* prat, RAT* pratBase)
{
LO lo = *prat;
@ -61,6 +67,12 @@ int GetRatholeSize()
return sizeof(RATHOLE);
}
void OnRatholeRemove(RATHOLE* prathole)
{
OnLoRemove((LO*)prathole);
RemoveDlEntry(&prathole->psw->dlRathole, prathole);
}
void CloneRathole(RATHOLE* prathole, RATHOLE* pratholeBase)
{
LO lo = *prathole;

View File

@ -55,6 +55,7 @@ void*NewRat();
void InitRat(RAT* prat);
int GetRatSize();
void OnRatAdd(RAT* prat);
void OnRatRemove(RAT* prat);
void CloneRat(RAT* prat, RAT* pratBase);
void LoadRatFromBrx(RAT* prat, CBinaryInputStream* pbis);
void RenderRatAll(RAT* prat, CM* pcm, RO* pro);
@ -62,6 +63,7 @@ void DeleteRat(LO* plo);
void*NewRathole();
int GetRatholeSize();
void OnRatholeRemove(RATHOLE* prathole);
void CloneRathole(RATHOLE* prathole, RATHOLE* pratholeBase);
void OnRatholeAdd(RATHOLE* prathole);
void DeleteRathole(LO* plo);

View File

@ -24,7 +24,8 @@ void RenderSw(SW *psw, CM *pcm)
while (localObject != 0)
{
// Setting object up to be rendered
localObject->pvtalo->pfnRenderAloAll((ALO*)localObject, pcm, 0);
//localObject->pvtalo->pfnRenderAloAll((ALO*)localObject, pcm, 0);
DrawAlo((ALO*)localObject);
// Loading next object
localObject = (LO*)*dlBusyDli.m_ppv;
// Loading pointer to next object to render

View File

@ -25,6 +25,11 @@ void CloneShape(SHAPE* pshape, SHAPE* pshapeBase)
CloneLo(pshape, pshapeBase);
}
void SetShapeParent(SHAPE* pshape, ALO* paloParent)
{
SetLoParent(pshape, paloParent);
}
void LoadShapeFromBrx(SHAPE* pshape, CBinaryInputStream* pbis)
{
byte unk_0 = pbis->U8Read();

View File

@ -15,5 +15,6 @@ void*NewShape();
void InitShape(SHAPE* pshape);
int GetShapeSize();
void CloneShape(SHAPE* pshape, SHAPE* pshapeBase);
void SetShapeParent(SHAPE* pshape, ALO* paloParent);
void LoadShapeFromBrx(SHAPE* pshape, CBinaryInputStream* pbis);
void DeleteShape(LO* plo);

View File

@ -12,6 +12,7 @@ int GetSmSize()
void LoadSmFromBrx(SM* psm, CBinaryInputStream* pbis)
{
InitDl(&psm->dlSma, offsetof(SMA, dleSm));
psm->csms = pbis->U8Read();
psm->asms.resize(psm->csms);
@ -66,4 +67,4 @@ int GetSmaSize()
void DeleteSma(LO* plo)
{
delete(SMA*)plo;
}
}

View File

@ -7,7 +7,7 @@ void* NewSo()
void InitSo(SO* pso)
{
InitDl(&pso->dlPhys, 0x468);
InitDl(&pso->dlPhys, offsetof(SO, dlePhys));
InitAlo(pso);
InitGeom(&pso->geomLocal);
@ -39,7 +39,10 @@ void OnSoRemove(SO* pso)
if (pso->paloParent == nullptr)
{
RemoveDlEntry(&pso->psw->dlRoot, pso);
pso->psw->cpsoRoot--;
}
pso->pstso = nullptr;
}
void CloneSo(SO* pso, SO* psoBase)
@ -57,6 +60,14 @@ void CloneSo(SO* pso, SO* psoBase)
pso->pstso = nullptr;
}
void SetSoParent(SO* pso, ALO* paloParent)
{
if (pso->paloParent != paloParent)
{
SetAloParent(pso, paloParent);
}
}
void ApplySoProxy(SO* pso, PROXY* pproxyApply)
{
ApplyAloProxy(pso, pproxyApply);
@ -117,7 +128,8 @@ void TranslateSoToPos(SO* pso, glm::vec3& ppos)
{
pso->xf.pos = ppos;
pso->pvtalo->pfnUpdateAloXfWorld(pso);
if(pso->paloRoot != nullptr)
pso->paloRoot->pvtalo->pfnUpdateAloXfWorld(pso);
}
void RotateSoToMat(SO* pso, glm::mat3& pmat)

View File

@ -90,6 +90,7 @@ int GetSoSize();
void OnSoAdd(SO *pso); // NOT FINISHED
void OnSoRemove(SO* pso);
void CloneSo(SO* pso, SO* psoBase);
void SetSoParent(SO* pso, ALO* paloParent);
void ApplySoProxy(SO* pso, PROXY* pproxyApply);
void UpdateSoXfWorldHierarchy(SO* pso);
void UpdateSoXfWorld(SO* pso);

View File

@ -16,6 +16,12 @@ void OnSpireAdd(SPIRE* pspire)
AppendDlEntry(&pspire->psw->dlSpire, pspire);
}
void OnSpireRemove(SPIRE* pspire)
{
OnLoRemove(pspire);
RemoveDlEntry(&pspire->psw->dlSpire, pspire);
}
void CloneSpire(SPIRE* pspire, SPIRE* pspireBase)
{
LO lo = *pspire;
@ -28,4 +34,4 @@ void CloneSpire(SPIRE* pspire, SPIRE* pspireBase)
void DeleteSpire(LO* plo)
{
delete(SPIRE*)plo;
}
}

View File

@ -10,5 +10,6 @@ class SPIRE : public PNT
void*NewSpire();
int GetSpireSize();
void OnSpireAdd(SPIRE* pspire);
void OnSpireRemove(SPIRE* pspire);
void CloneSpire(SPIRE* pspire, SPIRE* pspireBase);
void DeleteSpire(LO* plo);

View File

@ -44,6 +44,11 @@ void OnStepguardAdd(STEPGUARD* pstepguard)
OnPoAdd(pstepguard);
}
void OnStepguardRemove(STEPGUARD* pstepguard)
{
OnPoRemove(pstepguard);
}
void CloneStepguard(STEPGUARD* pstepguard, STEPGUARD* pstepguardBase)
{
LO lo = *pstepguard;

View File

@ -37,7 +37,8 @@ struct SGP
OID oidPhys;
struct SO* psoPhys;
};
enum RPK {
enum RPK
{
RPK_Nil = -1,
RPK_Closest = 0,
RPK_Previous = 1,
@ -185,6 +186,7 @@ void DeleteSgg(LO* plo);
void*NewStepguard();
void InitStepGuard(STEPGUARD* pstepguard);
void OnStepguardAdd(STEPGUARD* pstepguard);
void OnStepguardRemove(STEPGUARD* pstepguard);
void CloneStepguard(STEPGUARD* pstepguard, STEPGUARD* pstepguardBase);
void LoadStepGuardFromBrx(STEPGUARD *pstepguard, CBinaryInputStream *pbis);
void RenderStepguardSelf(STEPGUARD* pstepguard, CM* pcm, RO* pro);

View File

@ -3,7 +3,7 @@
std::vector<LO*> allWorldObjs;
std::vector<ALO*> allSWAloObjs;
extern std::vector<void*> allSwLights;
std::vector<void*> allSwLights;
extern std::vector <GEOM*> allcollisionModels;
void* NewSw()
@ -15,10 +15,10 @@ void InitSw(SW* psw)
{
InitLo(psw);
InitDl(&psw->dlChild, 0x38);
InitDl(&psw->dlMRD, 0xA0);
InitDl(&psw->dlChild, offsetof(LO, dleChild));
InitDl(&psw->dlMRD, offsetof(ALO, dleMRD));
InitDl(&psw->dlMRDRealClock, 0x1C + 0x54); // GOTTA COME BACK TO THIS
InitDl(&psw->dlBusy, 0x90);
InitDl(&psw->dlBusy, offsetof(ALO, dleBusy));
InitDl(&psw->dlBusySo, 0x790);
InitDl(&psw->dlRoot, 0x458);
InitDl(&psw->dlAsega, 0x1C + 0x34); // GOTTA COME BACK TO THIS
@ -36,15 +36,15 @@ void InitSw(SW* psw)
InitDl(&psw->dlRat, 0xB90);
InitDl(&psw->dlRathole, 0xC8);
InitDl(&psw->dlDartFree, 0xA70);
InitDl(&psw->dlSpire, 0x1C + 0x50); // GOTTA COME BACK TO THIS
InitDl(&psw->dlRail, 0x1C + 0x50); // GOTTA COME BACK TO THIS
InitDl(&psw->dlLanding, 0x1C + 0x50); // GOTTA COME BACK TO THIS
InitDl(&psw->dlSpire, 0x88);
InitDl(&psw->dlRail, 0x90);
InitDl(&psw->dlLanding, 0x90);
InitDl(&psw->dlBusyLasen, 0x1200);
InitDl(&psw->dlBlipg, 0x1C + 0x640);// GOTTA COME BACK TO THIS
InitDl(&psw->dlBlipgFree, 0x1C + 0x640);// GOTTA COME BACK TO THIS
InitDl(&psw->dlFader, 0x1C + 0xc);// GOTTA COME BACK TO THIS
InitDl(&psw->dlRealClockFader, 0x1C + 0xc);// GOTTA COME BACK TO THIS
InitDl(&psw->dlCrfod, 0x1C + 0xb90);// GOTTA COME BACK TO THIS
InitDl(&psw->dlCrfod, 0x11A8);
InitDl(&psw->dlShape, 0x80);
InitDl(&psw->dlPathzone, 0xB8);
}
@ -57,7 +57,7 @@ int GetSwSize()
void InitSwDlHash(SW* psw)
{
for (int i = 0; i < 0x200; i++)
InitDl(&psw->adlHash[i], 0x18);
InitDl(&psw->adlHash[i], offsetof(LO, dleOid));
}
void LoadSwFromBrx(SW* psw, CBinaryInputStream* pbis)
@ -74,10 +74,8 @@ void LoadSwFromBrx(SW* psw, CBinaryInputStream* pbis)
LoadWorldTableFromBrx(pbis);
// Loads level filenames from file
LoadNameTableFromBrx(pbis);
// Initializing camera object for world
g_pcm = (CM*)PloNew(CID_CM, psw, nullptr, OID__CAMERA, -1);
// Loads all splice script events from binary file
LoadSwSpliceFromBrx(psw, pbis);
LoadOptionFromBrx(psw, pbis);
@ -85,9 +83,13 @@ void LoadSwFromBrx(SW* psw, CBinaryInputStream* pbis)
LoadShadersFromBrx(pbis);
// Loads all the static world objects from the binary file
LoadSwObjectsFromBrx(psw, 0x0, pbis);
pbis->Align(0x10);
std::cout << "Loading Textures...\n";
LoadTexturesFromBrx(pbis);
psw->lsmDefault.uShadow = psw->lsmDefault.uShadow * 0.003921569;
psw->lsmDefault.uMidtone = psw->lsmDefault.uMidtone * 0.003921569;
std::cout << "World Loaded Successfully\n";
}
@ -115,7 +117,6 @@ void AddSwProxySource(SW* psw, LO* ploProxySource, int cploClone)
proxySourceList.cploCloneFree = cploClone;
proxySourceList.aploClone.resize(cploClone);
ALO* test = (ALO*)ploProxySource;
for (int i = 0; i < cploClone; i++)
{
LO* clonedLocalObject = PloCloneLo(ploProxySource, psw, nullptr);
@ -148,6 +149,9 @@ void DeleteSw(SW* psw)
void DeleteWorld(SW* psw)
{
for (int i = 0; i < allSWAloObjs.size(); i++)
DeleteModel(allSWAloObjs[i]);
for (int i = 0; i < allcollisionModels.size(); i++)
{
glDeleteVertexArrays(1, &allcollisionModels[i]->VAO);
@ -155,9 +159,6 @@ void DeleteWorld(SW* psw)
glDeleteBuffers(1, &allcollisionModels[i]->EBO);
}
for (int i = 0; i < allSWAloObjs.size(); i++)
DeleteModel(allSWAloObjs[i]);
for (int i = 0; i < allWorldObjs.size(); i++)
allWorldObjs[i]->pvtlo->pfnDeleteLo(allWorldObjs[i]);

View File

@ -22,6 +22,12 @@ void OnTargetAdd(TARGET* ptarget)
OnLoAdd(ptarget);
}
void OnTargetRemove(TARGET* ptarget)
{
OnLoRemove(ptarget);
//RemoveDlEntry(&g_dlTarget, ptarget);
}
void CloneTarget(TARGET* ptarget, TARGET* ptargetBase)
{
LO lo = *ptarget;

View File

@ -13,5 +13,6 @@ class TARGET : public XFM
void InitTarget(TARGET* ptarget);
int GetTargetSize();
void OnTargetAdd(TARGET* ptarget);
void OnTargetRemove(TARGET* ptarget);
void CloneTarget(TARGET* ptarget, TARGET* ptargetBase);
void DeleteTarget(LO* plo);

View File

@ -15,6 +15,11 @@ int GetTnSize()
return sizeof(TN);
}
void OnTnRemove(TN* ptn)
{
OnAloRemove(ptn);
}
void LoadTnFromBrx(TN* ptn, CBinaryInputStream* pbis)
{
ptn->xf.mat = pbis->ReadMatrix();

View File

@ -63,6 +63,7 @@ class TN : public ALO
void*NewTn();
void InitTn(TN* ptn);
int GetTnSize();
void OnTnRemove(TN* ptn);
void LoadTnFromBrx(TN* ptn, CBinaryInputStream* pbis);
void CloneTn(TN* ptn, TN* ptnBase);
void LoadTbspFromBrx(CBinaryInputStream* pbis);

View File

@ -31,9 +31,17 @@ void CloneXfm(XFM* pxfm, XFM* pxfmBase)
CloneLo(pxfm, pxfmBase);
}
void SetXfmParent(XFM* pxfm, ALO* paloParent)
{
ConvertAloPos(pxfm->paloParent, paloParent, pxfm->posLocal, pxfm->posLocal);
ConvertAloMat(pxfm->paloParent, paloParent, pxfm->matLocal, pxfm->matLocal);
SetLoParent(pxfm, paloParent);
}
void ApplyXfmProxy(XFM* pxfm, PROXY* pproxyApply)
{
ConvertAloPos((ALO*)pproxyApply, nullptr, pxfm->posLocal, pxfm->posLocal);
ConvertAloMat((ALO*)pproxyApply, nullptr, pxfm->matLocal, pxfm->matLocal);
}
void DeleteXfm(LO* plo)
@ -66,7 +74,7 @@ void LoadWarpFromBrx(WARP* pwarp, CBinaryInputStream* pbis)
OID oid = (OID)pbis->S16Read();
uint16_t isplice = pbis->S16Read();
LO* plo = PloNew(cid, pwarp->psw, 0, oid, isplice);
LO* plo = PloNew(cid, pwarp->psw, nullptr, oid, isplice);
plo->pvtlo->pfnLoadLoFromBrx(plo, pbis);
}
@ -105,8 +113,8 @@ int GetExitSize()
void LoadExitFromBrx(EXIT* pexit, CBinaryInputStream* pbis)
{
pbis->ReadMatrix();
pbis->ReadVector();
pexit->xf.mat = pbis->ReadMatrix();
pexit->xf.pos = pbis->ReadVector();
pexit->pvtalo->pfnUpdateAloXfWorld(pexit);

View File

@ -90,6 +90,7 @@ void InitXfm(XFM* pxfm);
int GetXfmSize();
void LoadXfmFromBrx(XFM* pxfm, CBinaryInputStream* pbis);
void CloneXfm(XFM* pxfm, XFM* pxfmBase);
void SetXfmParent(XFM* pxfm, ALO* paloParent);
void ApplyXfmProxy(XFM* pxfm, PROXY* pproxyApply);
void DeleteXfm(LO* plo);