diff --git a/Runtime/Particle/CCollisionResponseData.cpp b/Runtime/Collision/CCollisionResponseData.cpp similarity index 97% rename from Runtime/Particle/CCollisionResponseData.cpp rename to Runtime/Collision/CCollisionResponseData.cpp index 4cba26e92..81ce8adc9 100644 --- a/Runtime/Particle/CCollisionResponseData.cpp +++ b/Runtime/Collision/CCollisionResponseData.cpp @@ -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" diff --git a/Runtime/Particle/CCollisionResponseData.hpp b/Runtime/Collision/CCollisionResponseData.hpp similarity index 100% rename from Runtime/Particle/CCollisionResponseData.hpp rename to Runtime/Collision/CCollisionResponseData.hpp diff --git a/Runtime/Collision/CMakeLists.txt b/Runtime/Collision/CMakeLists.txt index ad4202743..0893fb90f 100644 --- a/Runtime/Collision/CMakeLists.txt +++ b/Runtime/Collision/CMakeLists.txt @@ -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 diff --git a/Runtime/Collision/COBBTree.cpp b/Runtime/Collision/COBBTree.cpp index f990ee8e7..f5958cc81 100644 --- a/Runtime/Collision/COBBTree.cpp +++ b/Runtime/Collision/COBBTree.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, diff --git a/Runtime/Collision/COBBTree.hpp b/Runtime/Collision/COBBTree.hpp index 2a8fbe2d1..942ab1b4a 100644 --- a/Runtime/Collision/COBBTree.hpp +++ b/Runtime/Collision/COBBTree.hpp @@ -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 x0_; - std::vector x10_; - std::vector x20_; - std::vector x30_; - std::vector x40_; - std::vector x50_; - std::vector x60_; + std::vector x0_materials; + std::vector x10_vertMaterials; + std::vector x20_edgeMaterials; + std::vector x30_surfaceMaterials; + std::vector x40_edges; + std::vector x50_surfaceIndices; + std::vector 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; }; diff --git a/Runtime/Particle/CMakeLists.txt b/Runtime/Particle/CMakeLists.txt index 23cf3a68a..8c32ef2eb 100644 --- a/Runtime/Particle/CMakeLists.txt +++ b/Runtime/Particle/CMakeLists.txt @@ -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 diff --git a/Runtime/Particle/CParticleElectric.cpp b/Runtime/Particle/CParticleElectric.cpp index 664d18592..cbfa61e27 100644 --- a/Runtime/Particle/CParticleElectric.cpp +++ b/Runtime/Particle/CParticleElectric.cpp @@ -17,7 +17,7 @@ void CParticleElectric::RenderSwooshes() CParticleElectric::CParticleElectric(const TToken& 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& 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& 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 diff --git a/Runtime/Particle/CParticleElectric.hpp b/Runtime/Particle/CParticleElectric.hpp index 88910e6fd..080c4da67 100644 --- a/Runtime/Particle/CParticleElectric.hpp +++ b/Runtime/Particle/CParticleElectric.hpp @@ -20,6 +20,7 @@ public: std::unique_ptr GPSM; std::unique_ptr EPSM; }; + private: TLockedToken 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 x1c0_; rstl::reserved_vector 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; };