mirror of
https://github.com/zeldaret/oot
synced 2026-07-31 00:04:49 -04:00
20c1f4e648
* First batch of files * Add missing folders back * Fix missing folders again * Finish fixing existing texture files * Gameplay_Keep XML finished * Most actor gameplay_keep undefined syms removed * Only ~200 gkeep symbols remain * All gkeep symbols that ZAP supports are fixed * Cleanup, and make gkeep names more accurate * Starting to figure out what some unknown blobs are, merge zeldaret in * fix a few more things * refactor gkeep * Change how gitkeep is handled * gkeep xml cleanup * Gkeep finished, now just waiting up ZAP updates * 100 link animations finished * 150 link animations finished * 200 link animations finished * 250 link animations finished * 350 link animations finished * 400 link animations finished * 450 link animations finished * 500 link animations finished * 550 link animations finished * All Link animations finished cannot build yet because ZAP doesn't have LinkAnimationHeader yet * xml changes for new zap stuff * finish gameplay_keep * fixing existing objects * ready for pr besides zap padding issue * mostly ready for pr * format all c files * all conflicts fixed * make changes that roman requested * fix thing i didn't mean to change * some animation symbols renamed * fixed roman's stuff * lifemeter hardcoded pointers removed * fix issue with incorrect data in gameplay_keep * removed unused asm * fixed most of fig's comments * fix all of fig's comments * reformat files * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * fixed stuff * fixed most of roman's comments * remove leading zeroes * should build now * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "f84d8337b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "f84d8337b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * all of gkeep symbols fixed * compiler error fixed * format files * final changes Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
116 lines
2.8 KiB
C++
116 lines
2.8 KiB
C++
#include "ZVector.h"
|
|
#include "ZFile.h"
|
|
#include "BitConverter.h"
|
|
#include "StringHelper.h"
|
|
#include "File.h"
|
|
#include "Globals.h"
|
|
#include <assert.h>
|
|
|
|
ZVector::ZVector() : ZResource()
|
|
{
|
|
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)
|
|
{
|
|
ZVector* vector = new ZVector();
|
|
vector->rawData = nRawData;
|
|
vector->rawDataIndex = rawDataIndex;
|
|
vector->ParseXML(reader);
|
|
vector->ParseRawData();
|
|
|
|
return vector;
|
|
}
|
|
|
|
void ZVector::ParseXML(tinyxml2::XMLElement* reader)
|
|
{
|
|
ZResource::ParseXML(reader);
|
|
|
|
std::string type = reader->Attribute("Type");
|
|
this->scalarType = ZScalar::MapOutputTypeToScalarType(type);
|
|
|
|
std::string dimensions = reader->Attribute("Dimensions");
|
|
this->dimensions = strtol(dimensions.c_str(), NULL, 16);
|
|
}
|
|
|
|
void ZVector::ParseRawData()
|
|
{
|
|
int currentRawDataIndex = this->rawDataIndex;
|
|
|
|
scalars.clear();
|
|
|
|
for (int i = 0; i < this->dimensions; i++)
|
|
{
|
|
ZScalar* scalar = new ZScalar(this->scalarType);
|
|
scalar->rawDataIndex = currentRawDataIndex;
|
|
scalar->rawData = this->rawData;
|
|
scalar->ParseRawData();
|
|
currentRawDataIndex += scalar->GetRawDataSize();
|
|
|
|
this->scalars.push_back(scalar);
|
|
}
|
|
|
|
// Ensure the scalars vector has the same number of elements as the vector dimension.
|
|
assert(this->scalars.size() == this->dimensions);
|
|
}
|
|
|
|
int ZVector::GetRawDataSize()
|
|
{
|
|
int size = 0;
|
|
for (int i = 0; i < this->scalars.size(); i++)
|
|
size += this->scalars[i]->GetRawDataSize();
|
|
return size;
|
|
}
|
|
|
|
bool ZVector::DoesSupportArray()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
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("Encountered unsupported vector type: %d dimensions, %s type", dimensions, ZScalar::MapScalarTypeToOutputType(scalarType).c_str());
|
|
|
|
if (Globals::Instance->verbosity >= VERBOSITY_DEBUG)
|
|
printf("%s\n", output.c_str());
|
|
|
|
throw output;
|
|
}
|
|
}
|
|
|
|
std::string ZVector::GetSourceValue()
|
|
{
|
|
std::vector<std::string> strings = std::vector<std::string>();
|
|
for (int i = 0; i < this->scalars.size(); i++)
|
|
strings.push_back(scalars[i]->GetSourceValue());
|
|
return "{ " + StringHelper::Implode(strings, ", ") + " }";
|
|
}
|
|
|
|
std::string ZVector::GetSourceOutputCode(const std::string& prefix)
|
|
{
|
|
if (parent != nullptr)
|
|
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), GetSourceTypeName(), GetName(), GetSourceValue());
|
|
|
|
return "";
|
|
}
|
|
|
|
ZResourceType ZVector::GetResourceType()
|
|
{
|
|
return ZResourceType::Vector;
|
|
} |