diff --git a/rwengine/include/data/ObjectData.hpp b/rwengine/include/data/ObjectData.hpp index 92b70304..92202f2c 100644 --- a/rwengine/include/data/ObjectData.hpp +++ b/rwengine/include/data/ObjectData.hpp @@ -6,6 +6,9 @@ #include #include +/** + * Data used by Object Instances + */ struct ObjectData { uint16_t ID; @@ -38,6 +41,9 @@ struct ObjectData }; }; +/** + * Data used by vehicles + */ struct CarData { enum VehicleClass @@ -83,6 +89,9 @@ struct CarData float wheelScale; // used only when type == CAR }; +/** + * Data used by peds + */ struct CharacterData { uint16_t ID; diff --git a/rwengine/include/engine/GTAObject.hpp b/rwengine/include/engine/GTAObject.hpp index 34b67f63..7b063f36 100644 --- a/rwengine/include/engine/GTAObject.hpp +++ b/rwengine/include/engine/GTAObject.hpp @@ -15,8 +15,7 @@ class Animator; class GameWorld; /** - * @brief The GTAObject struct - * Stores data that is relevant to all types of objects. + * Stores data used by call types of object instances. */ struct GTAObject { diff --git a/rwengine/include/objects/VehicleInfo.hpp b/rwengine/include/objects/VehicleInfo.hpp index b3a42014..6edd7c07 100644 --- a/rwengine/include/objects/VehicleInfo.hpp +++ b/rwengine/include/objects/VehicleInfo.hpp @@ -5,6 +5,9 @@ #include #include +/** + * Vehicle handling data + */ struct VehicleHandlingInfo { enum EngineType diff --git a/rwengine/include/render/DrawBuffer.hpp b/rwengine/include/render/DrawBuffer.hpp index 36ecd4b3..3f68fe4e 100644 --- a/rwengine/include/render/DrawBuffer.hpp +++ b/rwengine/include/render/DrawBuffer.hpp @@ -4,6 +4,10 @@ #include class GeometryBuffer; + +/** + * DrawBuffer stores VAO state + */ class DrawBuffer { GLuint vao; diff --git a/rwengine/include/render/GTARenderer.hpp b/rwengine/include/render/GTARenderer.hpp index ff877f19..158c003f 100644 --- a/rwengine/include/render/GTARenderer.hpp +++ b/rwengine/include/render/GTARenderer.hpp @@ -14,6 +14,12 @@ class GameWorld; class GTAObject; class Animator; +/** + * Renderer + * + * Handles low level rendering of Models, as well as high level rendering of + * objects in the world. + */ class GTARenderer { GameWorld* engine; @@ -46,6 +52,7 @@ public: size_t rendered; size_t culled; + /* TODO clean up all these variables */ GLint uniModel, uniProj, uniView, uniCol, uniAmbientCol, uniSunDirection, uniDynamicCol; GLint uniMatDiffuse, uniMatAmbient, uniFogStart, uniFogEnd; GLuint worldProgram; @@ -59,7 +66,7 @@ public: GLuint debugTex; /** - * @brief renderWorld renders the world. + * Renders the current World. */ void renderWorld(); @@ -67,10 +74,13 @@ public: void renderGeometry(Model*, size_t geom, const glm::mat4& modelMatrix, GTAObject* = nullptr); + /** + * Renders a model (who'd have thought) + */ void renderModel(Model*, const glm::mat4& modelMatrix, GTAObject* = nullptr, Animator* animator = nullptr); /** - * @brief renderPaths renders the AI paths. + * Debug method renders all AI paths */ void renderPaths(); }; diff --git a/rwengine/include/render/GeometryBuffer.hpp b/rwengine/include/render/GeometryBuffer.hpp index 638e249d..881bd1e7 100644 --- a/rwengine/include/render/GeometryBuffer.hpp +++ b/rwengine/include/render/GeometryBuffer.hpp @@ -27,6 +27,9 @@ struct AttributeIndex { typedef std::vector AttributeList; +/** + * GeometryBuffer stores a set of vertex attribute data + */ class GeometryBuffer { GLuint vbo; GLsizei num; @@ -42,6 +45,9 @@ public: /** * Uploads Vertex Buffer data from an STL vector + * + * vertex_attributes() is assumed to exist so that vertex types + * can implicitly declare the strides and offsets for their data. */ template void uploadVertices(const std::vector& data) { uploadVertices(data.size(), data.size()*sizeof(T), data.data()); diff --git a/rwengine/include/render/Model.hpp b/rwengine/include/render/Model.hpp index a610cd41..653c5c06 100644 --- a/rwengine/include/render/Model.hpp +++ b/rwengine/include/render/Model.hpp @@ -11,17 +11,10 @@ #include "DrawBuffer.hpp" #include "GeometryBuffer.hpp" -/** - * Frame - * => Atomic - * => Geometry - * - defaultRotation - * - defaultTranslation - * - * + setTransform(mat) - * + resetTransform() - */ - +/** + * ModelFrame stores the hierarchy of a model's geometry as well as default + * transformations. + */ class ModelFrame { glm::mat3 defaultRotation; glm::vec3 defaultTranslation; @@ -65,6 +58,10 @@ public: { return geometries; } }; +/** + * Model stores all the data contained within a DFF, as well as data required + * to render them. + */ class Model { public: @@ -108,6 +105,7 @@ public: glm::vec2 texcoord; /* 48 */ glm::vec4 colour; /* 64 */ + /** @see GeometryBuffer */ static const AttributeList vertex_attributes() { return { {ATRS_Position, 3, sizeof(GeometryVertex), 0ul}, @@ -145,9 +143,7 @@ public: }; std::vector frames; - - std::vector frameNames; - + /** @TODO clean up this mess a little */ std::vector> geometries; std::vector atomics; diff --git a/rwengine/src/loaders/LoaderDFF.cpp b/rwengine/src/loaders/LoaderDFF.cpp index 7f8aa3aa..6ef83bed 100644 --- a/rwengine/src/loaders/LoaderDFF.cpp +++ b/rwengine/src/loaders/LoaderDFF.cpp @@ -52,13 +52,9 @@ Model* LoaderDFF::loadFromMemory(char *data, GameData *gameData) std::string framename(extSec.raw(), extSec.header.size); std::transform(framename.begin(), framename.end(), framename.begin(), ::tolower ); - // !HACK! - if(framename == "swaist") { - model->rootFrameIdx = model->frameNames.size(); - } - if( fn < model->frames.size() ) { - model->frames[(fn++)]->setName(framename); + model->frames[fn]->setName(framename); + fn++; } } }