Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Move custom types to cbtypes #5

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/cbreader/rmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace rmesh

struct Vertex
{
Vector3 vertex;
Vector2 uv;
cbtypes::Vector3 vertex;
cbtypes::Vector2 uv;

float unk1{};
float unk2{};
Expand All @@ -50,7 +50,7 @@ namespace rmesh

std::vector<Vertex> vertices;

std::vector<Triangle> triangles;
std::vector<cbtypes::Triangle> triangles;
};

/**
Expand All @@ -76,9 +76,9 @@ namespace rmesh
std::string className;

/** This is read per entity. It would be ideal to read it in Entity, but EntityModel is special in that it has the model file name THEN the position. */
Vector3 position;
Vector3 rotation;
Vector3 scale;
cbtypes::Vector3 position;
cbtypes::Vector3 rotation;
cbtypes::Vector3 scale;

virtual ~Entity() = default;

Expand Down
35 changes: 19 additions & 16 deletions include/cbreader/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

#include <cstdint>

struct Vector3
namespace cbtypes
{
float x = 0.f;
float y = 0.f;
float z = 0.f;
};
struct Vector3
{
float x = 0.f;
float y = 0.f;
float z = 0.f;
};

struct Vector2
{
float x = 0.f;
float y = 0.f;
};
struct Vector2
{
float x = 0.f;
float y = 0.f;
};

struct Triangle
{
std::uint32_t index1 = 0;
std::uint32_t index2 = 0;
std::uint32_t index3 = 0;
};
struct Triangle
{
std::uint32_t index1 = 0;
std::uint32_t index2 = 0;
std::uint32_t index3 = 0;
};
}
4 changes: 2 additions & 2 deletions src/rmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Mesh RMesh::ReadDrawnMesh(BufferStream& stream)
std::uint32_t triangleCount = stream.read<std::uint32_t>();
for (std::uint32_t j = 0; j < triangleCount; j++)
{
Triangle& triangle = surf.triangles.emplace_back();
cbtypes::Triangle& triangle = surf.triangles.emplace_back();
stream
.read(triangle.index1)
.read(triangle.index2)
Expand Down Expand Up @@ -182,7 +182,7 @@ Mesh RMesh::ReadCollisionMesh(BufferStream& stream)
std::uint32_t triangleCount = stream.read<std::uint32_t>();
for (std::uint32_t j = 0; j < triangleCount; j++)
{
Triangle triangle{};
cbtypes::Triangle triangle{};
triangle.index1 = stream.read<std::uint32_t>();
triangle.index2 = stream.read<std::uint32_t>();
triangle.index3 = stream.read<std::uint32_t>();
Expand Down
Loading