From a472e6af52e1b35ab64482c6a3f04441aa992676 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Tue, 11 Mar 2025 01:28:08 +0300 Subject: [PATCH] /apps/demos/scenery: simpler normal_at(), clean one bit --- apps/demos/scenery/scenes/ingame.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/apps/demos/scenery/scenes/ingame.c b/apps/demos/scenery/scenes/ingame.c index 3fbe6f7..9e743f6 100644 --- a/apps/demos/scenery/scenes/ingame.c +++ b/apps/demos/scenery/scenes/ingame.c @@ -332,10 +332,10 @@ static Vec3 normal_at(SceneIngame *scn, Vec2 position) { float const height1 = heightmap[x + 1][y]; float const height2 = heightmap[x][y + 1]; - Vec3 const a = { .x = -1, .y = height0 - height1, .z = 0 }; + Vec3 const a = { .x = 1, .y = height0 - height1, .z = 0 }; Vec3 const b = { .x = 0, .y = height0 - height2, .z = -1 }; - return vec3_scale(vec3_norm(vec3_cross(a, b)), -1); + return vec3_norm(vec3_cross(a, b)); } /* TODO: don't operate on triangles, instead interpolate on quads */ @@ -531,12 +531,8 @@ static void ingame_tick(State *state) { input_action("mouse_capture_toggle", "ESCAPE"); input_action("toggle_camera_mode", "C"); - // draw_model("models/test.obj", (Vec3){0}, (Vec3){0,0,1}, (Vec3){1.f / 64,1.f / 64,1.f / 64}); - // draw_model("models/test2.obj", (Vec3){0}, (Vec3){0,0,1}, (Vec3){1.f / 64,1.f / 64,1.f / 64}); - // draw_model("models/bunny.obj", (Vec3){0}, (Vec3){0,0,1}, (Vec3){4.,4.,4.}); - if (scn->mouse_captured) { - const float sensitivity = 0.4f * (float)DEG2RAD; /* TODO: put this in a better place */ + const float sensitivity = 0.4f * (float)(M_PI / 180); /* TODO: put this in a better place */ scn->yaw += (float)ctx.mouse_movement.x * sensitivity; scn->pitch -= (float)ctx.mouse_movement.y * sensitivity; scn->pitch = clampf(scn->pitch, (float)-M_PI * 0.49f, (float)M_PI * 0.49f);