mirror of https://github.com/AxioDL/metaforce.git
COBBTree::GetSurface imp
This commit is contained in:
parent
79443d93d2
commit
ed5220793f
|
@ -1,9 +1,9 @@
|
|||
#include "CCollisionResponseData.hpp"
|
||||
#include "CParticleDataFactory.hpp"
|
||||
#include "CDecalDescription.hpp"
|
||||
#include "CSwooshDescription.hpp"
|
||||
#include "CElectricDescription.hpp"
|
||||
#include "CGenDescription.hpp"
|
||||
#include "Particle/CParticleDataFactory.hpp"
|
||||
#include "Particle/CDecalDescription.hpp"
|
||||
#include "Particle/CSwooshDescription.hpp"
|
||||
#include "Particle/CElectricDescription.hpp"
|
||||
#include "Particle/CGenDescription.hpp"
|
||||
#include "Graphics/CModel.hpp"
|
||||
#include "CSimplePool.hpp"
|
||||
#include "CRandom16.hpp"
|
|
@ -1,6 +1,7 @@
|
|||
set(COLLISION_SOURCES
|
||||
CollisionUtil.hpp CollisionUtil.cpp
|
||||
CGameCollision.hpp CGameCollision.cpp
|
||||
CCollisionResponseData.hpp CCollisionResponseData.cpp
|
||||
CCollisionInfo.hpp CCollisionInfo.cpp
|
||||
CCollisionInfoList.hpp CCollisionInfoList.cpp
|
||||
CCollisionEdge.hpp CCollisionEdge.cpp
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "COBBTree.hpp"
|
||||
|
||||
|
||||
namespace urde
|
||||
{
|
||||
/* This is exactly what retro did >.< */
|
||||
|
@ -30,6 +29,29 @@ COBBTree::COBBTree(CInputStream& in)
|
|||
{
|
||||
}
|
||||
|
||||
CCollisionSurface COBBTree::GetSurface(u16 idx) const
|
||||
{
|
||||
u32 surfIdx = idx * 3;
|
||||
CCollisionEdge edge1 = x18_indexData.x50_surfaceIndices[x18_indexData.x50_surfaceIndices[surfIdx]];
|
||||
CCollisionEdge edge2 = x18_indexData.x50_surfaceIndices[x18_indexData.x50_surfaceIndices[surfIdx + 1]];
|
||||
u16 vert1 = edge2.GetVertIndex1();
|
||||
u16 vert2 = edge2.GetVertIndex2();
|
||||
u16 vert3 = edge1.GetVertIndex1();
|
||||
|
||||
if (vert3 == vert1 || vert3 == edge2.GetVertIndex2())
|
||||
vert3 = edge1.GetVertIndex2();
|
||||
|
||||
u32 mat = x18_indexData.x0_materials[x18_indexData.x30_surfaceMaterials[idx]];
|
||||
|
||||
if ((mat & 0x2000000) != 0)
|
||||
{
|
||||
return CCollisionSurface(x18_indexData.x60_vertices[vert2], x18_indexData.x60_vertices[vert1],
|
||||
x18_indexData.x60_vertices[vert3], mat);
|
||||
}
|
||||
return CCollisionSurface(x18_indexData.x60_vertices[vert1], x18_indexData.x60_vertices[vert2],
|
||||
x18_indexData.x60_vertices[vert3], mat);
|
||||
}
|
||||
|
||||
zeus::CAABox COBBTree::CalculateLocalAABox() const
|
||||
{
|
||||
return CalculateAABox(zeus::CTransform::Identity());
|
||||
|
@ -45,31 +67,31 @@ zeus::CAABox COBBTree::CalculateAABox(const zeus::CTransform& xf) const
|
|||
COBBTree::SIndexData::SIndexData(CInputStream& in)
|
||||
{
|
||||
u32 count = in.readUint32Big();
|
||||
x0_.reserve(count);
|
||||
x0_materials.reserve(count);
|
||||
for (u32 i = 0 ; i < count ; i++)
|
||||
x0_.push_back(in.readUint32Big());
|
||||
x0_materials.push_back(in.readUint32Big());
|
||||
|
||||
count = in.readUint32Big();
|
||||
for (u32 i = 0 ; i < count ; i++)
|
||||
x10_.push_back(in.readUByte());
|
||||
x10_vertMaterials.push_back(in.readUByte());
|
||||
count = in.readUint32Big();
|
||||
for (u32 i = 0 ; i < count ; i++)
|
||||
x20_.push_back(in.readUByte());
|
||||
x20_edgeMaterials.push_back(in.readUByte());
|
||||
count = in.readUint32Big();
|
||||
for (u32 i = 0 ; i < count ; i++)
|
||||
x30_.push_back(in.readUByte());
|
||||
x30_surfaceMaterials.push_back(in.readUByte());
|
||||
|
||||
count = in.readUint32Big();
|
||||
for (u32 i = 0 ; i < count ; i++)
|
||||
x40_.push_back(in);
|
||||
x40_edges.push_back(in);
|
||||
|
||||
count = in.readUint32Big();
|
||||
for (u32 i = 0 ; i < count ; i++)
|
||||
x50_.push_back(in.readUint16Big());
|
||||
x50_surfaceIndices.push_back(in.readUint16Big());
|
||||
|
||||
count = in.readUint32Big();
|
||||
for (u32 i = 0 ; i < count ; i++)
|
||||
x60_.push_back(zeus::CVector3f::ReadBig(in));
|
||||
x60_vertices.push_back(zeus::CVector3f::ReadBig(in));
|
||||
}
|
||||
|
||||
COBBTree::CNode::CNode(const zeus::CTransform& xf, const zeus::CVector3f& point,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __URDE_COBBTREE_HPP__
|
||||
#include "RetroTypes.hpp"
|
||||
#include "CCollisionEdge.hpp"
|
||||
#include "CCollisionSurface.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
#include "zeus/COBBox.hpp"
|
||||
|
||||
|
@ -12,13 +13,13 @@ class COBBTree
|
|||
public:
|
||||
struct SIndexData
|
||||
{
|
||||
std::vector<u32> x0_;
|
||||
std::vector<u8> x10_;
|
||||
std::vector<u8> x20_;
|
||||
std::vector<u8> x30_;
|
||||
std::vector<CCollisionEdge> x40_;
|
||||
std::vector<u16> x50_;
|
||||
std::vector<zeus::CVector3f> x60_;
|
||||
std::vector<u32> x0_materials;
|
||||
std::vector<u8> x10_vertMaterials;
|
||||
std::vector<u8> x20_edgeMaterials;
|
||||
std::vector<u8> x30_surfaceMaterials;
|
||||
std::vector<CCollisionEdge> x40_edges;
|
||||
std::vector<u16> x50_surfaceIndices;
|
||||
std::vector<zeus::CVector3f> x60_vertices;
|
||||
SIndexData()=default;
|
||||
SIndexData(CInputStream&);
|
||||
};
|
||||
|
@ -70,6 +71,7 @@ public:
|
|||
COBBTree(const COBBTree::SIndexData&, const CNode*);
|
||||
COBBTree(CInputStream&);
|
||||
|
||||
void GetSurface(u16) const;
|
||||
zeus::CAABox CalculateLocalAABox() const;
|
||||
zeus::CAABox CalculateAABox(const zeus::CTransform&) const;
|
||||
};
|
||||
|
|
|
@ -27,7 +27,6 @@ set(PARTICLE_SOURCES
|
|||
CParticleElectric.hpp CParticleElectric.cpp
|
||||
CParticleGen.hpp CParticleGen.cpp
|
||||
CProjectileWeaponDataFactory.hpp CProjectileWeaponDataFactory.cpp
|
||||
CCollisionResponseData.hpp CCollisionResponseData.cpp
|
||||
CDecalManager.hpp CDecalManager.cpp
|
||||
CSpawnSystemKeyframeData.hpp CSpawnSystemKeyframeData.cpp
|
||||
CWarp.hpp CWarp.cpp
|
||||
|
|
|
@ -17,7 +17,7 @@ void CParticleElectric::RenderSwooshes()
|
|||
CParticleElectric::CParticleElectric(const TToken<CElectricDescription>& token)
|
||||
: x1c_elecDesc(token)
|
||||
{
|
||||
x438_24_x450_24 = true;
|
||||
x450_24 = true;
|
||||
/* x438_28_x450_28 = true; demo */
|
||||
x450_29 = true; // are 28 and 29 the same between retail and demo?
|
||||
CElectricDescription* desc = x1c_elecDesc.GetObj();
|
||||
|
@ -40,14 +40,14 @@ CParticleElectric::CParticleElectric(const TToken<CElectricDescription>& token)
|
|||
|
||||
if (desc->x40_SSWH.m_found)
|
||||
{
|
||||
x438_27_x450_27_HaveSSWH = true;
|
||||
x450_27_HaveSSWH = true;
|
||||
for (int i = 0 ; i < x154_SCNT ; i++)
|
||||
x1e0_lineManagers[i].SSWH.reset(new CParticleSwoosh(desc->x40_SSWH.m_token, x150_SSEG));
|
||||
}
|
||||
|
||||
if (desc->x50_GPSM.m_found)
|
||||
{
|
||||
x438_25_x450_25_HaveGPSM = true;
|
||||
x450_25_HaveGPSM = true;
|
||||
for (int i = 0 ; i < x154_SCNT ; i++)
|
||||
x1e0_lineManagers[i].GPSM.reset(new CElementGen(desc->x50_GPSM.m_token,
|
||||
CElementGen::EModelOrientationType::Normal,
|
||||
|
@ -56,7 +56,7 @@ CParticleElectric::CParticleElectric(const TToken<CElectricDescription>& token)
|
|||
|
||||
if (desc->x60_EPSM.m_found)
|
||||
{
|
||||
x438_26_x450_26_HaveEPSM = true;
|
||||
x450_26_HaveEPSM = true;
|
||||
for (int i = 0 ; i < x154_SCNT ; i++)
|
||||
x1e0_lineManagers[i].EPSM.reset(new CElementGen(desc->x60_EPSM.m_token,
|
||||
CElementGen::EModelOrientationType::Normal,
|
||||
|
@ -105,38 +105,38 @@ void CParticleElectric::Render()
|
|||
void CParticleElectric::SetOrientation(const zeus::CTransform& orientation)
|
||||
{
|
||||
x44_orientation = orientation;
|
||||
x438_28_x450_28 = true;
|
||||
x450_28 = true;
|
||||
}
|
||||
|
||||
void CParticleElectric::SetTranslation(const zeus::CVector3f& translation)
|
||||
{
|
||||
x38_translation = translation;
|
||||
x438_28_x450_28 = true;
|
||||
x450_28 = true;
|
||||
}
|
||||
|
||||
void CParticleElectric::SetGlobalOrientation(const zeus::CTransform& orientation)
|
||||
{
|
||||
xb0_globalOrientation = orientation;
|
||||
x438_28_x450_28 = true;
|
||||
x450_28 = true;
|
||||
}
|
||||
|
||||
void CParticleElectric::SetGlobalTranslation(const zeus::CVector3f& translation)
|
||||
{
|
||||
xa4_globalTranslation = translation;
|
||||
x438_28_x450_28 = true;
|
||||
x450_28 = true;
|
||||
}
|
||||
|
||||
void CParticleElectric::SetGlobalScale(const zeus::CVector3f& scale)
|
||||
{
|
||||
xe0_globalScale = scale;
|
||||
x438_28_x450_28 = true;
|
||||
x450_28 = true;
|
||||
}
|
||||
|
||||
void CParticleElectric::SetLocalScale(const zeus::CVector3f& scale)
|
||||
{
|
||||
xec_localScale = scale;
|
||||
x438_28_x450_28 = true;
|
||||
if (x438_26_x450_26_HaveEPSM)
|
||||
x450_28 = true;
|
||||
if (x450_26_HaveEPSM)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -147,11 +147,7 @@ void CParticleElectric::SetParticleEmission(bool)
|
|||
|
||||
void CParticleElectric::SetModulationColor(const zeus::CColor& color)
|
||||
{
|
||||
if (!x1bc_hasModuColor)
|
||||
x1bc_hasModuColor = true;
|
||||
|
||||
x1b8_moduColor = color;
|
||||
/* TODO: Add child particle systems */
|
||||
}
|
||||
|
||||
const zeus::CTransform& CParticleElectric::GetOrientation() const
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
std::unique_ptr<CElementGen> GPSM;
|
||||
std::unique_ptr<CElementGen> EPSM;
|
||||
};
|
||||
|
||||
private:
|
||||
TLockedToken<CElectricDescription> x1c_elecDesc;
|
||||
int x28_currentFrame = 0;
|
||||
|
@ -44,9 +45,7 @@ private:
|
|||
bool x194 = false;
|
||||
bool x1b4 = false;
|
||||
zeus::CColor x1b8_moduColor;
|
||||
bool x1bc_hasModuColor = false;
|
||||
int x1c0 = 32;
|
||||
char x1c4[4][8];
|
||||
rstl::reserved_vector<bool,32> x1c0_;
|
||||
rstl::reserved_vector<CLineManager, 32> x1e0_lineManagers;
|
||||
int x414 = 0;
|
||||
int x418 = 0;
|
||||
|
@ -65,8 +64,8 @@ private:
|
|||
{
|
||||
struct
|
||||
{
|
||||
bool x438_24_x450_24 : 1; bool x438_25_x450_25_HaveGPSM : 1; bool x438_26_x450_26_HaveEPSM : 1; bool x438_27_x450_27_HaveSSWH : 1;
|
||||
bool x438_28_x450_28: 1; bool x450_29 : 1;
|
||||
bool x450_24 : 1; bool x450_25_HaveGPSM : 1; bool x450_26_HaveEPSM : 1;
|
||||
bool x450_27_HaveSSWH : 1; bool x450_28: 1; bool x450_29 : 1;
|
||||
};
|
||||
u8 dummy = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue