From: Daniel Karbach Date: Mon, 15 Jun 2015 10:30:34 +0000 (+0200) Subject: some cleaning :) X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=6f94235a5b7c140852703e60c8a74760b8b61d99;p=blank.git some cleaning :) --- diff --git a/TODO b/TODO index 8ee6ef2..7b481da 100644 --- a/TODO +++ b/TODO @@ -68,7 +68,7 @@ chunk traversal all chunks by position, possibly base-relative profiling indicates that this is not neccessary atm. maybe it will - when some more action is in the world + when there's some more action in the world transparency (blocks and entities) diff --git a/src/app/Application.hpp b/src/app/Application.hpp index c8236ff..99f0dc4 100644 --- a/src/app/Application.hpp +++ b/src/app/Application.hpp @@ -31,6 +31,7 @@ public: /// run until user quits void Run(); + /// evaluate a single frame of dt milliseconds void Loop(int dt); /// run for n frames @@ -40,8 +41,11 @@ public: /// run for n frames, assuming t milliseconds for each void RunS(size_t n, size_t t); + /// process all events in SDL's queue void HandleEvents(); + /// integrate to the next step with dt milliseconds passed void Update(int dt); + /// push the current state to display void Render(); static Entity &MakeTestEntity(World &); diff --git a/src/app/FPSController.hpp b/src/app/FPSController.hpp index 88dca64..01c7451 100644 --- a/src/app/FPSController.hpp +++ b/src/app/FPSController.hpp @@ -9,13 +9,19 @@ namespace blank { +/// Sets entity rotation and velocity according to stored velocity +/// and pitch/yaw components. +/// Rotation is applied in yaw,pitch order (YX). Velocity is relative +/// to yaw only (Y axis). class FPSController { public: explicit FPSController(Entity &) noexcept; + /// get position and face direction of controlled entity Ray Aim() const noexcept { return entity.Aim(entity.ChunkCoords()); } + /// velocity, relative to heading (yaw only) const glm::vec3 &Velocity() const noexcept { return velocity; } void Velocity(const glm::vec3 &vel) noexcept { velocity = vel; } diff --git a/src/app/IntervalTimer.hpp b/src/app/IntervalTimer.hpp index e5d0248..0d6790b 100644 --- a/src/app/IntervalTimer.hpp +++ b/src/app/IntervalTimer.hpp @@ -4,9 +4,15 @@ namespace blank { +/// Timer that hits every n milliseconds. Resolution is that of the +/// delta values passed to Update(), minimum 1ms. +/// Also tracks the number of iterations as well as milliseconds +/// passed. class IntervalTimer { public: + /// Create a timer that hits every interval_ms milliseconds. + /// Initial state is stopped. explicit IntervalTimer(int interval_ms) noexcept : intv(interval_ms) { } @@ -21,6 +27,7 @@ public: bool Running() const noexcept { return speed != 0; } + /// true if an interval boundary was passed by the last call to Update() bool Hit() const noexcept { return Running() && value % intv < last_dt; } diff --git a/src/app/RandomWalk.hpp b/src/app/RandomWalk.hpp index 5660ab3..0a61974 100644 --- a/src/app/RandomWalk.hpp +++ b/src/app/RandomWalk.hpp @@ -8,6 +8,7 @@ namespace blank { class Entity; +/// Randomly start or stop moving in axis directions every now and then. class RandomWalk { public: diff --git a/src/app/Runtime.hpp b/src/app/Runtime.hpp index 2fdf2e5..ee0b4a0 100644 --- a/src/app/Runtime.hpp +++ b/src/app/Runtime.hpp @@ -8,14 +8,20 @@ namespace blank { +/// Parse and interpret arguemnts, then set up the environment and execute. class Runtime { public: enum Mode { + /// default behaviour: run until user quits, dynamic timesteps NORMAL, + /// quit after n frames FRAME_LIMIT, + /// quit after n milliseconds TIME_LIMIT, + /// quit after n frames, use fixed timestap FIXED_FRAME_LIMIT, + /// display error message and quit with failure ERROR, }; diff --git a/src/world/Chunk.hpp b/src/world/Chunk.hpp index d986874..8d6816c 100644 --- a/src/world/Chunk.hpp +++ b/src/world/Chunk.hpp @@ -158,8 +158,8 @@ private: private: const BlockTypeRegistry *types; Chunk *neighbor[Block::FACE_COUNT]; - Block blocks[16 * 16 * 16]; - unsigned char light[16 * 16 * 16]; + Block blocks[size]; + unsigned char light[size]; BlockModel model; Pos position; bool dirty;