summaryrefslogtreecommitdiff
path: root/ZAPD/ZCollision.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ZAPD/ZCollision.cpp')
-rw-r--r--ZAPD/ZCollision.cpp31
1 files changed, 10 insertions, 21 deletions
diff --git a/ZAPD/ZCollision.cpp b/ZAPD/ZCollision.cpp
index 0b04ca5..992332d 100644
--- a/ZAPD/ZCollision.cpp
+++ b/ZAPD/ZCollision.cpp
@@ -61,18 +61,22 @@ void ZCollisionHeader::ParseRawData()
currentPtr += vec.GetRawDataSize();
vertices.push_back(vec);
}
-
+
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 (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)));
@@ -149,16 +153,13 @@ 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",
+ polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(),
StringHelper::Sprintf("%sPolygons", auxName.c_str()), polygons.size(), declaration);
}
@@ -254,18 +255,6 @@ size_t ZCollisionHeader::GetRawDataSize() const
return 44;
}
-PolygonEntry::PolygonEntry(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
-{
- type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0);
- vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2);
- vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4);
- vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6);
- a = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8);
- b = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10);
- c = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12);
- d = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14);
-}
-
WaterBoxHeader::WaterBoxHeader(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
{
xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0);