commit 7ab896e9ceb94396729001b4123abc3773a39ec6
parent 6606ae2389598374120f2198bbd14fd61a1b1414
Author: William Casarin <jb55@jb55.com>
Date: Sat, 6 Jul 2019 17:50:06 -0700
laptop tweaks
Diffstat:
9 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -12,6 +12,7 @@
#include "stb_image.h"
#include "skybox.h"
#include "quickhull.h"
+#include "poisson.h"
#include "procmesh.h"
#include "util.h"
@@ -109,23 +110,23 @@ void game_init(struct game *game, int width, int height) {
assert(sun_camera);
mat4 *light_dir = res->light_dir;
- int ok = 0;
game->quit = 0;
game->frame = 0;
const double size = 10000.0;
+ double scale = 0.03;
terrain->settings = (struct perlin_settings){
.depth = 1,
- .freq = 0.02,
+ .freq = scale * 0.08,
.o1 = 2.0, .o1s = 0.5,
.o2 = 4.0, .o2s = 0.25,
- .amplitude = 1.0,
+ .amplitude = 70.0,
.ox = 0,
.oy = 0,
.exp = 5.3,
- .scale = 1.0
+ .scale = scale
};
create_ui(&game->ui, width, height, &res->programs[UI_PROGRAM]);
@@ -133,8 +134,10 @@ void game_init(struct game *game, int width, int height) {
check_gl();
init_terrain(terrain, size);
- create_terrain(terrain, size);
- update_terrain(terrain);
+ int seed;
+ terrain->samples = load_samples(&seed, &terrain->n_samples);
+ create_terrain(terrain, size, game->seed);
+ /* update_terrain(terrain); */
/* get_entity(&terrain->entity_id)->flags |= ENT_INVISIBLE; */
diff --git a/src/main.c b/src/main.c
@@ -4,6 +4,7 @@
#include "fbo.h"
#include "file.h"
#include "game.h"
+#include "debug.h"
#include "geometry.h"
#include "gl.h"
#include "hires.h"
@@ -30,6 +31,7 @@ int main(void)
int nsamples;
int seed = time(NULL);
+ debug("seed %d\n", seed);
srand(seed);
struct game game;
diff --git a/src/node.c b/src/node.c
@@ -41,7 +41,7 @@ void destroy_node(node_id *id)
void init_node_manager()
{
- init_resource_manager(&node_manager, sizeof(struct node), 128,
+ init_resource_manager(&node_manager, sizeof(struct node), 4096,
0xFFFF, "node", N_STATIC_NODES);
for (int i = 0; i < N_STATIC_NODES; i++)
diff --git a/src/resource.c b/src/resource.c
@@ -204,7 +204,7 @@ void *get_resource(struct resource_manager *r, struct resource_id *id) {
enum refresh_status res = refresh_id(r, id, id);
if (res == RESOURCE_DELETED) {
- unusual("getting deleted %s resource %llu\n", r->name, id->uuid);
+ /* unusual("getting deleted %s resource %llu\n", r->name, id->uuid); */
return NULL;
}
@@ -237,8 +237,8 @@ void destroy_resource(struct resource_manager *r, struct resource_id *id) {
return;
}
- debug("destroying %s resource %llu ind %d res_count %d\n",
- r->name, id->uuid, id->index, r->resource_count);
+ /* debug("destroying %s resource %llu ind %d res_count %d\n", */
+ /* r->name, id->uuid, id->index, r->resource_count); */
r->resource_count--;
assert(r->resource_count >= r->static_elems);
diff --git a/src/scene.c b/src/scene.c
@@ -60,6 +60,7 @@ void entity_test_scene(struct game *game)
struct geometry *geom = get_geometry(&pmodel->geom_id); assert(geom);
proc_sphere(geom);
+ for (int i = 0; i < 5; i++) {
struct entity *ent = new_entity(NULL);
struct node *node = get_node(&ent->node_id);
diff --git a/src/terrain.c b/src/terrain.c
@@ -82,6 +82,8 @@ double offset_fn(struct terrain* terrain, double x, double y) {
}
void gen_terrain_samples(struct terrain *terrain, float scale) {
+
+ debug("generating terrain samples\n");
if (terrain->samples)
free(terrain->samples);
@@ -102,15 +104,18 @@ void gen_terrain_samples(struct terrain *terrain, float scale) {
terrain->samples = samples;
terrain->n_samples = n_samples;
+
}
-void create_terrain(struct terrain *terrain, float scale) {
+void create_terrain(struct terrain *terrain, float scale, int seed) {
u32 i;
const double size = terrain->size;
float tmp1[3], tmp2[3];
- if (!terrain->n_samples)
+ if (!terrain->n_samples) {
gen_terrain_samples(terrain, scale);
+ /* save_samples(terrain->samples, seed, terrain->n_samples); */
+ }
assert(terrain->n_samples > 0);
del_point2d_t *points = calloc(terrain->n_samples, sizeof(*points));
@@ -236,6 +241,7 @@ void create_terrain(struct terrain *terrain, float scale) {
free(del_verts);
free(del_norms);
free(del_indices);
+
}
@@ -292,5 +298,5 @@ void update_terrain(struct terrain *terrain) {
}
last_scale = scale;
- create_terrain(terrain, scale);
+ create_terrain(terrain, scale, 0);
}
diff --git a/src/terrain.h b/src/terrain.h
@@ -36,7 +36,7 @@ void update_terrain(struct terrain *terrain);
void gen_terrain_samples(struct terrain *terrain, float scale);
void init_terrain(struct terrain *terrain, float size);
void reset_terrain(struct terrain *terrain, float size);
-void create_terrain(struct terrain *terrain, float scale);
+void create_terrain(struct terrain *terrain, float scale, int seed);
void destroy_terrain(struct terrain *terrain);
diff --git a/src/update.c b/src/update.c
@@ -352,7 +352,7 @@ void update (struct game *game) {
gravity(game);
if (needs_terrain_update) {
- update_terrain(terrain);
+ /* update_terrain(terrain); */
needs_terrain_update = 0;
}
diff --git a/test/test_scene.c b/test/test_scene.c
@@ -17,7 +17,7 @@ void delete_every_other_entity()
u32 count;
entity_id *ids;
- for (u32 i = 0; i < 1000; i++) {
+ for (u32 i = RESERVED_ENTITIES; i < 1000; i++) {
get_all_entities(&count, &ids);
if (i >= count)