Let the free camera go anywhere, and make ground avoidance a switch that is off unless asked for.

The camera kept its height (only ZR and ZL changed it) and rose whenever the closest surface in the lower part of the view came within about three metres, so flying up to a character, a rock or a wall sent it upwards. It now moves where it looks and nothing stops it, the ground included.

Ground avoidance is a checkbox in the debug menu's free camera section. With it on, the nine view distances read back from the lower view become points of the scene (from the view's angles and the camera's pitch), and only a column whose lowest surface rises by less than about 30 degrees counts as ground: the camera goes no lower than a metre above it. Steeper things, objects and walls, are left alone. The read-back runs only while the switch is on.

Tested on a village save, 4 m/s forward for 5 s and then ZL for 4 s: with avoidance off the camera ended 17.4 m lower, through the floor; with it on it ended 0.7 m lower and held there. Flown at Link with the first version of the ground test, its height did not change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
epicmeme546
2026-11-12 12:07:56 -05:00
parent 81e7da91aa
commit 7581bb887d
5 changed files with 98 additions and 43 deletions

View File

@@ -1475,12 +1475,12 @@ static void hl_destroy(void) {
// The device is idle here. Release NGX features and parameters before their Vulkan resources, then shut down NGX even
// if initialization succeeded but the layout check failed. The Linux core's Shutdown1 takes an extra output pointer
// compared with the SDK's public wrapper; it reports the number of devices still using NGX.
// ---- the free camera's view of the ground (debug_tools.c dbg_pad). While it flies, nine of the view distances
// mv_pass wrote (a grid over the lower part of the view, where the ground is) go back to the host, and the camera rises
// where the closest is nearer than its clearance: flown through a hill, it showed the void below the map. A slot is
// read FC_SLOTS evaluations after its copy, when the GPU has long been past it.
// ---- the free camera's view of the ground (debug_tools.c dbg_pad, ground avoidance). While it flies with that on,
// nine of the view distances mv_pass wrote (a grid over the lower part of the view, where the ground is) go back to
// the host, which works out how far below the camera the ground is (ground_under). A slot is read FC_SLOTS evaluations
// after its copy, when the GPU has long been past it.
int dbg_freecam_flying(void); // debug_tools.c
void dbg_freecam_ground(const float *dist, int n);
void dbg_freecam_ground(const float *dist, int n, float tan_half_y, float aspect);
#define FC_N 9
#define FC_SLOTS 4
static VkBuffer fc_buf;
@@ -1510,7 +1510,8 @@ static void fcam_probe(VkCommandBuffer cb, const struct Size *e, uint32_t w, uin
uint32_t s = fc_next++ % FC_SLOTS;
if (fc_have[s]) {
vmaInvalidateAllocation(c->vma, fc_mem, s * FC_N * sizeof(float), FC_N * sizeof(float));
dbg_freecam_ground(fc_map + s * FC_N, FC_N);
dbg_freecam_ground(fc_map + s * FC_N, FC_N, D.fg_cam_ok ? tanf(0.5f * D.fg_cam.fov_y) : 0.0f,
D.fg_cam_ok ? D.fg_cam.aspect : 0.0f);
}
// the replay's viewports have negative heights: row 0 is the top of the view
static const float fx[3] = {0.2f, 0.5f, 0.8f}, fy[3] = {0.6f, 0.78f, 0.96f};