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)
/// run until user quits
void Run();
+ /// evaluate a single frame of dt milliseconds
void Loop(int dt);
/// run for n frames
/// 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 &);
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; }
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) { }
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;
}
class Entity;
+/// Randomly start or stop moving in axis directions every now and then.
class RandomWalk {
public:
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,
};
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;