MREA fixes, some script constructors

This commit is contained in:
Jack Andersen 2017-02-27 21:31:14 -10:00
parent e923d83617
commit 5277d445d3
17 changed files with 301 additions and 133 deletions

View File

@ -1,5 +1,6 @@
#include "MREA.hpp" #include "MREA.hpp"
#include "SCLY.hpp" #include "SCLY.hpp"
#include "PATH.hpp"
#include "DeafBabe.hpp" #include "DeafBabe.hpp"
#include "../DNACommon/BabeDead.hpp" #include "../DNACommon/BabeDead.hpp"
#include "zeus/Math.hpp" #include "zeus/Math.hpp"
@ -433,9 +434,9 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath,
/* VISI */ /* VISI */
hecl::ProjectPath visiMetadataPath(areaDirPath, _S("!visi.yaml")); hecl::ProjectPath visiMetadataPath(areaDirPath, _S("!visi.yaml"));
bool visiGood = false;
if (visiMetadataPath.isFile()) if (visiMetadataPath.isFile())
{ {
bool good = false;
athena::io::FileReader visiReader(visiMetadataPath.getAbsolutePath()); athena::io::FileReader visiReader(visiMetadataPath.getAbsolutePath());
athena::io::YAMLDocReader r; athena::io::YAMLDocReader r;
if (r.parse(&visiReader)) if (r.parse(&visiReader))
@ -514,18 +515,19 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath,
size_t length = r.length(); size_t length = r.length();
secs.emplace_back(length, 0); secs.emplace_back(length, 0);
r.readBytesToBuf(secs.back().data(), length); r.readBytesToBuf(secs.back().data(), length);
good = true; visiGood = true;
} }
} }
if (!good)
secs.emplace_back(4, 0);
} }
if (!visiGood)
secs.emplace_back(4, 0);
/* PATH */ /* PATH */
{ {
UniqueID32 pathId = inPath.ensureAuxInfo(_S("PATH"));
secs.emplace_back(4, 0); secs.emplace_back(4, 0);
athena::io::MemoryWriter w(secs.back().data(), secs.back().size()); athena::io::MemoryWriter w(secs.back().data(), secs.back().size());
w.writeUint32Big(0xffffffff); /* Empty (for now) */ pathId.write(w);
} }
/* Assemble sizes and add padding */ /* Assemble sizes and add padding */
@ -550,5 +552,32 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath,
return true; return true;
} }
bool MREA::CookPath(const hecl::ProjectPath& outPath,
const hecl::ProjectPath& inPath)
{
PATH path = {};
path.version = 4;
path.unkStructCount = 1;
path.unkStructs.emplace_back();
PATH::UnknownStruct& s = path.unkStructs.back();
s.unk1 = 1;
s.unk2[0] = {FLT_MAX, FLT_MAX, FLT_MAX};
s.unk2[1] = {FLT_MIN, FLT_MIN, FLT_MIN};
s.unk2[2] = {0.f, 0.f, 0.f};
for (int i=0 ; i<8 ; ++i)
s.unk3[i] = ~0;
s.unk4 = 0;
s.unk5 = 0;
athena::io::FileWriter w(outPath.getAbsolutePath());
path.write(w);
int64_t rem = w.position() % 32;
if (rem)
for (int64_t i=0 ; i<32-rem ; ++i)
w.writeBytes((atInt8*)"\xff", 1);
return true;
}
} }
} }

View File

@ -137,6 +137,9 @@ struct MREA
const ColMesh& cMesh, const ColMesh& cMesh,
const std::vector<Light>& lights, const std::vector<Light>& lights,
hecl::BlenderToken& btok); hecl::BlenderToken& btok);
static bool CookPath(const hecl::ProjectPath& outPath,
const hecl::ProjectPath& inPath);
}; };
} }

View File

