Skip to content

standalone: add --viewer-height to add observer height above DEM ground - #4

Open
thannart wants to merge 1 commit into
dkogan:masterfrom
thannart:add-viewer-height
Open

thannart wants to merge 1 commit into
dkogan:masterfrom
thannart:add-viewer-height

Conversation

@thannart

@thannart thannart commented Sep 3, 2026

Copy link
Copy Markdown

Lets you account for the fact that the viewer isn't standing at ground level (e.g. an apartment floor), by reusing horizonator_move() to reposition the camera at ground_elevation + viewer_height after the usual auto-selected ground elevation is computed.

Lets you account for the fact that the viewer isn't standing at ground
level (e.g. an apartment floor), by reusing horizonator_move() to
reposition the camera at ground_elevation + viewer_height after the
usual auto-selected ground elevation is computed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dkogan

dkogan commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Hi. Thanks for the patch. If we're going to do this, I'd like to do a little bit better. Instead of an extra call to horizonator_move(), can we update the APIs for horizonator_move() and horizonator_init(), to allow this the height to be given in respect to the DEM instead of in absolute terms? Currently we have:

bool horizonator_init( // output
                       horizonator_context_t* ctx,

                       // input
                       float viewer_lat, float viewer_lon,
                       // output/input
                       // if viewer_z==NULL, auto-select a value; if *viewer_z >=
                       // 0, use that; if *viewer_z < 0, auto-select a value, and
                       // report it here
                       float* viewer_z,
                       int offscreen_width, int offscreen_height,
                       int render_radius_cells, // This should be given >0
                       float render_radius_m,   // or this, but not both

                       bool use_glut,
                       bool render_texture,
                       bool SRTM1,
                       const char* dir_dems,
                       const char* dir_tiles,
                       const char* tiles_name,
                       const char* tiles_url_fmt,
                       bool allow_downloads);
bool horizonator_move(horizonator_context_t* ctx,
                      // output/input
                      // if viewer_z==NULL, auto-select a value; if *viewer_z >=
                      // 0, use that; if *viewer_z < 0, auto-select a value, and
                      // report it here
                      float* viewer_z,
                      // input
                      float viewer_lat, float viewer_lon);

Among other things, this API breaks below sea level. Can you update the code to use this API instead?

bool horizonator_init( // output
                       horizonator_context_t* ctx,
                       // if non-NULL, report the elevation of the DEM here
                       float* viewer_z_dem,

                       // input
                       float viewer_lat, float viewer_lon,
                       float viewer_z, // either above sea level, or above the
                                       // DEM, depending on the next argument
                       bool viewer_z_is_given_above_dem,
                       int offscreen_width, int offscreen_height,
                       int render_radius_cells, // This should be given >0
                       float render_radius_m,   // or this, but not both

                       bool use_glut,
                       bool render_texture,
                       bool SRTM1,
                       const char* dir_dems,
                       const char* dir_tiles,
                       const char* tiles_name,
                       const char* tiles_url_fmt,
                       bool allow_downloads);
bool horizonator_move(// output
                      horizonator_context_t* ctx,
                      // if non-NULL, report the elevation of the DEM here
                      float* viewer_z_dem,
                      // input
                      float viewer_lat, float viewer_lon,
                      float viewer_z, // either above sea level, or above the
                                      // DEM, depending on the next argument
                      bool viewer_z_is_given_above_dem);

Seems reasonable? Then the default usages would pass viewer_z=0, viewer_z_is_give_above_dem=true. And YOU could pass larger viewer_z.

And if you make frontend changes, can you please modify the standalone.c and horizonator.cc? Let me know if that sounds reasonable. Thanks

@dkogan

dkogan commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Can you also update the python API to use this interface update? horizonator-pywrap.c and the two .docstring files. Let me know if that makes sense. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants