summaryrefslogtreecommitdiff
path: root/ZAPD/ZVector.cpp
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2021-04-13 07:49:30 -0400
committerGitHub <noreply@github.com>2021-04-13 07:49:30 -0400
commit420508d2d872e8653081d95a43bf2ad8f85d894c (patch)
tree9019e0a87ad719c4a3b1e38c61e7b67feebfa63a /ZAPD/ZVector.cpp
parent95bf5fc0080135f20f3ab17082f79b9e539e80a5 (diff)
Refactoring and various features added (#108)
* ZAPD prints out git hash * Refactor: ZResource constructor sets parent always. ZOverlay also no longer a ZResource, since it did not make much sense. * Organized ZResource a bit * A number of bug fixes, cleanup, and feature improvements. * Prepping for legacy dlist disasm * Fixed some merging issues. Fixed compilation issues with MSVC. Added in proper support for legacy display list disassembler. Refactored parts of ZFile. * Merge with upstream * Finished ZFile refactor, and other tidying. * Fixed up merge issues * Minor cleanup * Got rid of libgfxd_win.a * Fixed matching issue * Fixed up a few bugs * Fixed issue with exceptions * Fixed up merge issues with ZPrerender, along with cleaning up some code * Additional cleanup * Fixed merge issues with ZMtx and fixed a bug with ZDisplayList * Fixes based on PR feedback * run clang-format (#7) Signed-off-by: angie <angheloalf95@gmail.com> * Fixed merge issues with Roz's PR * Misc fixes * Fixed MM bug, removed redundant file. * Removed some commented out code Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com> Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl>
Diffstat (limited to 'ZAPD/ZVector.cpp')
-rw-r--r--ZAPD/ZVector.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/ZAPD/ZVector.cpp b/ZAPD/ZVector.cpp
index 7659852..98dc3f2 100644
--- a/ZAPD/ZVector.cpp
+++ b/ZAPD/ZVector.cpp
@@ -6,23 +6,19 @@
#include "StringHelper.h"
#include "ZFile.h"
-ZVector::ZVector() : ZResource()
+REGISTER_ZFILENODE(Vector, ZVector);
+
+ZVector::ZVector(ZFile* nParent) : ZResource(nParent)
{
scalars = std::vector<ZScalar*>();
this->scalarType = ZSCALAR_NONE;
this->dimensions = 0;
}
-ZVector* ZVector::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
- const int rawDataIndex, const std::string& nRelPath)
+void ZVector::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
+ const int nRawDataIndex, const std::string& nRelPath)
{
- ZVector* vector = new ZVector();
- vector->rawData = nRawData;
- vector->rawDataIndex = rawDataIndex;
- vector->ParseXML(reader);
- vector->ParseRawData();
-
- return vector;
+ ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath);
}
void ZVector::ParseXML(tinyxml2::XMLElement* reader)
@@ -44,7 +40,7 @@ void ZVector::ParseRawData()
for (uint32_t i = 0; i < this->dimensions; i++)
{
- ZScalar* scalar = new ZScalar(this->scalarType);
+ ZScalar* scalar = new ZScalar(this->scalarType, this->parent);
scalar->rawDataIndex = currentRawDataIndex;
scalar->rawData = this->rawData;
scalar->ParseRawData();
@@ -60,8 +56,10 @@ void ZVector::ParseRawData()
int ZVector::GetRawDataSize()
{
int size = 0;
- for (size_t i = 0; i < this->scalars.size(); i++)
+
+ for (int i = 0; i < this->scalars.size(); i++)
size += this->scalars[i]->GetRawDataSize();
+
return size;
}
@@ -73,17 +71,11 @@ bool ZVector::DoesSupportArray()
std::string ZVector::GetSourceTypeName()
{
if (dimensions == 3 && scalarType == ZSCALAR_F32)
- {
return "Vec3f";
- }
else if (dimensions == 3 && scalarType == ZSCALAR_S16)
- {
return "Vec3s";
- }
else if (dimensions == 3 && scalarType == ZSCALAR_S32)
- {
return "Vec3i";
- }
else
{
std::string output = StringHelper::Sprintf(
@@ -100,8 +92,10 @@ std::string ZVector::GetSourceTypeName()
std::string ZVector::GetSourceValue()
{
std::vector<std::string> strings = std::vector<std::string>();
- for (size_t i = 0; i < this->scalars.size(); i++)
+
+ for (int i = 0; i < this->scalars.size(); i++)
strings.push_back(scalars[i]->GetSourceValue());
+
return "{ " + StringHelper::Implode(strings, ", ") + " }";
}