@ -525,7 +525,11 @@ struct SpecMP1 : SpecBase
} }
return {SBIG('ANCS'), path.hash().val32()}; return {SBIG('ANCS'), path.hash().val32()};
case hecl::BlenderConnection::BlendType::Area: case hecl::BlenderConnection::BlendType::Area:
{
if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _S("PATH")))
return {SBIG('PATH'), path.hash().val32()};
return {SBIG('MREA'), path.hash().val32()}; return {SBIG('MREA'), path.hash().val32()};
}
case hecl::BlenderConnection::BlendType::World: case hecl::BlenderConnection::BlendType::World:
{ {
if (path.getAuxInfo().size()) if (path.getAuxInfo().size())
@ -713,37 +717,44 @@ struct SpecMP1 : SpecBase
void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast, void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
hecl::BlenderToken& btok, FCookProgress progress) hecl::BlenderToken& btok, FCookProgress progress)
{ {
std::vector<std::string> meshes = ds.getMeshList(); if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _S("PATH")))
std::vector<Mesh> meshCompiles;
meshCompiles.reserve(meshes.size());
std::experimental::optional<ColMesh> colMesh;
for (const std::string& mesh : meshes)
{ {
hecl::SystemStringView meshSys(mesh); DNAMP1::MREA::CookPath(out, in);
if (!mesh.compare("CMESH"))
{
colMesh = ds.compileColMesh(mesh);
progress(_S("Collision Mesh"));
continue;
}
meshCompiles.push_back(ds.compileMesh(
mesh, fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, -1,
[&](int surfCount) { progress(hecl::SysFormat(_S("%s %d"), meshSys.c_str(), surfCount).c_str()); }));
} }
if (!colMesh)
Log.report(logvisor::Fatal, _S("unable to find mesh named 'CMESH' in %s"), in.getAbsolutePath().c_str());
std::vector<Light> lights = ds.compileLights();
ds.close();
if (m_pc)
DNAMP1::MREA::PCCook(out, in, meshCompiles, *colMesh, lights, btok);
else else
DNAMP1::MREA::Cook(out, in, meshCompiles, *colMesh, lights); {
std::vector<std::string> meshes = ds.getMeshList();
std::vector<Mesh> meshCompiles;
meshCompiles.reserve(meshes.size());
std::experimental::optional<ColMesh> colMesh;
for (const std::string& mesh : meshes)
{
hecl::SystemStringView meshSys(mesh);
if (!mesh.compare("CMESH"))
{
colMesh = ds.compileColMesh(mesh);
progress(_S("Collision Mesh"));
continue;
}
meshCompiles.push_back(ds.compileMesh(
mesh, fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, -1,
[&](int surfCount) { progress(hecl::SysFormat(_S("%s %d"), meshSys.c_str(), surfCount).c_str()); }));
}
if (!colMesh)
Log.report(logvisor::Fatal, _S("unable to find mesh named 'CMESH' in %s"), in.getAbsolutePath().c_str());
std::vector<Light> lights = ds.compileLights();
ds.close();
if (m_pc)
DNAMP1::MREA::PCCook(out, in, meshCompiles, *colMesh, lights, btok);
else
DNAMP1::MREA::Cook(out, in, meshCompiles, *colMesh, lights);
}
} }
void cookWorld(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast, void cookWorld(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,

View File

@ -246,6 +246,17 @@ bool ProjectResourceFactoryBase::AddFileToIndex(const hecl::ProjectPath& path,
pathTag = {SBIG('AGSC'), asGlob.hash().val32()}; pathTag = {SBIG('AGSC'), asGlob.hash().val32()};
useGlob = true; useGlob = true;
} }
else if (pathTag.type == SBIG('MREA'))
{
hecl::ProjectPath subPath = path.ensureAuxInfo(_S("PATH"));
SObjectTag pathTag = BuildTagFromPath(subPath, m_backgroundBlender);
m_tagToPath[pathTag] = subPath;
m_pathToTag[subPath.hash()] = pathTag;
WriteTag(cacheWriter, pathTag, subPath);
#if DUMP_CACHE_FILL
DumpCacheAdd(pathTag, subPath);
#endif
}
/* Cache in-memory */ /* Cache in-memory */
const hecl::ProjectPath& usePath = useGlob ? asGlob : path; const hecl::ProjectPath& usePath = useGlob ? asGlob : path;
@ -889,7 +900,7 @@ const urde::SObjectTag* ProjectResourceFactoryBase::GetResourceIdByName(const ch
FourCC ProjectResourceFactoryBase::GetResourceTypeById(ResId id) const FourCC ProjectResourceFactoryBase::GetResourceTypeById(ResId id) const
{ {
if ((id & 0xffffffff) == 0xffffffff || !id) if ((id & 0xffffffff) == 0xffffffff || !id)
Log.report(logvisor::Fatal, "attempted to access null id"); return {};
std::unique_lock<std::mutex> lk(const_cast<ProjectResourceFactoryBase*>(this)->m_backgroundIndexMutex); std::unique_lock<std::mutex> lk(const_cast<ProjectResourceFactoryBase*>(this)->m_backgroundIndexMutex);
SObjectTag searchTag = {FourCC(), id}; SObjectTag searchTag = {FourCC(), id};

View File

@ -68,6 +68,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
x90c_loaderFuncs[int(EScriptObjectType::Platform)] = ScriptLoader::LoadPlatform; x90c_loaderFuncs[int(EScriptObjectType::Platform)] = ScriptLoader::LoadPlatform;
x90c_loaderFuncs[int(EScriptObjectType::Sound)] = ScriptLoader::LoadSound; x90c_loaderFuncs[int(EScriptObjectType::Sound)] = ScriptLoader::LoadSound;
x90c_loaderFuncs[int(EScriptObjectType::Generator)] = ScriptLoader::LoadGenerator; x90c_loaderFuncs[int(EScriptObjectType::Generator)] = ScriptLoader::LoadGenerator;
x90c_loaderFuncs[int(EScriptObjectType::Dock)] = ScriptLoader::LoadDock;
x90c_loaderFuncs[int(EScriptObjectType::Camera)] = ScriptLoader::LoadCamera; x90c_loaderFuncs[int(EScriptObjectType::Camera)] = ScriptLoader::LoadCamera;
x90c_loaderFuncs[int(EScriptObjectType::CameraWaypoint)] = ScriptLoader::LoadCameraWaypoint; x90c_loaderFuncs[int(EScriptObjectType::CameraWaypoint)] = ScriptLoader::LoadCameraWaypoint;
x90c_loaderFuncs[int(EScriptObjectType::NewIntroBoss)] = ScriptLoader::LoadNewIntroBoss; x90c_loaderFuncs[int(EScriptObjectType::NewIntroBoss)] = ScriptLoader::LoadNewIntroBoss;
@ -599,12 +600,18 @@ std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, ESc
else else
error = true; error = true;
u32 leftover = length - (in.position() - startPos); u32 readAmt = in.position() - startPos;
if (readAmt > length)
LogModule.report(logvisor::Fatal, "Script object overread");
u32 leftover = length - readAmt;
for (u32 i=0 ; i<leftover ; ++i) for (u32 i=0 ; i<leftover ; ++i)
in.readByte(); in.readByte();
if (error || ent == nullptr) if (error || ent == nullptr)
{
LogModule.report(logvisor::Fatal, "Script load error");
return {kInvalidEditorId, kInvalidUniqueId}; return {kInvalidEditorId, kInvalidUniqueId};
}
else else
return {id, ent->GetUniqueId()}; return {id, ent->GetUniqueId()};
} }

View File

@ -58,8 +58,9 @@ CAreaOctTree::Node CAreaOctTree::Node::GetChild(int idx) const
} }
else if (type == ETreeType::Leaf) else if (type == ETreeType::Leaf)
{ {
const zeus::CAABox* aabb = reinterpret_cast<const zeus::CAABox*>(m_ptr + offsets[idx] + 36); const float* aabb = reinterpret_cast<const float*>(m_ptr + offsets[idx] + 36);
return Node(aabb, *aabb, m_owner, ETreeType::Leaf); zeus::CAABox aabbObj(aabb[0], aabb[1], aabb[2], aabb[3], aabb[4], aabb[5]);
return Node(aabb, aabbObj, m_owner, ETreeType::Leaf);
} }
else else
{ {
@ -73,24 +74,24 @@ void CAreaOctTree::SwapTreeNode(u8* ptr, Node::ETreeType type)
{ {
u16* typeBits = reinterpret_cast<u16*>(ptr); u16* typeBits = reinterpret_cast<u16*>(ptr);
*typeBits = hecl::SBig(*typeBits); *typeBits = hecl::SBig(*typeBits);
u32* offsets = reinterpret_cast<u32*>(ptr + 4);
for (int i=0 ; i<8 ; ++i) for (int i=0 ; i<8 ; ++i)
{ {
Node::ETreeType ctype = Node::ETreeType((*typeBits >> (2 * i)) & 0x3); Node::ETreeType ctype = Node::ETreeType((*typeBits >> (2 * i)) & 0x3);
u32* offsets = reinterpret_cast<u32*>(ptr + 4);
offsets[i] = hecl::SBig(offsets[i]); offsets[i] = hecl::SBig(offsets[i]);
SwapTreeNode(ptr + offsets[i] + 36, ctype); SwapTreeNode(ptr + offsets[i] + 36, ctype);
} }
} }
else if (type == Node::ETreeType::Leaf) else if (type == Node::ETreeType::Leaf)
{ {
zeus::CAABox* aabb = reinterpret_cast<zeus::CAABox*>(ptr); float* aabb = reinterpret_cast<float*>(ptr);
aabb->min[0] = hecl::SBig(aabb->min[0]); aabb[0] = hecl::SBig(aabb[0]);
aabb->min[1] = hecl::SBig(aabb->min[1]); aabb[1] = hecl::SBig(aabb[1]);
aabb->min[2] = hecl::SBig(aabb->min[2]); aabb[2] = hecl::SBig(aabb[2]);
aabb->max[0] = hecl::SBig(aabb->max[0]); aabb[3] = hecl::SBig(aabb[3]);
aabb->max[1] = hecl::SBig(aabb->max[1]); aabb[4] = hecl::SBig(aabb[4]);
aabb->max[2] = hecl::SBig(aabb->max[2]); aabb[5] = hecl::SBig(aabb[5]);
u16* countIdxs = reinterpret_cast<u16*>(ptr + 24); u16* countIdxs = reinterpret_cast<u16*>(ptr + 24);
*countIdxs = hecl::SBig(*countIdxs); *countIdxs = hecl::SBig(*countIdxs);
@ -99,60 +100,43 @@ void CAreaOctTree::SwapTreeNode(u8* ptr, Node::ETreeType type)
} }
} }
CAreaOctTree::CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, const u8* buf, std::unique_ptr<u8[]>&& treeBuf, CAreaOctTree::CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, const u8* buf, const u8* treeBuf,
u32 matCount, const u32* materials, const u8* vertMats, const u8* edgeMats, const u8* polyMats, u32 matCount, const u32* materials, const u8* vertMats, const u8* edgeMats, const u8* polyMats,
u32 edgeCount, const CCollisionEdge* edges, u32 polyCount, const u16* polyEdges, u32 edgeCount, const CCollisionEdge* edges, u32 polyCount, const u16* polyEdges,
u32 vertCount, const zeus::CVector3f* verts) u32 vertCount, const float* verts)
: x0_aabb(aabb), x18_treeType(treeType), x1c_buf(buf), x20_treeBuf(std::move(treeBuf)), : x0_aabb(aabb), x18_treeType(treeType), x1c_buf(buf), x20_treeBuf(treeBuf),
x24_matCount(matCount), x2c_vertMats(vertMats), x24_matCount(matCount), x28_materials(materials), x2c_vertMats(vertMats),
x30_edgeMats(edgeMats), x34_polyMats(polyMats), x38_edgeCount(edgeCount), x30_edgeMats(edgeMats), x34_polyMats(polyMats), x38_edgeCount(edgeCount),
x40_polyCount(polyCount), x3c_edges(edges), x40_polyCount(polyCount), x44_polyEdges(polyEdges),
x48_vertCount(vertCount) x48_vertCount(vertCount), x4c_verts(verts)
{ {
SwapTreeNode(x20_treeBuf.get(), treeType); SwapTreeNode(const_cast<u8*>(x20_treeBuf), treeType);
{ for (u32 i=0 ; i<matCount ; ++i)
x28_materials.reserve(matCount); const_cast<u32*>(x28_materials)[i] = hecl::SBig(x28_materials[i]);
athena::io::MemoryReader r(materials, matCount * 4);
for (u32 i=0 ; i<matCount ; ++i)
x28_materials.push_back(r.readUint32Big());
}
{ for (u32 i=0 ; i<edgeCount ; ++i)
x3c_edges.reserve(edgeCount); const_cast<CCollisionEdge*>(x3c_edges)[i].swapBig();
athena::io::MemoryReader r(edges, edgeCount * 4);
for (u32 i=0 ; i<edgeCount ; ++i)
x3c_edges.emplace_back(r);
}
{ for (u32 i=0 ; i<polyCount ; ++i)
x44_polyEdges.reserve(polyCount); const_cast<u16*>(x44_polyEdges)[i] = hecl::SBig(x44_polyEdges[i]);
athena::io::MemoryReader r(polyEdges, polyCount * 2);
for (u32 i=0 ; i<polyCount ; ++i)
x44_polyEdges.push_back(r.readUint16Big());
}
{ for (u32 i=0 ; i<vertCount*3 ; ++i)
x4c_verts.reserve(vertCount); const_cast<float*>(x4c_verts)[i] = hecl::SBig(x4c_verts[i]);
athena::io::MemoryReader r(verts, vertCount * 12);
for (u32 i=0 ; i<vertCount ; ++i)
x4c_verts.push_back(zeus::CVector3f::ReadBig(r));
}
} }
std::unique_ptr<CAreaOctTree> CAreaOctTree::MakeFromMemory(const void* buf, unsigned int size) std::unique_ptr<CAreaOctTree> CAreaOctTree::MakeFromMemory(const u8* buf, unsigned int size)
{ {
athena::io::MemoryReader r(buf, size); athena::io::MemoryReader r(buf + 8, size - 8);
r.readUint32Big(); r.readUint32Big();
r.readUint32Big(); r.readUint32Big();
zeus::CAABox aabb; zeus::CAABox aabb;
aabb.readBoundingBoxBig(r); aabb.readBoundingBoxBig(r);
Node::ETreeType nodeType = Node::ETreeType(r.readUint32Big()); Node::ETreeType nodeType = Node::ETreeType(r.readUint32Big());
u32 treeSize = r.readUint32Big(); u32 treeSize = r.readUint32Big();
const u8* cur = reinterpret_cast<const u8*>(buf) + r.position(); const u8* cur = reinterpret_cast<const u8*>(buf) + 8 + r.position();
std::unique_ptr<u8[]> treeBuf(new u8[treeSize]); const u8* treeBuf = cur;
memmove(treeBuf.get(), cur, treeSize);
cur += treeSize; cur += treeSize;
u32 matCount = hecl::SBig(*reinterpret_cast<const u32*>(cur)); u32 matCount = hecl::SBig(*reinterpret_cast<const u32*>(cur));
@ -187,10 +171,9 @@ std::unique_ptr<CAreaOctTree> CAreaOctTree::MakeFromMemory(const void* buf, unsi
u32 vertCount = hecl::SBig(*reinterpret_cast<const u32*>(cur)); u32 vertCount = hecl::SBig(*reinterpret_cast<const u32*>(cur));
cur += 4; cur += 4;
const zeus::CVector3f* vertBuf = reinterpret_cast<const zeus::CVector3f*>(cur); const float* vertBuf = reinterpret_cast<const float*>(cur);
cur += polyCount * 2;
return std::make_unique<CAreaOctTree>(aabb, nodeType, reinterpret_cast<const u8*>(buf), std::move(treeBuf), return std::make_unique<CAreaOctTree>(aabb, nodeType, reinterpret_cast<const u8*>(buf + 8), treeBuf,
matCount, matBuf, vertMatsBuf, edgeMatsBuf, polyMatsBuf, matCount, matBuf, vertMatsBuf, edgeMatsBuf, polyMatsBuf,
edgeCount, edgeBuf, polyCount, polyBuf, vertCount, vertBuf); edgeCount, edgeBuf, polyCount, polyBuf, vertCount, vertBuf);
} }

View File

@ -95,30 +95,34 @@ public:
zeus::CAABox x0_aabb; zeus::CAABox x0_aabb;
Node::ETreeType x18_treeType; Node::ETreeType x18_treeType;
const u8* x1c_buf; const u8* x1c_buf;
std::unique_ptr<u8[]> x20_treeBuf; const u8* x20_treeBuf;
u32 x24_matCount; u32 x24_matCount;
std::vector<u32> x28_materials; const u32* x28_materials;
const u8* x2c_vertMats; const u8* x2c_vertMats;
const u8* x30_edgeMats; const u8* x30_edgeMats;
const u8* x34_polyMats; const u8* x34_polyMats;
u32 x38_edgeCount; u32 x38_edgeCount;
std::vector<CCollisionEdge> x3c_edges; const CCollisionEdge* x3c_edges;
u32 x40_polyCount; u32 x40_polyCount;
std::vector<u16> x44_polyEdges; const u16* x44_polyEdges;
u32 x48_vertCount; u32 x48_vertCount;
std::vector<zeus::CVector3f> x4c_verts; const float* x4c_verts;
void SwapTreeNode(u8* ptr, Node::ETreeType type); void SwapTreeNode(u8* ptr, Node::ETreeType type);
public: public:
CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, const u8* buf, std::unique_ptr<u8[]>&& treeBuf, CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, const u8* buf, const u8* treeBuf,
u32 matCount, const u32* materials, const u8* vertMats, const u8* edgeMats, const u8* polyMats, u32 matCount, const u32* materials, const u8* vertMats, const u8* edgeMats, const u8* polyMats,
u32 edgeCount, const CCollisionEdge* edges, u32 polyCount, const u16* polyEdges, u32 edgeCount, const CCollisionEdge* edges, u32 polyCount, const u16* polyEdges,
u32 vertCount, const zeus::CVector3f* verts); u32 vertCount, const float* verts);
Node GetRootNode() const { return Node(x20_treeBuf.get(), x0_aabb, *this, x18_treeType); } Node GetRootNode() const { return Node(x20_treeBuf, x0_aabb, *this, x18_treeType); }
const u8* GetTreeMemory() const { return x20_treeBuf.get(); } const u8* GetTreeMemory() const { return x20_treeBuf; }
const zeus::CVector3f& GetVert(int idx) const { return x4c_verts[idx]; } zeus::CVector3f GetVert(int idx) const
{
const float* vert = &x4c_verts[idx * 3];
return zeus::CVector3f(vert[0], vert[1], vert[2]);
}
const CCollisionEdge& GetEdge(int idx) const { return x3c_edges[idx]; } const CCollisionEdge& GetEdge(int idx) const { return x3c_edges[idx]; }
u32 GetEdgeMaterial(int idx) const { return x28_materials[x30_edgeMats[idx]]; } u32 GetEdgeMaterial(int idx) const { return x28_materials[x30_edgeMats[idx]]; }
u32 GetTriangleMaterial(int idx) const { return x28_materials[x34_polyMats[idx]]; } u32 GetTriangleMaterial(int idx) const { return x28_materials[x34_polyMats[idx]]; }
@ -129,7 +133,7 @@ public:
const u16* GetTriangleVertexIndices(u16 idx) const; const u16* GetTriangleVertexIndices(u16 idx) const;
const u16* GetTriangleEdgeIndices(u16 idx) const; const u16* GetTriangleEdgeIndices(u16 idx) const;
static std::unique_ptr<CAreaOctTree> MakeFromMemory(const void* buf, unsigned int size); static std::unique_ptr<CAreaOctTree> MakeFromMemory(const u8* buf, unsigned int size);
}; };
} }

