Skip to content

Bundle 1/6: camera and map view - #145

Merged
bssth merged 24 commits into
bssth:masterfrom
MortenLyhr:train/1-camera-map
Nov 23, 2026
Merged

bssth merged 24 commits into
bssth:masterfrom
MortenLyhr:train/1-camera-map

Conversation

@MortenLyhr

@MortenLyhr MortenLyhr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

This PR replaces 8 open PRs, merged here one by one with their own commits (each description stays on its PR, which links here once closed); the conflicts between them are resolved as on the branch we play daily. Merging it closes nothing automatically: each replaced PR will be closed with a link here.

PR What
#62 Camera: tilt, field of view and view centre as measured in the original
#129 City screen: the city where the original draws it
#83 Camera: the original's slight turn, Ctrl+Left/Right and Alt+F
#102 Camera: glide to where the game looks, as the original's
#69 Resource layer: the original's bubbles on pins
#109 City screen: no units, flags, city bars or resource bubbles on the map
#99 Map: a changed improvement or road no longer stalls the window
#64 City bar: the original's art, layout, placement and size at every zoom

Commits of this bundle's own (on top of the merges):

Checks: macOS build (Release), ctest 13/13 passed; sync checksums --turns 100 --map Fractal --size STANDARD --seed 7 at turn 100 equal master's (D7D43800). Windows: this PR's CI.

A resource bubble keeps its side near the screen's middle (2026-11-22, 02f6067f)

A bubble stands left of its plot on the screen's left half and right of it on the right half. A plot at the very middle (the camera centred on it, as when the camera glides out of a city's screen) sat within a thousandth of a pixel of the middle, and its bubble jumped sides with every frame's rounding (84 times in one test run). Now each bubble keeps its side until its plot is 2% of the screen's width past the middle. Bundles 2–4 re-merged on top (fast-forward); ctest 13/13, checksum D7D43800.

Alt+F's message: source re-checked in the running game (2026-11-22, 2546ca2c)

#83 had taken Alt+F's two message lines from strings on the original's exe, against CONTRIBUTING. They were checked in the running game under Wine instead (pressed and filmed; see #83's added section): the same two lines, as an event message for about 10 s, and no TXT_KEY holds them. No code change; the comment names the new source. Bundles 2–6 restacked on top by merges. ctest 13/13 on #145 (14/19/21/22 on the bundles above), sync checksum at turn 100 D7D43800 on all six, as before.

🤖 Generated with Claude Code

MortenLyhr and others added 22 commits November 19, 2026 13:49
Measured in BtS 3.19 (Wine) with CyCamera at 19 zoom levels and the plot
grid at two window sizes:
- Tilt: about CAMERA_LOWER_PITCH + 1.8 (29.8 degrees) up to 1.3 x
  CAMERA_MIN_DISTANCE, then quadratic with the distance to straight down at
  0.86 x CAMERA_SMALLEST_MAX_DISTANCE (within 0.15 degrees). At the start
  distance that is 33.6 degrees, where the straight line gave 42.8.
- FIELD_OF_VIEW is across the screen's diagonal: plots 206 px apart at
  1600x900 and 170 at 1200x900 at the same camera; it was taken as the
  horizontal angle (168 px).
- What the camera looks at is drawn 56.9% of the way up the window
  (CyCamera().GetDefaultViewPortCenter() = (0.5, 0.569)), not in the middle.
  Camera::projection shifts the perspective so the renderer and picking agree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The city bar is drawn from the game's CityBar.nif layout and textures:
the banner (CityBar_Base) with the growth and production bars in its
halves, the capital's star or the circle in the population's colour,
the production symbol (what the city builds, else the cancel button,
cut round by ProductionIconMask under ProductionIconBevel) for the
active team's cities, the name and what it builds in the banner's
halves, and buildCityBillboardIconString's icons above it.

It is placed and sized as the original's CITYBILLBOARD faders
(CIV4DetailManager) place it, measured in the original at camera
distances of 12 to 102 plots: out from the city towards the bottom of
the screen and raised, its size levelling off at 0.67. It is no longer
hidden beyond 45 plots, and a click on it is a click on its city (the
city screen opens), over any unit figure under it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…LLBOARD_RADIUS

The size came from a fit to zooms from the start view out, which grew
without end closer in. It is now the star's width as measured in the
original at 5 to 102 plots (1.39 points a model unit up close to 0.69 far
out). The bar's top sits on the ground south of the city by
CITYBILLBOARD_RADIUS (90 units up close, no closer than 70), as the
original's plot grid shows, not twice that and raised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onIcon

The host may call only the game core's exports on Windows: the order
queue and GC's info getters are not, so the Windows build did not link.
getCityBillboardProductionIcon is the engine's own call for the symbol:
the player's button for a unit, and INTERFACE_BUTTONS_NOPRODUCTION when
nothing is built (as the original shows), not the cancel button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the resource layer on, each resource is shown as the original's plot
picker draws it: the resource's button cut to a circle in a black disc with
a light bevelled rim, on a pale pin whose tip is the plot. The bubble keeps
its size at every zoom and stands up and away from the middle of the screen
(left of its plot on the left half, right of it on the right half), so it
moves to the other side as the view passes over it. Farther bubbles are
drawn first, and the layer shows at every camera height, as in the original;
the yield and unit icon layers keep their distance limit.

Measured against Beyond the Sword under Wine at 1600x900: disc 51 px, pin
tip 29 px across and 31 px down from the disc's centre.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original turns its camera a little east of south, more the closer it is:
4.17 degrees x s^2, s the share of the way from 0.86 x CAMERA_SMALLEST_MAX_DISTANCE
in to 1.3 x CAMERA_MIN_DISTANCE (2.3 degrees at the start distance), measured
with CyCamera().GetCurrentPosition at 13 zooms and a fit of the camera to the
plot grid in its picture (turned towards the target, not moved aside).

