Back to square one
This commit is contained in:
@@ -8,11 +8,6 @@
|
||||
|
||||
#include "../util.h"
|
||||
|
||||
#define CHUNK_DIM 32
|
||||
#define CHUNK_SIZE (CHUNK_DIM*CHUNK_DIM)
|
||||
|
||||
#define INDEX(x, z) (CHUNK_DIM * (z) + (x))
|
||||
|
||||
typedef struct Chunk
|
||||
{
|
||||
float *heightmap;
|
||||
|
||||
@@ -5,11 +5,6 @@
|
||||
|
||||
#include "chunk.h"
|
||||
|
||||
#define TERRAIN_TEXTURES 5
|
||||
#define CHUNKMESH_DIM (CHUNK_DIM+1)
|
||||
#define CHUNKMESH_SIZE (CHUNKMESH_DIM*CHUNKMESH_DIM)
|
||||
#define CMINDEX(x, z) (CHUNKMESH_DIM * (z) + (x))
|
||||
|
||||
typedef struct ChunkMesh
|
||||
{
|
||||
unsigned int pbo;
|
||||
@@ -18,7 +13,6 @@ typedef struct ChunkMesh
|
||||
unsigned int ebo;
|
||||
} ChunkMesh;
|
||||
|
||||
|
||||
ChunkMesh *ChunkMesh_build (Chunk *chunk, Chunk *nr, Chunk *nd, Chunk *nc);
|
||||
void ChunkMesh_bind (ChunkMesh *mesh);
|
||||
void ChunkMesh_render (ChunkMesh *mesh, gboolean wireframe);
|
||||
|
||||
@@ -26,7 +26,7 @@ Entity_render (Entity *entity, vec3 camera_position, mat4 view, vec4 frustum_pla
|
||||
/* Why an int, why int division? It's simply much faster than
|
||||
floating point operations. No need to have super accurate cull
|
||||
distance anyway, and might as well save a lot when rendering entities. */
|
||||
unsigned int cull_dist = (render_distance * 16 * entity->cull_distance) / 100;
|
||||
unsigned int cull_dist = (render_distance * CHUNK_DIM * entity->cull_distance) / 100;
|
||||
/* Underneath is the slowest (for the CPU) part of the entity render
|
||||
process. Moving the camera positions from memory into some
|
||||
registers. Thus the entity rendering function optimization is
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
#include <glib-2.0/glib.h>
|
||||
#include <cglm/cglm.h>
|
||||
|
||||
#include "../util.h"
|
||||
#include "../gvar.h"
|
||||
#include "../gl/mesh_globals.h"
|
||||
#include "../gl/program.h"
|
||||
#include "../gl/texture.h"
|
||||
|
||||
struct World; /* Forward declaration. */
|
||||
|
||||
typedef struct Entity
|
||||
{
|
||||
enum { MESH_QUAD1, MESH_QUAD2, MESH_QUAD_X } mesh_type;
|
||||
@@ -21,7 +24,7 @@ typedef struct Entity
|
||||
gboolean wavy;
|
||||
|
||||
void *userdata;
|
||||
void (*on_tick) (struct Entity *self);
|
||||
void (*on_tick) (struct Entity *self, struct World *world);
|
||||
|
||||
vec3 position;
|
||||
vec3 rotation;
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
extern SDL_Window *sdl_window;
|
||||
|
||||
static Profiler profiler = { 0 };
|
||||
static const int profiler_check_freq_s = 10;
|
||||
|
||||
static const int profiler_check_freq_s = 10;
|
||||
static const int render_frame_budget_us = 16666;
|
||||
static const int render_distance_min = 2;
|
||||
static const int render_distance_max = 12;
|
||||
@@ -158,6 +158,15 @@ _freelook_camera (SDL_Event *event, void *userdata)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
_temporary_player_tick (Entity *self, World *world)
|
||||
{
|
||||
if (!FLAG_GET ("flight_enabled"))
|
||||
{
|
||||
self->position[1] = World_get_height_at (world, self->position[0], self->position[2]);
|
||||
}
|
||||
}
|
||||
|
||||
GameStage *
|
||||
stage_ingame_new ()
|
||||
{
|
||||
@@ -198,6 +207,7 @@ stage_ingame_new ()
|
||||
|
||||
player_entity = Entity_new ();
|
||||
player_entity->visible = false;
|
||||
player_entity->on_tick = _temporary_player_tick;
|
||||
glm_vec3_copy ((vec3) { 1.0, 1.8, 1.0 }, player_entity->scale);
|
||||
/* player_entity->on_tick = character_on_tick; */
|
||||
World_add_Entity (self->world, player_entity);
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
#define GAME_NAME "Wschód"
|
||||
#define GAME_VERSION "0.3"
|
||||
|
||||
#define CHUNK_DIM 32
|
||||
#define CHUNK_SIZE (CHUNK_DIM*CHUNK_DIM)
|
||||
#define INDEX(x, z) (CHUNK_DIM * (z) + (x))
|
||||
|
||||
#define TERRAIN_TEXTURES 5
|
||||
#define CHUNKMESH_DIM (CHUNK_DIM+1)
|
||||
#define CHUNKMESH_SIZE (CHUNKMESH_DIM*CHUNKMESH_DIM)
|
||||
#define CMINDEX(x, z) (CHUNKMESH_DIM * (z) + (x))
|
||||
|
||||
#define UNUSED(...) (UNUSED_1 (__VA_ARGS__, 0))
|
||||
#define UNUSED_1(arg, ...) (void) arg, UNUSED_2 (__VA_ARGS__, 0)
|
||||
#define UNUSED_2(arg, ...) (void) arg, UNUSED_3 (__VA_ARGS__, 0)
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ World_update (World *w, vec3 position)
|
||||
|
||||
if (e->on_tick)
|
||||
{
|
||||
e->on_tick (e);
|
||||
e->on_tick (e, w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user