ZAPD Update (#2851)
* git subrepo clone --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "6aa54a551" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "6aa54a551" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo clone --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "88b012240" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "88b012240" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Update (its broken) * fix the enum * git subrepo push --remote=C:/ZeldaStuff/ZAPDTR/ ZAPDTR subrepo: subdir: "ZAPDTR" merged: "b7b6e1c82" upstream: origin: "C:/ZeldaStuff/ZAPDTR/" branch: "rebase2" commit: "b7b6e1c82" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * New names for LUS actions * git subrepo push --remote=C:/ZeldaStuff/ZAPDTR/ ZAPDTR subrepo: subdir: "ZAPDTR" merged: "c5cfebeee" upstream: origin: "C:/ZeldaStuff/ZAPDTR/" branch: "rebase2" commit: "c5cfebeee" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo clone (merge) --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/ subrepo: subdir: "ZAPDTR" merged: "d5f4769b8" upstream: origin: "C:/ZeldaStuff/ZAPDTR" branch: "rebase2" commit: "d5f4769b8" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Fix missing commands in the exporter. * Cleanups. * git subrepo pull --force --remote=https://github.com/harbourmasters/ZAPDTR --branch=master ZAPDTR subrepo: subdir: "ZAPDTR" merged: "d4c35b90a" upstream: origin: "https://github.com/harbourmasters/ZAPDTR" branch: "master" commit: "d4c35b90a" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Add unordered_map include to fix MacOS * fix string_view * Update Main.cpp * fix string view * So close I can almost taste it * So close * Fix missed git marker. * Fix surface types and * Update ZFile.cpp * Delete Jenkinsfile --------- Co-authored-by: Christopher Leggett <chris@leggett.dev> Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "ZCollision.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
@@ -51,7 +52,7 @@ void ZCollisionHeader::ParseRawData()
|
||||
vertices.reserve(numVerts);
|
||||
polygons.reserve(numPolygons);
|
||||
|
||||
uint32_t currentPtr = vtxSegmentOffset;
|
||||
offset_t currentPtr = vtxSegmentOffset;
|
||||
|
||||
for (uint16_t i = 0; i < numVerts; i++)
|
||||
{
|
||||
@@ -63,23 +64,67 @@ void ZCollisionHeader::ParseRawData()
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < numPolygons; i++)
|
||||
polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16)));
|
||||
{
|
||||
ZCollisionPoly poly(parent);
|
||||
poly.SetRawDataIndex(polySegmentOffset + (i * 16));
|
||||
poly.ParseRawData();
|
||||
polygons.push_back(poly);
|
||||
}
|
||||
|
||||
uint16_t highestPolyType = 0;
|
||||
|
||||
for (PolygonEntry poly : polygons)
|
||||
for (const ZCollisionPoly& poly : polygons)
|
||||
{
|
||||
if (poly.type > highestPolyType)
|
||||
highestPolyType = poly.type;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < highestPolyType + 1; i++)
|
||||
polygonTypes.push_back(
|
||||
BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8)));
|
||||
{
|
||||
ZSurfaceType surfaceType(parent);
|
||||
surfaceType.SetRawDataIndex(polyTypeDefSegmentOffset + (i * 8));
|
||||
surfaceType.ParseRawData();
|
||||
PolygonTypes.push_back(surfaceType);
|
||||
}
|
||||
// polygonTypes.push_back(
|
||||
// BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8)));
|
||||
|
||||
if (camDataAddress != 0)
|
||||
camData = new CameraDataList(parent, name, rawData, camDataSegmentOffset,
|
||||
polyTypeDefSegmentOffset, polygonTypes.size());
|
||||
if (camDataAddress != SEGMENTED_NULL)
|
||||
{
|
||||
// Try to guess how many elements the CamDataList array has.
|
||||
// The "guessing algorithm" is basically a "best effort" one and it
|
||||
// is error-prone.
|
||||
// This is based mostly on observation of how CollisionHeader data is
|
||||
// usually ordered. If for some reason the data was in some other funny
|
||||
// order, this would probably break.
|
||||
// The most common ordering is:
|
||||
// - *CamData*
|
||||
// - SurfaceType
|
||||
// - CollisionPoly
|
||||
// - Vertices
|
||||
// - WaterBoxes
|
||||
// - CollisionHeader
|
||||
offset_t upperCameraBoundary = polyTypeDefSegmentOffset;
|
||||
if (upperCameraBoundary == 0)
|
||||
{
|
||||
upperCameraBoundary = polySegmentOffset;
|
||||
}
|
||||
if (upperCameraBoundary == 0)
|
||||
{
|
||||
upperCameraBoundary = vtxSegmentOffset;
|
||||
}
|
||||
if (upperCameraBoundary == 0)
|
||||
{
|
||||
upperCameraBoundary = waterBoxSegmentOffset;
|
||||
}
|
||||
if (upperCameraBoundary == 0)
|
||||
{
|
||||
upperCameraBoundary = rawDataIndex;
|
||||
}
|
||||
|
||||
camData =
|
||||
new CameraDataList(parent, name, rawData, camDataSegmentOffset, upperCameraBoundary);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < numWaterBoxes; i++)
|
||||
waterBoxes.push_back(WaterBoxHeader(
|
||||
@@ -110,8 +155,7 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix)
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
waterBoxSegmentOffset, DeclarationAlignment::Align4, 16 * waterBoxes.size(), "WaterBox",
|
||||
StringHelper::Sprintf("%s_waterBoxes_%06X", auxName.c_str(), waterBoxSegmentOffset),
|
||||
waterBoxes.size(), declaration);
|
||||
StringHelper::Sprintf("%sWaterBoxes", auxName.c_str()), waterBoxes.size(), declaration);
|
||||
}
|
||||
|
||||
if (polygons.size() > 0)
|
||||
@@ -122,40 +166,31 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix)
|
||||
{
|
||||
for (size_t i = 0; i < polygons.size(); i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(
|
||||
"\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },",
|
||||
polygons[i].type, polygons[i].vtxA, polygons[i].vtxB, polygons[i].vtxC,
|
||||
polygons[i].a, polygons[i].b, polygons[i].c, polygons[i].d);
|
||||
declaration +=
|
||||
StringHelper::Sprintf("\t%s,", polygons[i].GetBodySourceCode().c_str());
|
||||
if (i + 1 < polygons.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, "CollisionPoly",
|
||||
StringHelper::Sprintf("%s_polygons_%08X", auxName.c_str(), polySegmentOffset),
|
||||
polygons.size(), declaration);
|
||||
parent->AddDeclarationArray(polySegmentOffset, DeclarationAlignment::Align4,
|
||||
polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(),
|
||||
StringHelper::Sprintf("%sPolygons", auxName.c_str()),
|
||||
polygons.size(), declaration);
|
||||
}
|
||||
|
||||
declaration.clear();
|
||||
if (!Globals::Instance->otrMode)
|
||||
for (const auto& polyType : PolygonTypes)
|
||||
{
|
||||
for (size_t i = 0; i < polygonTypes.size(); i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf("\t{ 0x%08lX, 0x%08lX },", polygonTypes[i] >> 32,
|
||||
polygonTypes[i] & 0xFFFFFFFF);
|
||||
|
||||
if (i < polygonTypes.size() - 1)
|
||||
declaration += "\n";
|
||||
}
|
||||
declaration += StringHelper::Sprintf("\t%s,", polyType.GetBodySourceCode().c_str());
|
||||
}
|
||||
|
||||
if (polyTypeDefAddress != 0)
|
||||
parent->AddDeclarationArray(
|
||||
polyTypeDefSegmentOffset, DeclarationAlignment::Align4, polygonTypes.size() * 8,
|
||||
"SurfaceType",
|
||||
StringHelper::Sprintf("%s_surfaceType_%08X", auxName.c_str(), polyTypeDefSegmentOffset),
|
||||
polygonTypes.size(), declaration);
|
||||
if (polyTypeDefAddress != SEGMENTED_NULL)
|
||||
parent->AddDeclarationArray(polyTypeDefSegmentOffset, DeclarationAlignment::Align4,
|
||||
PolygonTypes.size() * 8,
|
||||
PolygonTypes[0].GetSourceTypeName().c_str(),
|
||||
StringHelper::Sprintf("%sSurfaceType", auxName.c_str()),
|
||||
PolygonTypes.size(), declaration);
|
||||
|
||||
declaration.clear();
|
||||
|
||||
@@ -180,8 +215,7 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix)
|
||||
parent->AddDeclarationArray(
|
||||
vtxSegmentOffset, first.GetDeclarationAlignment(),
|
||||
vertices.size() * first.GetRawDataSize(), first.GetSourceTypeName(),
|
||||
StringHelper::Sprintf("%s_vtx_%08X", auxName.c_str(), vtxSegmentOffset),
|
||||
vertices.size(), declaration);
|
||||
StringHelper::Sprintf("%sVertices", auxName.c_str()), vertices.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,34 +278,18 @@ size_t ZCollisionHeader::GetRawDataSize() const
|
||||
return 44;
|
||||
}
|
||||
|
||||
PolygonEntry::PolygonEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
type = BitConverter::ToUInt16BE(data, rawDataIndex + 0);
|
||||
vtxA = BitConverter::ToUInt16BE(data, rawDataIndex + 2);
|
||||
vtxB = BitConverter::ToUInt16BE(data, rawDataIndex + 4);
|
||||
vtxC = BitConverter::ToUInt16BE(data, rawDataIndex + 6);
|
||||
a = BitConverter::ToUInt16BE(data, rawDataIndex + 8);
|
||||
b = BitConverter::ToUInt16BE(data, rawDataIndex + 10);
|
||||
c = BitConverter::ToUInt16BE(data, rawDataIndex + 12);
|
||||
d = BitConverter::ToUInt16BE(data, rawDataIndex + 14);
|
||||
}
|
||||
|
||||
WaterBoxHeader::WaterBoxHeader(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
|
||||
{
|
||||
const uint8_t* data = rawData.data();
|
||||
|
||||
xMin = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
||||
ySurface = BitConverter::ToInt16BE(data, rawDataIndex + 2);
|
||||
zMin = BitConverter::ToInt16BE(data, rawDataIndex + 4);
|
||||
xLength = BitConverter::ToInt16BE(data, rawDataIndex + 6);
|
||||
zLength = BitConverter::ToInt16BE(data, rawDataIndex + 8);
|
||||
xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);
|
||||
ySurface = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
|
||||
zMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
||||
xLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
||||
zLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 8);
|
||||
|
||||
if (Globals::Instance->game == ZGame::OOT_SW97)
|
||||
properties = BitConverter::ToInt16BE(data, rawDataIndex + 10);
|
||||
properties = BitConverter::ToInt16BE(rawData, rawDataIndex + 10);
|
||||
else
|
||||
properties = BitConverter::ToInt32BE(data, rawDataIndex + 12);
|
||||
properties = BitConverter::ToInt32BE(rawData, rawDataIndex + 12);
|
||||
}
|
||||
|
||||
std::string WaterBoxHeader::GetBodySourceCode() const
|
||||
@@ -281,16 +299,17 @@ std::string WaterBoxHeader::GetBodySourceCode() const
|
||||
}
|
||||
|
||||
CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
||||
const std::vector<uint8_t>& rawData, uint32_t rawDataIndex,
|
||||
uint32_t polyTypeDefSegmentOffset,
|
||||
[[maybe_unused]] uint32_t polygonTypesCnt)
|
||||
const std::vector<uint8_t>& rawData, offset_t rawDataIndex,
|
||||
offset_t upperCameraBoundary)
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
// Parse CameraDataEntries
|
||||
int32_t numElements = (polyTypeDefSegmentOffset - rawDataIndex) / 8;
|
||||
uint32_t cameraPosDataSeg = rawDataIndex;
|
||||
for (int32_t i = 0; i < numElements; i++)
|
||||
size_t numElements = (upperCameraBoundary - rawDataIndex) / 8;
|
||||
assert(numElements < 10000);
|
||||
|
||||
offset_t cameraPosDataSeg = rawDataIndex;
|
||||
for (size_t i = 0; i < numElements; i++)
|
||||
{
|
||||
CameraDataEntry* entry = new CameraDataEntry();
|
||||
|
||||
@@ -322,8 +341,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
||||
{
|
||||
int32_t index =
|
||||
((entries[i]->cameraPosDataSeg & 0x00FFFFFF) - cameraPosDataOffset) / 0x6;
|
||||
sprintf(camSegLine, "&%s_camPosData_%08X[%i]", prefix.c_str(), cameraPosDataOffset,
|
||||
index);
|
||||
sprintf(camSegLine, "&%sCamPosData[%i]", prefix.c_str(), index);
|
||||
}
|
||||
else
|
||||
sprintf(camSegLine, "NULL");
|
||||
@@ -338,7 +356,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
||||
|
||||
parent->AddDeclarationArray(
|
||||
rawDataIndex, DeclarationAlignment::Align4, entries.size() * 8, "CamData",
|
||||
StringHelper::Sprintf("%s_camDataList_%08X", prefix.c_str(), rawDataIndex), entries.size(),
|
||||
StringHelper::Sprintf("%sCamDataList", prefix.c_str(), rawDataIndex), entries.size(),
|
||||
declaration);
|
||||
|
||||
uint32_t numDataTotal = (rawDataIndex - cameraPosDataOffset) / 0x6;
|
||||
@@ -359,10 +377,9 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix,
|
||||
|
||||
int32_t cameraPosDataIndex = GETSEGOFFSET(cameraPosDataSeg);
|
||||
uint32_t entrySize = numDataTotal * 0x6;
|
||||
parent->AddDeclarationArray(
|
||||
cameraPosDataIndex, DeclarationAlignment::Align4, entrySize, "Vec3s",
|
||||
StringHelper::Sprintf("%s_camPosData_%08X", prefix.c_str(), cameraPosDataIndex),
|
||||
numDataTotal, declaration);
|
||||
parent->AddDeclarationArray(cameraPosDataIndex, DeclarationAlignment::Align4, entrySize,
|
||||
"Vec3s", StringHelper::Sprintf("%sCamPosData", prefix.c_str()),
|
||||
numDataTotal, declaration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user