View File

@ -7,14 +7,4 @@ CCollisionEdge::CCollisionEdge(CInputStream& in)
x0_index1 = in.readUint16Big(); x0_index1 = in.readUint16Big();
x2_index2 = in.readUint16Big(); x2_index2 = in.readUint16Big();
} }
u16 CCollisionEdge::GetVertIndex1() const
{
return x0_index1;
}
u16 CCollisionEdge::GetVertIndex2() const
{
return x2_index2;
}
} }

View File

@ -13,8 +13,14 @@ public:
CCollisionEdge()=default; CCollisionEdge()=default;
CCollisionEdge(CInputStream&); CCollisionEdge(CInputStream&);
u16 GetVertIndex1() const; u16 GetVertIndex1() const { return x0_index1; }
u16 GetVertIndex2() const; u16 GetVertIndex2() const { return x2_index2; }
void swapBig()
{
x0_index1 = hecl::SBig(x0_index1);
x2_index2 = hecl::SBig(x2_index2);
}
}; };
} }

View File

@ -20,9 +20,9 @@ class CActorParameters
bool b2 : 1; bool b2 : 1;
bool b3 : 1; bool b3 : 1;
bool b4 : 1; bool b4 : 1;
float x5c_; float x5c_ = 0.f;
float x60_; float x60_ = 0.f;
float x64_; float x64_ = 0.f;
public: public:
CActorParameters() : b1(true), b2(false), b3(false), b4(false) {} CActorParameters() : b1(true), b2(false), b3(false), b4(false) {}

