mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-14 05:11:21 +00:00
Connection: Make use of std::array where applicable
Uses std::array in place of C arrays where not used as a buffer.
This commit is contained in:
parent
a3caa28483
commit
877ca7ad87
@ -137,15 +137,15 @@ struct Vector4f {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct Matrix3f {
|
struct Matrix3f {
|
||||||
atVec3f m[3];
|
std::array<atVec3f, 3> m;
|
||||||
inline atVec3f& operator[](size_t idx) { return m[idx]; }
|
atVec3f& operator[](size_t idx) { return m[idx]; }
|
||||||
inline const atVec3f& operator[](size_t idx) const { return m[idx]; }
|
const atVec3f& operator[](size_t idx) const { return m[idx]; }
|
||||||
};
|
};
|
||||||
struct Matrix4f {
|
struct Matrix4f {
|
||||||
atVec4f val[4];
|
std::array<atVec4f, 4> val;
|
||||||
Matrix4f() = default;
|
Matrix4f() = default;
|
||||||
void read(Connection& conn);
|
|
||||||
Matrix4f(Connection& conn) { read(conn); }
|
Matrix4f(Connection& conn) { read(conn); }
|
||||||
|
void read(Connection& conn);
|
||||||
const atVec4f& operator[](size_t idx) const { return val[idx]; }
|
const atVec4f& operator[](size_t idx) const { return val[idx]; }
|
||||||
};
|
};
|
||||||
struct Index {
|
struct Index {
|
||||||
@ -434,14 +434,14 @@ struct ColMesh {
|
|||||||
std::vector<Vector3f> verts;
|
std::vector<Vector3f> verts;
|
||||||
|
|
||||||
struct Edge {
|
struct Edge {
|
||||||
uint32_t verts[2];
|
std::array<uint32_t, 2> verts;
|
||||||
bool seam;
|
bool seam;
|
||||||
Edge(Connection& conn);
|
Edge(Connection& conn);
|
||||||
};
|
};
|
||||||
std::vector<Edge> edges;
|
std::vector<Edge> edges;
|
||||||
|
|
||||||
struct Triangle {
|
struct Triangle {
|
||||||
uint32_t edges[3];
|
std::array<uint32_t, 3> edges;
|
||||||
uint32_t matIdx;
|
uint32_t matIdx;
|
||||||
bool flip;
|
bool flip;
|
||||||
Triangle(Connection& conn);
|
Triangle(Connection& conn);
|
||||||
@ -455,10 +455,10 @@ struct ColMesh {
|
|||||||
struct World {
|
struct World {
|
||||||
struct Area {
|
struct Area {
|
||||||
ProjectPath path;
|
ProjectPath path;
|
||||||
Vector3f aabb[2];
|
std::array<Vector3f, 2> aabb;
|
||||||
Matrix4f transform;
|
Matrix4f transform;
|
||||||
struct Dock {
|
struct Dock {
|
||||||
Vector3f verts[4];
|
std::array<Vector3f, 4> verts;
|
||||||
Index targetArea;
|
Index targetArea;
|
||||||
Index targetDock;
|
Index targetDock;
|
||||||
Dock(Connection& conn);
|
Dock(Connection& conn);
|
||||||
@ -702,8 +702,8 @@ class Connection {
|
|||||||
#else
|
#else
|
||||||
pid_t m_blenderProc = 0;
|
pid_t m_blenderProc = 0;
|
||||||
#endif
|
#endif
|
||||||
int m_readpipe[2];
|
std::array<int, 2> m_readpipe{};
|
||||||
int m_writepipe[2];
|
std::array<int, 2> m_writepipe{};
|
||||||
BlendType m_loadedType = BlendType::None;
|
BlendType m_loadedType = BlendType::None;
|
||||||
bool m_loadedRigged = false;
|
bool m_loadedRigged = false;
|
||||||
ProjectPath m_loadedBlend;
|
ProjectPath m_loadedBlend;
|
||||||
|
@ -285,8 +285,8 @@ Connection::Connection(int verbosityLevel) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
/* Construct communication pipes */
|
/* Construct communication pipes */
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
_pipe(m_readpipe, 2048, _O_BINARY);
|
_pipe(m_readpipe.data(), 2048, _O_BINARY);
|
||||||
_pipe(m_writepipe, 2048, _O_BINARY);
|
_pipe(m_writepipe.data(), 2048, _O_BINARY);
|
||||||
HANDLE writehandle = HANDLE(_get_osfhandle(m_writepipe[0]));
|
HANDLE writehandle = HANDLE(_get_osfhandle(m_writepipe[0]));
|
||||||
SetHandleInformation(writehandle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
|
SetHandleInformation(writehandle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
|
||||||
HANDLE readhandle = HANDLE(_get_osfhandle(m_readpipe[1]));
|
HANDLE readhandle = HANDLE(_get_osfhandle(m_readpipe[1]));
|
||||||
@ -561,8 +561,9 @@ std::streambuf::int_type PyOutStream::StreamBuf::overflow(int_type ch) {
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* BlendTypeStrs[] = {"NONE", "MESH", "CMESH", "ACTOR", "AREA", "WORLD",
|
constexpr std::array<const char*, 11> BlendTypeStrs{
|
||||||
"MAPAREA", "MAPUNIVERSE", "FRAME", "PATH", nullptr};
|
"NONE", "MESH", "CMESH", "ACTOR", "AREA", "WORLD", "MAPAREA", "MAPUNIVERSE", "FRAME", "PATH", nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
bool Connection::createBlend(const ProjectPath& path, BlendType type) {
|
bool Connection::createBlend(const ProjectPath& path, BlendType type) {
|
||||||
if (m_lock) {
|
if (m_lock) {
|
||||||
@ -1548,7 +1549,7 @@ std::pair<atVec3f, atVec3f> DataStream::getMeshAABB() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* DataStream::MeshOutputModeString(HMDLTopology topology) {
|
const char* DataStream::MeshOutputModeString(HMDLTopology topology) {
|
||||||
static const char* STRS[] = {"TRIANGLES", "TRISTRIPS"};
|
static constexpr std::array<const char*, 2> STRS{"TRIANGLES", "TRISTRIPS"};
|
||||||
return STRS[int(topology)];
|
return STRS[int(topology)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user