18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-03 10:05:23 +01:00
Commit Graph

23 Commits

Author SHA1 Message Date
maj00r 7f42a1642a refactor(render): the section walks of the local lights and of the texture read-ahead in helpers of their own
Sonar's quality gate of #603 failed on its maintainability rating: the loops over the sections changed there for
the unbounded region sit in two functions of a cognitive complexity of 51 (local_lights::gather) and 73
(opengl46_renderer::Update_Texture_Prefetch). The walk of the lights goes to gather_scenery() and gather_section(),
the read-ahead to Prefetch_Cell(), Prefetch_Instances(), Prefetch_Vehicles(), Prefetch_Material() and
Prefetch_Model(), the lambdas becoming member functions. The code moved, it didn't change: the same sections, cells,
instances and textures in the same order.

Checked in the game (--test 120 s, seed 1): the physics logs of td.scn and Glinojeck.scn the same bit for bit.
2026-12-03 03:25:03 +01:00
maj00r 774a736acc feat(scene): world.unbounded, a region reaching as far as its nodes do instead of ending at +-250 km
Step 3b of docs/world-format-eu07.md (#516, section 13), on the map of sections of step 3a. With
world.unbounded 1 in eu07.ini (off by default; then nothing changes) the region keeps sections wherever the
nodes are: point_inside() takes any finite point, section() no longer puts a point beyond the classic square
into the section at its edge, and the walks of the renderer, the local lights and sections() go over the rows
and columns around the camera with no cut at 0 and 499 (region_index_low/high, section_in_region).

The binary files index only the classic square, so a scenery reaching beyond it gets no .sbt (the log says so)
and a terrain file beyond it no .btf. An unbounded region reads and writes its own binary files,
.unbounded.sbt and .unbounded.btf: a file made with the region ending at +-250 km has the nodes beyond left
out or put at the edge, and must not stand in for them, nor the other way round. For a scenery within the
square the two files come out byte for byte the same.

Checked in the game (--test 120 s, seed 1): td.scn with the switch on gives the same physics log bit for bit as
without it; a copy of td.scn moved 400 km out (origin 400000 0 0) gives with the switch on the same physics
log as td.scn at its own place, with 16 lines in the error log against 301 with the switch off, where it runs
as before.
2026-12-02 23:44:05 +01:00
maj00r 602b0bdcf7 refactor(scene): the region keeps its sections in a map by row and column, not in a grid of 500 x 500
Step 3a of docs/world-format-eu07.md (#516, section 13): the dense std::array of 250 000 section pointers
gives way to a std::map keyed by section_key (row and column, counted as before with the middle of the region
at 250, 250), holding only the sections that hold something. The map runs row by row, the order of the index
of the classic square, so the .sbt and .btf files keep their indices and come out byte for byte the same.

basic_region gains find_section(key or row and column) and all_sections(); get_section(index) stays for the
classic index. The renderer's walk, its prefetch and memory count, the local lights, the map, the terrain
files, the editor and its self-test use them instead of indexing the grid; the loops over all 250 000 slots
(the map every frame, the editor's terrain drop) go over the sections there are.

Nothing changes in what the game does: the region still ends at +-250 km, a point beyond it still goes to the
section at the edge, and the centre of a new section is computed from the row and column before that clamp,
as it was. Lifting the limit is a later step, behind a switch.

Checked in the game (td.scn, Glinojeck.scn, --test 120 s, seed 1): the physics logs are the same bit for bit
as before the change, with the .sbt written and with it read back, and the .sbt files written are byte for
byte the same as those of the build before.
2026-12-02 23:20:42 +01:00
miloszunio 1e3c9b9c40 fix(driver): the flashlight after the review of 30.11: the toggle in a helper, a line in the log with the clustered lights off
- TCamera::OnCommand() hands the command to toggle_flashlight(), which keeps the complexity of the handler where it was (S3776)
- turned on with gfx.lights.clustered off the flashlight lights nothing: the log says so
- local_lights::add_flashlight() is private; gather() adds the flashlight right after the lights of the cab, apart from the
  place the arcs of the pantographs of #431 are added in, so the two merge without a conflict
- a test of the toggle: the key going up switches it, a press and the repeats don't
2026-11-30 22:01:30 +00:00
miloszunio 84c4138301 merge: staging (6a716b67) into feat/flashlight-gl46
The flashlight's command stays the last one in input/command.h and both lists of input/command.cpp,
after the genericset and the traction mode commands staging added; local_lights keeps both forget()
of staging and add_flashlight().
2026-11-30 12:33:36 +00:00
Hirek 969864f204 Merge staging into cleanup/mover
The windscreen weather (#367) and the compiler cache of the CI (#434). The
wipers' code of both renderers takes staging's side, reading the active cab and
the speed through TDynamicObject (ActiveCab(), Speed()) as the renderer does on
this branch; the windscreen water reads the speed the same way, and the deer
(world/deer.cpp) read the vehicle through its queries (V(), WarningSignal(),
CabOccupied()).

The golden traces recorded on dfb43c4f still match bit for bit: staging didn't
touch the physics.
2026-11-29 16:55:25 +01:00
lcddisplay 339d70a6e6 Moths fly about the lit lamps of the scenery
A part of the lamps of the scenery models which shine downwards (moths.share,
picked by the places of the lamps) gets a swarm of moths: an instance of
animals/cmy.t3d (animated by textures, shader vat) put at the light point when
the lamp first comes within moths.range of the camera. The swarm is shown while
its lamp shines (the light points gathered by the local lights in the frame),
not in the winter and not below moths.temperature. The swarms are made by the
game (basic_node::m_generated): not saved with the scenery, not edited.

Settings (eu07.ini): moths yes/no, moths.share 0-1 (0.4), moths.range metres
(80), moths.temperature degrees (8). Also in the debug window of the lights.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GXgG7F4L42c2F9sDSAJbT2
2026-11-29 11:39:09 +01:00
Hirek d28b908ca4 refactor(render): the renderer reads a vehicle through TDynamicObject, not its physics
No file of rendering/ includes physics/vehicle.h any more. What the renderers
read of a vehicle comes through a few queries of TDynamicObject
(vehicle/dynamic/lights.cpp): its dimensions, its speed, its active cab, the
light of its compartments, the adapters of its couplers, the lights switched
on at an end, the low voltage for them, and the multiplier and the colour of
its headlights. The shares of the speed and the opacity of the exhaust smoke
(ExhaustScales()) move out of the particles into the vehicle, as they are.

The headlights pick their multiplier once, by the dimming and the high beam
switches, where the light array repeated the same four branches twice; the
light of a switched off end still goes to zero as before.
2026-11-29 10:43:31 +01:00
Hirek d0387753f8 refactor(physics): TMoverParameters becomes physics::Vehicle, the mover is gone
The physics of a vehicle loses the name it had from the Pascal of 2001. Done by
tools/rename/mover_to_physics.py, committed with it:

  physics/mover.h                  physics/vehicle.h
  TMoverParameters                 physics::Vehicle (in namespace physics)
  TDynamicObject::MoverParameters  physics
  mvOccupied, mvControlled         occupied, controlled (TTrain, TController)
  mvSecond, mvThird                secondUnit, thirdUnit
  mvPantographUnit                 pantographUnit
  mover, Mover, movers             physics, Physics, vehicles (locals, params)
  m_mover, othermover, currentMover, from_movers, renderMoverEventSounds
                                   m_physics, otherPhysics, currentPhysics,
                                   from_vehicles, renderPhysicsEventSounds

The code and the comments are renamed, the string literals are not: no text
the game shows, logs or looks up has changed (none had the names). The movers
of the editor, the tracks a slide moves, keep their name.

By hand: two member functions of TDynamicObject (gather_off_track_terrain,
begin_off_track) had a local mover aliasing their own MoverParameters, which
the rename made physics { *physics }; the alias is gone, they use physics->.
No other function has a renamed local meeting a renamed member (checked over
all the functions of the code before the rename).

For the branches made before it: run the script on the branch (python
tools/rename/mover_to_physics.py, from the root of the repository) before
merging it with this one, and the names don't conflict. It can be run again;
the second time it changes nothing.

The class is the same as it was; breaking it into its parts (braking,
electrics, controls, load) and making its data private are the next stages.

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-28 23:56:46 +01:00
Hirek 19f884cdbb refactor(physics): the vehicle vocabulary in physics/vehicletypes.h; DynObj.h and Driver.h no longer include mover.h
DynObj.h included physics/mover.h, so nearly every file of the simulator
compiled the whole vehicle physics (TMoverParameters and the brakes) though
most of them only name a vehicle end, a coupling or a light.

- physics/vehicletypes.h: the enums, flags and small structures the rest of
  the simulator passes around (end, side, coupling, light, sound, activation,
  train_type, TEngineType, TBrakeSystem..., TLocation, TTrackShape,
  neighbour_data), moved from mover.h as they were. mover.h includes it.
- DynObj.h and Driver.h include vehicletypes.h; TMoverParameters is forward
  declared (utilities/Classes.h). Their inline accessors that read the mover
  (NextConnected(), GetVelocity(), is_emu(), DirectionalVel()...) are defined
  in DynObj.cpp and Driver.cpp.
- the files that use the mover include physics/mover.h themselves.

Now 140 of the 730 objects of the build depend on mover.h and brakes.h,
about 80 of them unit tests.

No change in behaviour: 1142/1142 tests, golden traces exact against staging
62f7a29b.
2026-11-27 18:53:06 +01:00
Hirek 0ce190eab2 fix: the review of the renderers PR: physics switches off by default, crashes on exit and at start, renderer, shader and editor fixes 2026-11-27 09:15:11 +01:00
miloszunio 98c53a15dc fix(driver): the flashlight held in the right hand, so its shadows are seen
From 15 cm under the eye the flashlight's shadows fell right behind the things which cast them, where
the eye can't see them. It shines now from the right hand, 35 cm down and 25 cm right of the eye, along
the line of sight as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:00:26 +01:00
miloszunio 2f7eb0c119 fix(driver): the flashlight casts shadows, not lighting the snow through the walls of the vehicles
Without shadows the flashlight lit everything in its cone, also behind the walls of the vehicles: the
snow on the ground beyond a car shone white through its windows as a band at their bottom. It now has
a cube shadow map as the lamps of the scenery do (opengl46/vulkan14 local shadows), made anew as it
moves, named to them by Global.flashlight. It doesn't skip any model drawing its shadow map
(shade_self).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:00:26 +01:00
miloszunio 2a34d32521 fix(driver): the flashlight's cone narrower and its light neutral white
The cone is 16 degrees wide from its axis (was 24), at its full brightness within 8 (was 12), and the
light is a neutral white (1, 0.98, 0.95) instead of a warm one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:00:26 +01:00
miloszunio d11555e46e feat(driver): a flashlight of the player, switched with Ctrl+Shift+L
The new command flashlighttoggle (Ctrl+Shift+L, free in the default keyboard bindings) switches a cone
of warm white light from a little under the camera where it looks, in the cab, outside and in the free
camera, by day as well. It is one more local light of the clustered lighting (gfx::local_lights), so it
works with both the OpenGL 4.6 and the Vulkan renderers, and only with gfx.lights.clustered on. It
casts no shadows. It is off at the start and isn't kept between the runs.

The command is added at the end of user_command, so the numbers of the commands before it stay as they
were. Its key comes from the default bindings in the code: an eu07_input-keyboard.ini without it keeps
working, and one can bind it to another key with a "flashlighttoggle" line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:00:25 +01:00
pawelw 3710f87fc5 feat(gl46): street lamps of the scenery light their surroundings (#371)
* Local lights: street lamps of the scenery light their surroundings

Optional settings, all off by default (nothing changes without them):
- gfx.lights.stars: Stars submodels (e.g. "lamp" of the SGP340 street lights) whose glowing points light downwards as lamps;
  signal LEDs, chimneys and the sky only glow
- gfx.lights.points.near: scenery lamps shining downwards light also closer than their glare is seen from
- gfx.lights.freespot.mincone: wider cones for scenery lamps shining downwards (many have the narrow cone of their glare)
- gfx.lights.lamps.gain: brightness of the scenery lamps shining downwards
- gfx.lights.hideglow: textures of the planes faking the light of lamps (pools of light, glows), hidden while the lamps light

Lights shining sideways (signals) keep their cones, brightness and distances.
The lamps made of glowing points are gathered also from the opaque instances of a cell.

* Local lights: the lamp settings in a parser of their own, the draw phase test in a helper

The entries of the lamps are read by ConfigParse_gfx_lamps, which the parser of the sky hands the tokens it doesn't know, and
the opaque and translucent draws ask drawn_in_phase whether a submodel has a part in them, so the long functions keep their
complexity. The fake glow cache is private, the colour of a light point is lightcolor (no shadowing of rendermode::color),
the minimal distance of a submodel comes from walk_min_distance and the lit instances of a cell from add_lit_instances.

* Settings: the lamp entries are tried by the main loop of the parser, the parser of the sky stays as it was

* Local lights: the fake glows are left out only within the reach the lamps are gathered from

Beyond gfx.lights.range nothing lights the ground in place of the pools of light and glows of the lamps, so a scenery model
keeps them there. Render_Alpha(TAnimModel *) tells hide_fake_glows() which model it draws, and is_fake_glow() leaves out the
glows of that model only, when it is within the range (and its radius) of the camera the lamps are gathered around. The glow
planes are translucent, so the opaque draws are as they were.

* Local lights: hide_fake_glows() takes the model as it is drawn (radius() isn't const)

* Local lights: the fake glows hidden at any distance again, gfx.lights.lamps.range to see the lamps from afar

Glow planes kept beyond the reach of the lamps don't light a distant station either, they only float above it, so the glows
listed in gfx.lights.hideglow are left out at any distance again. A lit station is seen from afar with gfx.lights.lamps.range
instead: the lamps are gathered from that far when it's above gfx.lights.range (0, the default: from gfx.lights.range).

* Local lights: gfx.lights.lamps.range for the lamps of the scenery only, the vehicles keep gfx.lights.range

* Local lights: the fake glows are kept with gfx.lights.range 0, the limits of gfx.lights.hideglow in the docs
2026-11-20 04:25:18 +01:00
Hirek 96100f1155 Draw the cab probe with all the lights of the cab 2026-10-29 20:05:03 +01:00
Hirek 65e104f813 Light the occupied cab with the light points of its model 2026-10-28 21:06:02 +01:00
Hirek 9904eddd0d Light the cab with cablight/dashboardlight light points of the cab model 2026-10-28 20:55:45 +01:00
Hirek c4e23932bf Add the optional Radius, ShadeSelf, CastShadows and SoftFalloff of FreeSpotLight and make FalloffAngle 360 a point light 2026-10-28 16:18:03 +01:00
Hirek 2a876befb0 Shade the sky and the sun by the scenery around the camera instead of the track environment flags 2026-10-27 16:02:36 +01:00
Hirek 9dde5b0e5e Take the ambient occlusion into the lighting and add a probe of the cab 2026-10-27 13:23:52 +01:00
Hirek 9b7d02e5fb Vulkan: scene rendering (D1–D7) on a scene walk shared with GL (N6a, N6b) 2026-10-24 20:10:24 +02:00