View File

@ -4,7 +4,10 @@ namespace urde
{ {
CHealthInfo::CHealthInfo(CInputStream& in) CHealthInfo::CHealthInfo(CInputStream& in)
: x0_health(in.readFloatBig()), {
x4_knockbackResistance(in.readFloatBig()) {} in.readUint32Big();
x0_health = in.readFloatBig();
x4_knockbackResistance = in.readFloatBig();
}
} }

View File

@ -35,6 +35,7 @@ set(WORLD_SOURCES
CScriptTimer.hpp CScriptTimer.cpp CScriptTimer.hpp CScriptTimer.cpp
CScriptCounter.hpp CScriptCounter.cpp CScriptCounter.hpp CScriptCounter.cpp
CScriptEffect.hpp CScriptEffect.cpp CScriptEffect.hpp CScriptEffect.cpp
CScriptSteam.hpp CScriptSteam.cpp
CScriptPlatform.hpp CScriptPlatform.cpp CScriptPlatform.hpp CScriptPlatform.cpp
CScriptSound.hpp CScriptSound.cpp CScriptSound.hpp CScriptSound.cpp
CScriptGenerator.hpp CScriptGenerator.cpp CScriptGenerator.hpp CScriptGenerator.cpp

View File

@ -8,28 +8,30 @@ CScriptDebris::CScriptDebris(TUniqueId uid, const std::string& name, const CEnti
CModelData&& mData, const CActorParameters& aParams, ResId, const zeus::CVector3f&, float, CModelData&& mData, const CActorParameters& aParams, ResId, const zeus::CVector3f&, float,
const zeus::CVector3f&, const zeus::CColor&, float f1, float f2, float f3, const zeus::CVector3f&, const zeus::CColor&, float f1, float f2, float f3,
CScriptDebris::EScaleType, bool, bool, bool active) CScriptDebris::EScaleType, bool, bool, bool active)
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), : CPhysicsActor(uid, active, name, info, xf, std::move(mData),
CMaterialList(EMaterialTypes::Solid, EMaterialTypes::Debris), CMaterialList(EMaterialTypes::Solid, EMaterialTypes::Debris),
mData.GetBounds(xf.getRotation()), SMoverData(f2), aParams, 0.3, 0.1) mData.GetBounds(xf.getRotation()), SMoverData(f2), aParams, 0.3f, 0.1f)
{ {
} }
CScriptDebris::CScriptDebris(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& aParams, float, float, float, float, float,
float, float, float, float, const zeus::CColor&, const zeus::CColor&, float,
const zeus::CVector3f&, const zeus::CVector3f&, float, float,
const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool,
CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, bool, bool,
CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, CScriptDebris::EOrientationType,
bool, bool, bool, bool active)
: CPhysicsActor(uid, active, name, info, xf, std::move(mData),
CMaterialList(EMaterialTypes::Solid, EMaterialTypes::Debris),
mData.GetBounds(xf.getRotation()), SMoverData(1.f), aParams, 0.3f, 0.1f)
{
}
void CScriptDebris::Accept(IVisitor& visitor) void CScriptDebris::Accept(IVisitor& visitor)
{ {
visitor.Visit(this); visitor.Visit(this);
} }
#if 0
CScriptDebris::CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, float, float, float, float, float, float, float, float, float,
const zeus::CColor&, const zeus::CColor&, float, const zeus::CVector3f&, const zeus::CVector3f&,
float, float, const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool,
CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, bool, bool,
CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, CScriptDebris::EOrientationType,
bool, bool, bool)
{
}
#endif
} }

