commit e73ab2ac56a742e586fb72efa6934a750d846565
parent 391fcac1c8c55d0eb6c2205adbb11c03bf377cce
Author: William Casarin <jb55@jb55.com>
Date: Mon, 30 Apr 2018 08:48:31 -0700
get terrain updates working again
Diffstat:
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -13,8 +13,8 @@ mat4 *cam_init = (float[16]){
void game_init(struct game *game) {
mat4 *mvp = game->test_resources.test_mvp;
struct node *camera = &game->test_resources.camera;
- mat4 *terrain = game->test_resources.terrain_node;
struct node *player = &game->test_resources.player;
+ struct node *terrain_node = &game->test_resources.terrain_node;
mat4 *light_dir = game->test_resources.light_dir;
mat4_id(mvp);
@@ -25,6 +25,7 @@ void game_init(struct game *game) {
node_init(player);
node_init(camera);
+ node_init(terrain_node);
/* vec3_all(camera->scale, -1); */
camera->mirrored = 1;
@@ -39,9 +40,7 @@ void game_init(struct game *game) {
/* mat4_copy(cam_init, camera); */
/* mat4_id(camera_pos); */
- mat4_id(terrain);
-
- terrain[M_Z] = 20.0;
+ terrain_node->pos[2] = 20.0;
/* mat4_scale(player, V3(0.36,0.36,PLAYER_HEIGHT), player); */
diff --git a/src/game.h b/src/game.h
@@ -32,8 +32,8 @@ struct resources {
struct node player;
struct node camera;
+ struct node terrain_node;
- float terrain_node[MAT4_ELEMS];
float normal_matrix[MAT4_ELEMS];
float test_mvp[MAT4_ELEMS];
float light_dir[3];
diff --git a/src/node.c b/src/node.c
@@ -39,6 +39,7 @@ int node_recalc(struct node *node) {
if (node->scale[0] != 1 || node->scale[1] != 1 || node->scale[2] != 1)
mat4_scale(node->mat, node->scale, node->mat);
+ //seomthing
float m = node->mirrored ? -1 : 1;
// FIXME: this seems bad?
diff --git a/src/update.c b/src/update.c
@@ -60,7 +60,7 @@ void update (struct game *game, u32 dt) {
static int stopped = 0;
struct perlin_settings *ts = &game->terrain->settings;
float player_prev[MAT4_ELEMS];
- float *tnode = game->test_resources.terrain_node;
+ struct node *tnode = &game->test_resources.terrain_node;
float *light = res->light_dir;
if (first) {
@@ -74,7 +74,7 @@ void update (struct game *game, u32 dt) {
/* mat4_multiply(res->player, res->ca era, res->player); */
}
if (game->input.modifiers & KMOD_LCTRL) {
- /* movement(game, res->terrain_node); */
+ movement(game, &res->terrain_node);
/* mat4_multiply(res->player, res->ca era, res->player); */
}
else {
@@ -120,21 +120,21 @@ void update (struct game *game, u32 dt) {
} else {
passed = 0;
- double ox = tnode[12];
- double oy = tnode[13];
+ double ox = tnode->pos[0];
+ double oy = tnode->pos[1];
- bool changed = last_ox != ox || last_oy != oy || last_oz != tnode[14];
+ bool changed = last_ox != ox || last_oy != oy || last_oz != tnode->pos[2];
if (!stopped && changed) {
- for (int i = 12; i < 14; ++i)
- tnode[i] = max(tnode[i], 0);
+ for (int i = 0; i < 2; ++i)
+ tnode->pos[i] = max(tnode->pos[i], 0);
- last_oz = tnode[14] = max(tnode[14], 20.0);
+ last_oz = tnode->pos[2] = max(tnode->pos[2], 20.0);
- double scale = tnode[14] * 0.01;
+ double scale = tnode->pos[2] * 0.01;
if (scale == 0) scale = 1.0;
- printf("terrain %f %f %f\n", tnode[12], tnode[13], tnode[14]);
+ printf("terrain %f %f %f\n", tnode->pos[0], tnode->pos[1], tnode->pos[2]);
last_ox = ts->ox = ox;
last_oy = ts->oy = oy;