Ctrl+Left/Right (CONTROL_ISOMETRIC_CAMERA_LEFT/RIGHT -> MoveBaseTurnLeft/Right)
turn the view 45 degrees each way, no further than CAMERA_MIN/MAX_YAW, on top of
the zoom's turn; Alt+F (CONTROL_TOP_DOWN_CAMERA -> SetSatelliteMode) looks
straight down, north up, with the original's message. The camera glides there
as the original's (the rest left shrinks by e^-5.2 a second). CyCamera's
Get/SetBaseTurn, MoveBaseTurnLeft/Right and Get/SetBasePitch (tilts the view
up) work. Ctrl+arrows no longer pan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eft turns the camera)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original draws the resource bubbles in the plots' order, south to north
and west to east, so where bubbles crowd (seen from far away) the farther and
the more easterly one covers its neighbour, its pin included. It doesn't push
them aside: they overlap at every zoom. bssth#69's first commit drew nearer bubbles
over farther ones; now the order is the original's.

Checked against Beyond the Sword under Wine at seven zooms (0.25 to 0.85) on a
row, a column, a 3x3 block, a 2x2 and pairs of wheat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Whenever a plot's improvement, road or resource changed (a worker's
farm done, an AI worker's road, a mine becoming worked), the map was
rebuilt in a way that held the window for most of a second (850 ms on a
small map): the trees were cut again for every river, each tree point
tested against every triangle of the river pieces, and the culture
borders were drawn again because the river mask was always marked
changed. During the other civilizations' turns that happened after
almost every tenth of a second of their play, so zoom, scroll, the
minimap and clicks did not answer until their turns were over.

Each river piece now has a grid of its placed triangles, and a point is
tested only against those in its cell, in the same order: the same
answer (checked on every test on a play-test save and the test map),
13 ms instead of 760. The river mask is marked changed only when it
changed. A rebuild now takes about 35 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The next unit, a city chosen and a left click on the map moved the camera there at once.
The original glides: the rest of the way shrinks by about e^-6 a second (no easing in, most
of it in the first half second), and from farther than CAMERA_MAX_TRAVEL_DISTANCE (3000,
16.7 plots) it jumps. Measured in Wine (a film of the window at 120 fps): 1-14 plots glide,
17 and more jump; a click on the map, on a unit or on bare ground, glides to that plot; a
click on the minimap jumps (unchanged here).

A drag, the keys or the minimap meanwhile leave the camera where it is; a scripted --look
keeps its view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
windows-x64 failed with C2513 on 'const float far': windef.h defines far (and near) as
nothing. Renamed to jumpDistance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While a city's screen is up the original shows no units on the map (own,
foreign or barbarian), so no flags and health bars either, no city bars
(the selected city's and the others'), and no resources' bubbles even with
the resource layer on. The cities, signs, worked plots and yields stay.
Checked in Wine with a test city that had all of these in its radius.

MapView::Options::cityScreen (set from MapWindow's city view each frame)
skips the units' figures, promotion glows, selection rings, flags and
health bars, and the overlay of flags and city bars; MapWindow::drawLayers
skips the resources' bubbles and the units' icons in the city view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The map view draws what the camera looks at 0.569 up the window (the
original's default viewport centre). The original's city screen draws its
city lower, 0.534 up (measured in Wine: 419 px from the top at 1600x900,
467 at 1280x1000; the camera straight above the city at
CAMERA_CITY_ZOOM_IN_DISTANCE). At 0.569 the fat cross's top row went under
the city screen's top panel. The view centre now glides along with the
camera into the city screen and out again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in View

bssth#129 makes the city screen's View with its screen centre last; bssth#83 adds a field 'turn' before
it. They merge without a conflict, but the centre then lands in 'turn': the view now names both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MortenLyhr and others added 2 commits November 22, 2026 09:54
A resource's bubble stands left of its plot on the left half of the screen and
right of it on the right half. A plot at the very middle of the screen (the
camera centred on it, as when it glides into or out of a city's screen on that
city) is within a thousandth of a pixel of the middle in every frame, on
either side by rounding: its bubble jumped from side to side with each frame
of the glide (84 times in one test run: Roma with stone, its screen opened and
closed).

Each plot's bubble now keeps the side it stands on from frame to frame and
goes over only when its plot is clearly past the middle: 2% of the screen's
width (32 px at 1600). Elsewhere the bubbles stand as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two lines and where and how long they show were checked in the original
under Wine (2026-11-22): Alt+F pressed on and off, filmed; the line is an
event message at the top for about 10 s (EVENT_MESSAGE_TIME). No TXT_KEY in
the game's text has it. The code was right; its comment named the wrong source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bssth
bssth merged commit 63a5e36 into bssth:master Nov 23, 2026
3 checks passed
@bssth

bssth commented Nov 23, 2026

Copy link
Copy Markdown
Owner

src/render/MapView.cpp:3874/3982: m->cityBars.clear() runs only after the early return in drawOverlay. On the city screen (or with banners off) cityBarAt() keeps matching last frame's rectangles, so clicking the plots under the city's old bar opens the city instead of working the tile. Clear cityBars before the early return.

Also please move the history out of the comments at MapWindow.cpp:298-304 and MapView.cpp:2266-2267 (CONTRIBUTING: no change history in comments).

@MortenLyhr

Copy link
Copy Markdown
Contributor Author

Thanks, fixed in #166: cityBars is now cleared before the early return in drawOverlay, and the two history comments are trimmed.

🤖 Generated with Claude Code

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