View File

@ -23,15 +23,14 @@ public:
const CActorParameters&, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&, const CActorParameters&, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&,
const zeus::CColor&, float, float, float, EScaleType, bool, bool, bool); const zeus::CColor&, float, float, float, EScaleType, bool, bool, bool);
void Accept(IVisitor& visitor);
#if 0
CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, float, float, float, float, float, float, float, float, float, const CActorParameters&, float, float, float, float, float, float, float, float, float,
const zeus::CColor&, const zeus::CColor&, float, const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CColor&, const zeus::CColor&, float, const zeus::CVector3f&, const zeus::CVector3f&,
float, float, const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool, EOrientationType, u32, float, float, const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool, EOrientationType, u32,
const zeus::CVector3f&, bool, bool, EOrientationType, u32, const zeus::CVector3f&, EOrientationType, const zeus::CVector3f&, bool, bool, EOrientationType, u32, const zeus::CVector3f&, EOrientationType,
bool, bool, bool); bool, bool, bool, bool);
#endif
void Accept(IVisitor& visitor);
}; };
} }

View File

@ -0,0 +1,14 @@
#include "CScriptSteam.hpp"
namespace urde
{
CScriptSteam::CScriptSteam(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos,
const zeus::CAABox& aabb, const CDamageInfo& dInfo, const zeus::CVector3f& orientedForce,
ETriggerFlags flags, bool active, ResId, float, float, float, float, bool)
: CScriptTrigger(uid, name, info, pos, aabb, dInfo, orientedForce, flags, active, false, false)
{
}
}

