Skip to content

Commit

Permalink
PascalCase model code
Browse files Browse the repository at this point in the history
  • Loading branch information
graphitemaster committed Jul 17, 2016
1 parent 2b6adff commit c900af2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 45 deletions.
31 changes: 16 additions & 15 deletions model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ static void createTangents(const u::vector<m::vec3> &vertices,

///! OBJ Loader
struct obj {
bool load(const u::string &file, model *store);
bool load(const u::string &file, Model *store);
};

bool obj::load(const u::string &file, model *store) {
bool obj::load(const u::string &file, Model *store) {
u::file fp = fopen(neoGamePath() + file + ".obj", "r");
if (!fp)
return false;
Expand Down Expand Up @@ -242,7 +242,7 @@ bool obj::load(const u::string &file, model *store) {

// Generate batches
for (const auto &g : groups) {
model::batch b;
Model::Batch b;
b.offset = (void *)(store->m_indices.size() * sizeof(uint32_t));
b.count = g.second.size();
// Rewire size_t -> GLuint
Expand All @@ -264,7 +264,8 @@ struct iqm {
static constexpr int kHalf = 6;
static constexpr int kFloat = 7;

bool load(const u::string &file, model *store, const u::vector<u::string> &anims);
bool load(const u::string &file, Model *store, const u::vector<u::string> &anims);

protected:
struct iqmHeader {
static constexpr const char *kMagic = "INTERQUAKEMODEL";
Expand Down Expand Up @@ -336,8 +337,8 @@ struct iqm {
uint32_t offset;
};

bool loadMeshes(const iqmHeader *hdr, unsigned char *buf, model *store);
bool loadAnims(const iqmHeader *hdr, unsigned char *buf, model *store);
bool loadMeshes(const iqmHeader *hdr, unsigned char *buf, Model *store);
bool loadAnims(const iqmHeader *hdr, unsigned char *buf, Model *store);

private:
u::vector<m::mat3x4> m_baseFrame;
Expand Down Expand Up @@ -393,7 +394,7 @@ struct inData {
};
};

bool iqm::loadMeshes(const iqmHeader *hdr, unsigned char *buf, model *store) {
bool iqm::loadMeshes(const iqmHeader *hdr, unsigned char *buf, Model *store) {
u::endianSwap((uint32_t*)&buf[hdr->ofsVertexArrays],
hdr->numVertexArrays*sizeof(iqmVertexArray)/sizeof(uint32_t));
u::endianSwap((uint32_t*)&buf[hdr->ofsTriangles],
Expand Down Expand Up @@ -579,7 +580,7 @@ bool iqm::loadMeshes(const iqmHeader *hdr, unsigned char *buf, model *store) {
return true;
}

bool iqm::loadAnims(const iqmHeader *hdr, unsigned char *buf, model *store) {
bool iqm::loadAnims(const iqmHeader *hdr, unsigned char *buf, Model *store) {
u::endianSwap((uint32_t *)&buf[hdr->ofsPoses], hdr->numPoses*sizeof(iqmPose)/sizeof(uint32_t));
u::endianSwap((uint32_t *)&buf[hdr->ofsAnims], hdr->numAnims*sizeof(iqmAnim)/sizeof(uint32_t));
u::endianSwap((uint16_t *)&buf[hdr->ofsFrames], hdr->numFrames*hdr->numFrameChannels);
Expand Down Expand Up @@ -611,7 +612,7 @@ bool iqm::loadAnims(const iqmHeader *hdr, unsigned char *buf, model *store) {
return true;
}

bool iqm::load(const u::string &file, model *store, const u::vector<u::string> &anims) {
bool iqm::load(const u::string &file, Model *store, const u::vector<u::string> &anims) {
auto read = u::read(neoGamePath() + file + ".iqm", "rb");
if (!read)
return false;
Expand All @@ -630,7 +631,7 @@ bool iqm::load(const u::string &file, model *store, const u::vector<u::string> &
return false;

// batches
model::batch b;
Model::Batch b;
const char *const str = hdr->ofsText ? (char *)&data[hdr->ofsText] : nullptr;
const iqmMesh *const meshes = (iqmMesh*)&data[hdr->ofsMeshes];
for (uint32_t i = 0; i < hdr->numMeshes; i++) {
Expand Down Expand Up @@ -665,9 +666,9 @@ bool iqm::load(const u::string &file, model *store, const u::vector<u::string> &
return true;
}

model::~model() = default;
Model::~Model() = default;

void model::makeHalf() {
void Model::makeHalf() {
static constexpr size_t kFloats = sizeof(Mesh::GeneralVertex)/sizeof(float);
if (animated()) {
const auto &vertices = m_animVertices;
Expand All @@ -694,7 +695,7 @@ void model::makeHalf() {
}
}

void model::makeSingle() {
void Model::makeSingle() {
static constexpr size_t kHalfs = sizeof(Mesh::GeneralHalfVertex)/sizeof(m::half);
if (animated()) {
const auto &vertices = m_animHalfVertices;
Expand All @@ -720,7 +721,7 @@ void model::makeSingle() {
}
}

bool model::load(const u::string &file, const u::vector<u::string> &anims) {
bool Model::load(const u::string &file, const u::vector<u::string> &anims) {
const auto iqm_ = u::format("%s/%s.iqm", neoGamePath(), file);
const auto obj_ = u::format("%s/%s.obj", neoGamePath(), file);
if (u::exists(iqm_) && !iqm().load(file, this, anims))
Expand All @@ -739,7 +740,7 @@ bool model::load(const u::string &file, const u::vector<u::string> &anims) {
return true;
}

void model::animate(float curFrame) {
void Model::animate(float curFrame) {
if (m_numFrames == 0)
return;

Expand Down
40 changes: 20 additions & 20 deletions model.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

#include "u_string.h"

struct model {
model();
~model();
struct Model {
Model();
~Model();

struct batch {
struct Batch {
void *offset;
size_t count;
size_t material; // Material index for rendering (calculated in r_model.cpp)
Expand All @@ -28,7 +28,7 @@ struct model {
const u::vector<Mesh::AnimHalfVertex> &animHalfVertices() const;

const u::vector<unsigned int> &indices() const;
const u::vector<batch> &batches() const;
const u::vector<Batch> &batches() const;
const u::vector<u::string> &meshNames() const;

const m::bbox &bounds() const;
Expand All @@ -49,7 +49,7 @@ struct model {
bool m_isHalf;

m::bbox m_bounds;
u::vector<batch> m_batches;
u::vector<Batch> m_batches;
u::vector<unsigned int> m_indices;

// When loading OBJs this is populated with the names of the groups in
Expand All @@ -75,62 +75,62 @@ struct model {
u::vector<Mesh::GeneralHalfVertex> m_generalHalfVertices; // generated data for unanimated models
};

inline model::model()
inline Model::Model()
: m_isHalf(false)
, m_numFrames(0)
, m_numJoints(0)
{
}

inline bool model::isHalf() const {
inline bool Model::isHalf() const {
return m_isHalf;
}

inline const u::vector<Mesh::GeneralVertex> &model::generalVertices() const {
inline const u::vector<Mesh::GeneralVertex> &Model::generalVertices() const {
return m_generalVertices;
}

inline const u::vector<Mesh::AnimVertex> &model::animVertices() const {
inline const u::vector<Mesh::AnimVertex> &Model::animVertices() const {
return m_animVertices;
}

inline const u::vector<Mesh::GeneralHalfVertex> &model::generalHalfVertices() const {
inline const u::vector<Mesh::GeneralHalfVertex> &Model::generalHalfVertices() const {
return m_generalHalfVertices;
}

inline const u::vector<Mesh::AnimHalfVertex> &model::animHalfVertices() const {
inline const u::vector<Mesh::AnimHalfVertex> &Model::animHalfVertices() const {
return m_animHalfVertices;
}

inline const u::vector<unsigned int> &model::indices() const {
inline const u::vector<unsigned int> &Model::indices() const {
return m_indices;
}

inline const u::vector<model::batch> &model::batches() const {
inline const u::vector<Model::Batch> &Model::batches() const {
return m_batches;
}

inline const u::vector<u::string> &model::meshNames() const {
inline const u::vector<u::string> &Model::meshNames() const {
return m_meshNames;
}

inline const m::bbox &model::bounds() const {
inline const m::bbox &Model::bounds() const {
return m_bounds;
}

inline bool model::animated() const {
inline bool Model::animated() const {
return m_numFrames;
}

inline const float *model::bones() const {
inline const float *Model::bones() const {
return m_outFrame[0].a.f;
}

inline size_t model::joints() const {
inline size_t Model::joints() const {
return m_numJoints;
}

inline const u::string &model::name() const {
inline const u::string &Model::name() const {
return m_name;
}

Expand Down
16 changes: 8 additions & 8 deletions r_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
namespace r {

#if defined(DEBUG_GUI)
static void printLine(const ::gui::line &it) {
static void printLine(const ::gui::Line &it) {
u::print(" [0] = { x: %d, y: %d }\n", it.x[0], it.y[0]);
u::print(" [1] = { x: %d, y: %d }\n", it.x[1], it.y[0]);
u::print(" r = %d\n", it.r);
}

static void printRectangle(const ::gui::rectangle &it) {
static void printRectangle(const ::gui::Rectangle &it) {
u::print(" { x: %d, y: %d, w: %d, h: %d, r: %d }\n", it.x, it.y, it.w,
it.h, it.r);
}

static void printText(const ::gui::text &it) {
static void printText(const ::gui::Text &it) {
auto align = [](int a) {
switch (a) {
case ::gui::kAlignCenter: return "center";
Expand All @@ -36,20 +36,20 @@ static void printText(const ::gui::text &it) {
align(it.align), it.contents);
}

static void printScissor(const ::gui::scissor &it) {
static void printScissor(const ::gui::Scissor &it) {
u::print(" { x: %d, y: %d, w: %d, h: %d }\n", it.x, it.y, it.w, it.h);
}

static void printTriangle(const ::gui::triangle &it) {
static void printTriangle(const ::gui::Triangle &it) {
u::print(" { x: %d, y: %d, w: %d, h: %d }\n", it.x, it.y, it.w, it.h);
}

static void printImage(const ::gui::image &it) {
static void printImage(const ::gui::Image &it) {
u::print(" { x: %d, y: %d, w: %d, h: %d, path: %s }\n",
it.x, it.y, it.w, it.h, it.path);
}

static void printModel(const ::gui::model &it) {
static void printModel(const ::gui::Model &it) {
u::print(" { x: %d, y: %d, w: %d, h: %d, path: %s\n",
it.x, it.y, it.w, it.h, it.path);
u::print(" wvp: {\n");
Expand All @@ -61,7 +61,7 @@ static void printModel(const ::gui::model &it) {
u::print(" }\n");
}

static void printCommand(const ::gui::command &it) {
static void printCommand(const ::gui::Command &it) {
switch (it.type) {
case ::gui::kCommandLine:
u::print("line: (color: #%X)\n", it.color);
Expand Down
4 changes: 2 additions & 2 deletions r_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ struct model : geom {
private:
geomMethods *m_geomMethods;
u::vector<material> m_materials;
u::vector<::model::batch> m_batches;
u::vector<::Model::Batch> m_batches;
size_t m_indices;
::model m_model;
::Model m_model;
bool m_half;
r::stat *m_stats;
};
Expand Down

0 comments on commit c900af2

Please sign in to comment.