Normalized some stuff
This commit is contained in:
parent
2cef922233
commit
dcca92ee43
20
terrain.c
20
terrain.c
@ -59,7 +59,7 @@
|
|||||||
#define CHUNKSCALE (1.0 / CHUNKSIZE)
|
#define CHUNKSCALE (1.0 / CHUNKSIZE)
|
||||||
// This is how many vertices across a chunk is
|
// This is how many vertices across a chunk is
|
||||||
#define CHUNKVSIZE (CHUNKSIZE + 1)
|
#define CHUNKVSIZE (CHUNKSIZE + 1)
|
||||||
#define VIEWDISTANCE 11
|
#define VIEWDISTANCE 10
|
||||||
#define PLBOXEDGE (VIEWDISTANCE * 2 + 1)
|
#define PLBOXEDGE (VIEWDISTANCE * 2 + 1)
|
||||||
#define INIT_NEARCLIP 0.01
|
#define INIT_NEARCLIP 0.01
|
||||||
#define INIT_FARCLIP 100.0
|
#define INIT_FARCLIP 100.0
|
||||||
@ -85,8 +85,8 @@
|
|||||||
#define INIT_LIGHTPITCH (MPI_2 * 1.65)
|
#define INIT_LIGHTPITCH (MPI_2 * 1.65)
|
||||||
#define INIT_LIGHTYAW (MPI_2 * 0.65)
|
#define INIT_LIGHTYAW (MPI_2 * 0.65)
|
||||||
#define INIT_MINLIGHT 0.2
|
#define INIT_MINLIGHT 0.2
|
||||||
#define INIT_DITHERSTART 3.5
|
#define INIT_DITHEREND (VIEWDISTANCE - 1.0)
|
||||||
#define INIT_DITHEREND (VIEWDISTANCE - 1.5)
|
#define INIT_DITHERSTART (INIT_DITHEREND * 0.33)
|
||||||
#define MAXTREEPERCELL 9
|
#define MAXTREEPERCELL 9
|
||||||
#define MAXTREEACROSS 3
|
#define MAXTREEACROSS 3
|
||||||
#define MAXTREECLOSENESS 0.2
|
#define MAXTREECLOSENESS 0.2
|
||||||
@ -117,9 +117,6 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model,
|
|||||||
haloo3d_obj *tree = haloo3d_easystore_getobj(storage, TREEKEY);
|
haloo3d_obj *tree = haloo3d_easystore_getobj(storage, TREEKEY);
|
||||||
// Don't allow the model to have more than some amount of faces/vertices.
|
// Don't allow the model to have more than some amount of faces/vertices.
|
||||||
haloo3d_obj_resetfixed(model, H3D_OBJ_MAXFACES, H3D_OBJ_MAXVERTICES);
|
haloo3d_obj_resetfixed(model, H3D_OBJ_MAXFACES, H3D_OBJ_MAXVERTICES);
|
||||||
// CHUNKVSIZE * CHUNKVSIZE * 32,
|
|
||||||
// CHUNKVSIZE * CHUNKVSIZE * 32);
|
|
||||||
// if (rand() & 3) return;
|
|
||||||
struct vec3 landcol = haloo3d_gen_paletteuv(LANDCOL); // 0xF2C0);
|
struct vec3 landcol = haloo3d_gen_paletteuv(LANDCOL); // 0xF2C0);
|
||||||
int landuv = haloo3d_obj_addvtexture(model, landcol);
|
int landuv = haloo3d_obj_addvtexture(model, landcol);
|
||||||
fnl_state ns = fnlCreateState();
|
fnl_state ns = fnlCreateState();
|
||||||
@ -134,7 +131,6 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model,
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
haloo3d_obj_addvertex(model,
|
haloo3d_obj_addvertex(model,
|
||||||
(struct vec4){.x = x, .y = fnlGetNoise2D(&ns, noisex + x, noisey + z), .z = -z, .w = 1 });
|
(struct vec4){.x = x, .y = fnlGetNoise2D(&ns, noisex + x, noisey + z), .z = -z, .w = 1 });
|
||||||
//(struct vec4){.x = x, .y = 2 * RANDF() - 1, .z = -z});
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,7 +161,6 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model,
|
|||||||
// ns.seed = 0;
|
// ns.seed = 0;
|
||||||
ns.frequency = 0.02;
|
ns.frequency = 0.02;
|
||||||
ns.fractal_type = FNL_FRACTAL_NONE;
|
ns.fractal_type = FNL_FRACTAL_NONE;
|
||||||
// Generate up to 4 trees per cell (usually not)
|
|
||||||
for (int t = 0; t < MAXTREEPERCELL; t++) {
|
for (int t = 0; t < MAXTREEPERCELL; t++) {
|
||||||
// We know that the first vec in the first triangle is bl, which is our
|
// We know that the first vec in the first triangle is bl, which is our
|
||||||
// base to start generating trees
|
// base to start generating trees
|
||||||
@ -217,7 +212,7 @@ void gen_cloud(render_context *ctx, tecs *ecs, struct vec3i pos) {
|
|||||||
.up = DEFAULTUP,
|
.up = DEFAULTUP,
|
||||||
.lookvec = DEFAULTLOOK,
|
.lookvec = DEFAULTLOOK,
|
||||||
.pos = {
|
.pos = {
|
||||||
.x = pos.x + RANDF(), .y = CLOUDHEIGHT + 1.0 * RANDF(), .z = pos.z}};
|
.x = pos.x + RANDF(), .y = CLOUDHEIGHT + 0.5 * RANDF(), .z = pos.z}};
|
||||||
ECS_SETCOMPONENT(ecs, cloudid, ecs_object){
|
ECS_SETCOMPONENT(ecs, cloudid, ecs_object){
|
||||||
.flatdither = CLOUDTRANSMIN + (CLOUDTRANSMAX - CLOUDTRANSMIN) * RANDF(),
|
.flatdither = CLOUDTRANSMIN + (CLOUDTRANSMAX - CLOUDTRANSMIN) * RANDF(),
|
||||||
.texture = haloo3d_easystore_gettex(&ecs->storage, PALETTEKEY),
|
.texture = haloo3d_easystore_gettex(&ecs->storage, PALETTEKEY),
|
||||||
@ -275,7 +270,7 @@ void player_chunkload(ecs_placement *ppos, render_context *ctx, tecs *ecs) {
|
|||||||
// Find + iterate over killable objects placed in world
|
// Find + iterate over killable objects placed in world
|
||||||
int mcount = tecs_query(
|
int mcount = tecs_query(
|
||||||
ecs, ecs_playergarbage_fl | ecs_placement_fl | ecs_object_fl, matches);
|
ecs, ecs_playergarbage_fl | ecs_placement_fl | ecs_object_fl, matches);
|
||||||
// eprintf("KILLABLE OBJS: %d PCHUNK: %d,%d\n", mcount, pchunk.x, pchunk.y);
|
int lostobjects = 0;
|
||||||
for (int i = 0; i < mcount; i++) {
|
for (int i = 0; i < mcount; i++) {
|
||||||
ecs_placement *placement =
|
ecs_placement *placement =
|
||||||
&ECS_GETCOMPONENT(ecs, matches[i], ecs_placement);
|
&ECS_GETCOMPONENT(ecs, matches[i], ecs_placement);
|
||||||
@ -286,6 +281,7 @@ void player_chunkload(ecs_placement *ppos, render_context *ctx, tecs *ecs) {
|
|||||||
fabs(floor(placement->pos.z) - pchunk.z) > VIEWDISTANCE) {
|
fabs(floor(placement->pos.z) - pchunk.z) > VIEWDISTANCE) {
|
||||||
// OK, reduce the chunk refcount, since we're no longer close to it
|
// OK, reduce the chunk refcount, since we're no longer close to it
|
||||||
obj->contextcount--;
|
obj->contextcount--;
|
||||||
|
lostobjects++;
|
||||||
}
|
}
|
||||||
// This is specifically a chunk, it might be within our view radius.
|
// This is specifically a chunk, it might be within our view radius.
|
||||||
if (ECS_HASCOMPONENT(ecs, matches[i], ecs_chunk)) {
|
if (ECS_HASCOMPONENT(ecs, matches[i], ecs_chunk)) {
|
||||||
@ -298,6 +294,9 @@ void player_chunkload(ecs_placement *ppos, render_context *ctx, tecs *ecs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (lostobjects) {
|
||||||
|
eprintf("KILLABLE OBJS: %d PCHUNK: %d,%d\n", mcount, pchunk.x, pchunk.y);
|
||||||
|
}
|
||||||
int chunkgen = 0;
|
int chunkgen = 0;
|
||||||
// We now have our view radius box and which chunks are not loaded. Up to
|
// We now have our view radius box and which chunks are not loaded. Up to
|
||||||
// some amount, let's load them
|
// some amount, let's load them
|
||||||
@ -307,7 +306,6 @@ void player_chunkload(ecs_placement *ppos, render_context *ctx, tecs *ecs) {
|
|||||||
int surz = z - pchunk.z + VIEWDISTANCE;
|
int surz = z - pchunk.z + VIEWDISTANCE;
|
||||||
if (!surround[surz][surx]) {
|
if (!surround[surz][surx]) {
|
||||||
gen_chunk(ctx, ecs, (struct vec3i){.x = x, .y = 0, .z = z});
|
gen_chunk(ctx, ecs, (struct vec3i){.x = x, .y = 0, .z = z});
|
||||||
//.y = pchunk.y - VIEWDISTANCE + y});
|
|
||||||
if (++chunkgen >= MAXCHUNKPERFRAME) {
|
if (++chunkgen >= MAXCHUNKPERFRAME) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user