mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
chore: replace custom vector, quaternion, matrix implementation with eigen library
This commit is contained in:
@ -80,16 +80,16 @@ float AbstractGdtEntryReader::ReadFloatProperty(const std::string& propertyName,
|
||||
return result;
|
||||
}
|
||||
|
||||
Vector2f AbstractGdtEntryReader::ReadVec2Property(const std::string& propertyName, const Vector2f defaultValue) const
|
||||
GdtVec2 AbstractGdtEntryReader::ReadVec2Property(const std::string& propertyName, const GdtVec2 defaultValue) const
|
||||
{
|
||||
const auto foundProperty = m_entry.m_properties.find(propertyName);
|
||||
if (foundProperty == m_entry.m_properties.end())
|
||||
return defaultValue;
|
||||
|
||||
std::istringstream iss(foundProperty->second);
|
||||
Vector2f result;
|
||||
GdtVec2 result;
|
||||
|
||||
iss >> result(0) >> result(1);
|
||||
iss >> result.x >> result.y;
|
||||
|
||||
if (iss.fail())
|
||||
{
|
||||
@ -101,16 +101,16 @@ Vector2f AbstractGdtEntryReader::ReadVec2Property(const std::string& propertyNam
|
||||
return result;
|
||||
}
|
||||
|
||||
Vector3f AbstractGdtEntryReader::ReadVec3Property(const std::string& propertyName, const Vector3f defaultValue) const
|
||||
GdtVec3 AbstractGdtEntryReader::ReadVec3Property(const std::string& propertyName, const GdtVec3 defaultValue) const
|
||||
{
|
||||
const auto foundProperty = m_entry.m_properties.find(propertyName);
|
||||
if (foundProperty == m_entry.m_properties.end())
|
||||
return defaultValue;
|
||||
|
||||
std::istringstream iss(foundProperty->second);
|
||||
Vector3f result;
|
||||
GdtVec3 result;
|
||||
|
||||
iss >> result(0) >> result(1) >> result(2);
|
||||
iss >> result.x >> result.y >> result.z;
|
||||
|
||||
if (iss.fail())
|
||||
{
|
||||
@ -122,16 +122,16 @@ Vector3f AbstractGdtEntryReader::ReadVec3Property(const std::string& propertyNam
|
||||
return result;
|
||||
}
|
||||
|
||||
Vector4f AbstractGdtEntryReader::ReadVec4Property(const std::string& propertyName, const Vector4f defaultValue) const
|
||||
GdtVec4 AbstractGdtEntryReader::ReadVec4Property(const std::string& propertyName, const GdtVec4 defaultValue) const
|
||||
{
|
||||
const auto foundProperty = m_entry.m_properties.find(propertyName);
|
||||
if (foundProperty == m_entry.m_properties.end())
|
||||
return defaultValue;
|
||||
|
||||
std::istringstream iss(foundProperty->second);
|
||||
Vector4f result;
|
||||
GdtVec4 result;
|
||||
|
||||
iss >> result(0) >> result(1) >> result(2) >> result(3);
|
||||
iss >> result.x >> result.y >> result.z >> result.w;
|
||||
|
||||
if (iss.fail())
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Math/Vector.h"
|
||||
#include "Obj/Gdt/GdtEntry.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
@ -16,6 +15,27 @@ private:
|
||||
std::string m_message;
|
||||
};
|
||||
|
||||
struct GdtVec2
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
struct GdtVec3
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
|
||||
struct GdtVec4
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
};
|
||||
|
||||
class AbstractGdtEntryReader
|
||||
{
|
||||
protected:
|
||||
@ -25,9 +45,9 @@ protected:
|
||||
_NODISCARD bool ReadBoolProperty(const std::string& propertyName, bool defaultValue = false) const;
|
||||
_NODISCARD int ReadIntegerProperty(const std::string& propertyName, int defaultValue = 0) const;
|
||||
_NODISCARD float ReadFloatProperty(const std::string& propertyName, float defaultValue = 0.0f) const;
|
||||
_NODISCARD Vector2f ReadVec2Property(const std::string& propertyName, Vector2f defaultValue = {}) const;
|
||||
_NODISCARD Vector3f ReadVec3Property(const std::string& propertyName, Vector3f defaultValue = {}) const;
|
||||
_NODISCARD Vector4f ReadVec4Property(const std::string& propertyName, Vector4f defaultValue = {}) const;
|
||||
_NODISCARD GdtVec2 ReadVec2Property(const std::string& propertyName, GdtVec2 defaultValue = {}) const;
|
||||
_NODISCARD GdtVec3 ReadVec3Property(const std::string& propertyName, GdtVec3 defaultValue = {}) const;
|
||||
_NODISCARD GdtVec4 ReadVec4Property(const std::string& propertyName, GdtVec4 defaultValue = {}) const;
|
||||
|
||||
const GdtEntry& m_entry;
|
||||
};
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "Game/IW4/MaterialConstantsIW4.h"
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
#include "Game/IW4/TechsetConstantsIW4.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "StateMap/StateMapFromTechniqueExtractor.h"
|
||||
@ -198,14 +197,14 @@ namespace IW4
|
||||
|
||||
const auto distortionScaleX = ReadFloatProperty("distortionScaleX");
|
||||
const auto distortionScaleY = ReadFloatProperty("distortionScaleY");
|
||||
AddConstant("distortionScale", Vector4f(distortionScaleX, distortionScaleY, 0, 0));
|
||||
AddConstant("distortionScale", {distortionScaleX, distortionScaleY, 0, 0});
|
||||
|
||||
if (uvAnim)
|
||||
{
|
||||
const auto uvScrollX = ReadFloatProperty("uvScrollX");
|
||||
const auto uvScrollY = ReadFloatProperty("uvScrollY");
|
||||
const auto uvScrollRotate = ReadFloatProperty("uvScrollRotate");
|
||||
AddConstant("uvAnimParms", Vector4f(uvScrollX, uvScrollY, uvScrollRotate, 0));
|
||||
AddConstant("uvAnimParms", {uvScrollX, uvScrollY, uvScrollRotate, 0});
|
||||
}
|
||||
}
|
||||
|
||||
@ -504,11 +503,11 @@ namespace IW4
|
||||
const auto zFeatherDepth = ReadFloatProperty("zFeatherDepth");
|
||||
if (std::fpclassify(zFeatherDepth) == FP_ZERO)
|
||||
throw GdtReadingException("zFeatherDepth may not be zero");
|
||||
AddConstant("featherParms", Vector4f(1.0f / zFeatherDepth, zFeatherDepth, 0, 0));
|
||||
AddConstant("featherParms", {1.0f / zFeatherDepth, zFeatherDepth, 0, 0});
|
||||
}
|
||||
|
||||
if (std::fpclassify(eyeOffsetDepth) != FP_ZERO)
|
||||
AddConstant("eyeOffsetParms", Vector4f(eyeOffsetDepth, 0, 0, 0));
|
||||
AddConstant("eyeOffsetParms", {eyeOffsetDepth, 0, 0, 0});
|
||||
|
||||
const auto colorTint = ReadVec4Property("colorTint", {1.0f, 1.0f, 1.0f, 1.0f});
|
||||
AddConstant("colorTint", colorTint);
|
||||
@ -1009,13 +1008,13 @@ namespace IW4
|
||||
m_textures.push_back(textureDef);
|
||||
}
|
||||
|
||||
void AddConstant(const std::string& constantName, Vector4f literalData)
|
||||
void AddConstant(const std::string& constantName, const GdtVec4& literalData)
|
||||
{
|
||||
MaterialConstantDef constantDef{};
|
||||
constantDef.literal[0] = literalData(0);
|
||||
constantDef.literal[1] = literalData(1);
|
||||
constantDef.literal[2] = literalData(2);
|
||||
constantDef.literal[3] = literalData(3);
|
||||
constantDef.literal[0] = literalData.x;
|
||||
constantDef.literal[1] = literalData.y;
|
||||
constantDef.literal[2] = literalData.z;
|
||||
constantDef.literal[3] = literalData.w;
|
||||
strncpy(constantDef.name, constantName.c_str(), std::extent_v<decltype(MaterialConstantDef::name)>);
|
||||
constantDef.nameHash = Common::R_HashString(constantName.c_str());
|
||||
|
||||
|
Reference in New Issue
Block a user