View File

@ -0,0 +1,19 @@
#ifndef __URDE_CSCRIPTSTEAM_HPP__
#define __URDE_CSCRIPTSTEAM_HPP__
#include "CScriptTrigger.hpp"
namespace urde
{
class CScriptSteam : public CScriptTrigger
{
public:
CScriptSteam(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos,
const zeus::CAABox&, const CDamageInfo& dInfo, const zeus::CVector3f& orientedForce,
ETriggerFlags flags, bool active, ResId, float, float, float, float, bool);
};
}
#endif // __URDE_CSCRIPTSTEAM_HPP__

View File

@ -44,6 +44,7 @@
#include "CScriptCameraBlurKeyframe.hpp" #include "CScriptCameraBlurKeyframe.hpp"
#include "CScriptDamageableTrigger.hpp" #include "CScriptDamageableTrigger.hpp"
#include "CScriptDebris.hpp" #include "CScriptDebris.hpp"
#include "CScriptSteam.hpp"
#include "CScriptDistanceFog.hpp" #include "CScriptDistanceFog.hpp"
#include "CScriptDockAreaChange.hpp" #include "CScriptDockAreaChange.hpp"
#include "CScriptActorRotate.hpp" #include "CScriptActorRotate.hpp"
@ -1612,12 +1613,97 @@ CEntity* ScriptLoader::LoadMetroidAlpha(CStateManager& mgr, CInputStream& in, in
CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
{ {
return nullptr; if (!EnsurePropertyCount(propCount, 39, "DebrisExtended"))
return nullptr;
SScaledActorHead aHead = LoadScaledActorHead(in, mgr);
float f1 = in.readFloatBig();
float f2 = in.readFloatBig();
float f3 = in.readFloatBig();
float f4 = in.readFloatBig();
float f5 = in.readFloatBig();
float f6 = in.readFloatBig();
float f7 = in.readFloatBig();
float f8 = in.readFloatBig();
float f9 = in.readFloatBig();
zeus::CColor c1 = zeus::CColor::ReadRGBABig(in);
zeus::CColor c2 = zeus::CColor::ReadRGBABig(in);
float f10 = in.readFloatBig();
zeus::CVector3f v1 = zeus::CVector3f::ReadBig(in);
float f11 = in.readFloatBig();
float f12 = in.readFloatBig();
zeus::CVector3f v2 = zeus::CVector3f::ReadBig(in);
ResId model = in.readUint32Big();
CActorParameters aParam = LoadActorParameters(in);
ResId particle1 = in.readUint32Big();
zeus::CVector3f particle1Scale = zeus::CVector3f::ReadBig(in);
bool particle1B1 = in.readBool();
bool particle1B2 = in.readBool();
CScriptDebris::EOrientationType particle1W = CScriptDebris::EOrientationType(in.readUint32Big());
ResId particle2 = in.readUint32Big();
zeus::CVector3f particle2Scale = zeus::CVector3f::ReadBig(in);
bool particle2B1 = in.readBool();
bool particle2B2 = in.readBool();
CScriptDebris::EOrientationType particle2W = CScriptDebris::EOrientationType(in.readUint32Big());
ResId particle3 = in.readUint32Big();
zeus::CVector3f particle3Scale = zeus::CVector3f::ReadBig(in);
CScriptDebris::EOrientationType particle3W = CScriptDebris::EOrientationType(in.readUint32Big());
bool b1 = in.readBool();
bool b2 = in.readBool();
bool b3 = in.readBool();
bool b4 = in.readBool();
CModelData modelData;
if (g_ResFactory->GetResourceTypeById(model))
modelData = CModelData(CStaticRes(model, aHead.x40_scale));
return new CScriptDebris(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform,
std::move(modelData), aParam, f1, f2, f3, f4, f5, f6, f7, f8, f9,
c1, c2, f10, aHead.x40_scale, v1, f11, f12, v2,
particle1, particle1Scale, particle1B1, particle1B2, particle1W,
particle2, particle2Scale, particle2B1, particle2B2, particle2W,
particle3, particle3Scale, particle3W, b1, b2, b3, b4);
} }
CEntity* ScriptLoader::LoadSteam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadSteam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
{ {
return nullptr; if (!EnsurePropertyCount(propCount, 11, "Steam"))
return nullptr;
std::string name = mgr.HashInstanceName(in);
zeus::CVector3f v1 = zeus::CVector3f::ReadBig(in);
zeus::CVector3f v2 = zeus::CVector3f::ReadBig(in);
CDamageInfo dInfo(in);
zeus::CVector3f v3 = zeus::CVector3f::ReadBig(in);
ETriggerFlags w1 = ETriggerFlags(in.readUint32Big());
bool b1 = in.readBool();
u32 w2 = in.readUint32Big();
float f1 = in.readFloatBig();
float f2 = in.readFloatBig();
float f3 = in.readFloatBig();
float f4 = in.readFloatBig();
bool b2 = in.readBool();
zeus::CAABox aabb(-v2 * 0.5f, v2 * 0.5f);
return new CScriptSteam(mgr.AllocateUniqueId(), name, info, v1, aabb, dInfo,
v3, w1, b1, w2, f1, f2, f3, f4, b2);
} }
CEntity* ScriptLoader::LoadRipple(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadRipple(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)