17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-20 10:24:53 +02:00
Commit Graph

33 Commits

Author SHA1 Message Date
jerrrrycho
00934a17ed fix(physics): automatic couplers don't catch above the safe collision speed (#86)
Two vehicles with automatic couplers coupled the moment they touched, in CouplerForce(), before
CollisionDetect() ran; its derail check only covers uncoupled vehicles, so they never collided nor
derailed, at any speed. With crash damage on, the coupling now waits for a closing speed of at most
15 km/h, the limit of the derail check. A faster hit locks the automatic coupling until the vehicles
part, so the collision runs its course instead of the couplers catching once it has slowed them down.

Two collision bugs on the way:
- CollisionVelocity() took the length of the difference of the heading quaternions times the speeds;
  a quaternion turns by half its angle, so for vehicles facing each other the speeds came out at right
  angles: a head-on hit at 10 + 10 km/h read as 14.1 km/h, under the limit. The closing speed is now
  taken from the touching ends, as CouplerForce() relates the vehicles: the sum of the speeds head-on,
  the difference rear-end, negative when the ends part,
- CollisionDetect() gave ComputeCollision() the other vehicle's speed along that vehicle's own axis,
  which points the other way for vehicles facing each other: a wagon hit head-on counted as running
  into the hitter, and the hitter bounced back as from a wall (20 km/h into a standing wagon: it ran
  off at 6 km/h instead of 17). The speed is turned into this vehicle's frame and back.

Head-on hits now count with both speeds, so with crash damage on they derail sooner than before, at
the 15 km/h the check was meant for.

Tests: test::pair runs two test vehicles on one track the way vehicle_table::update() runs a scene
(neighbours, forces, movement), with coupling, buffing, collisions and derailing coming from the
physics. tests/unit/test_couplers.cpp: catching up to 15 km/h and not above; a slow hit couples, a fast
one doesn't, nor once slowed down, the lock resets once the vehicles part; a hit a little over 15 km/h
bounces apart on the rails, harder ones derail; head-on 7 + 7 couples, 8 + 8 bounces, 15 + 15 derails;
no catching a coupler of another type, couplers of different control systems couple without the
control connection.
2026-10-17 13:49:05 +02:00
9935257783 Add nosonar tags 2026-10-09 18:40:31 +02:00
917c8f7285 Merge branch 'master' into feat/modern-editor 2026-10-08 17:44:58 +02:00
maj00r
084a705452 fix(vehicles): vehicle placed with a switch as its first path no longer reads the direction of a previous path it doesn't have; vehicle put back on the track keeps the direction of its axles 2026-10-06 22:19:12 +02:00
jerrrrycho
79bd0c8e91 fix(sonar): addressing reliability/security issues (#202) 2026-10-04 20:00:13 +02:00
2f417fddcc feat(roads): road node with generated lanes, surface and markings 2026-10-03 17:35:08 +02:00
b67bbb19e6 Merge pull request #188 from MaSzyna-EU07/feat/dynobj-seasonal-models
seasonal model variants for vehicle exterior model
2026-09-28 21:21:49 +02:00
jerrrrycho
4137f5504a fix: sonar sast fixes - sonar.yml, nosonar, linux chmod modification 2026-09-28 21:07:53 +02:00
551f6dbc3b seasonal model variants for vehicle exterior model 2026-09-28 20:49:18 +02:00
jerrrrycho
8fbb482350 feat(materials): texture randomization for loads
* feat(materials): texture randomization for loads
2026-09-27 00:09:16 +02:00
maj00r
03bfbb1345 fix: restore min>max tolerance lost in clamp->std::clamp migration
The dumb3d->glm / utilities-simplification refactor replaced the old custom
clamp() (which tolerated Lo>Hi, returning the upper bound) with std::clamp,
where inverted bounds are undefined behaviour. Only a few sites were patched
afterwards, by hand, with std::minmax plumbing (incl. a stray `static` inside
a per-axle loop). Others silently produced wrong results in the AI braking /
acceleration path.

Add a safe_clamp() helper (normalizes inverted bounds) and use it ONLY where
Lo<=Hi cannot be proven at compile time (config min/max pairs, sign-dependent
expressions, container underflow). Sites with constant bounds or [0, x>=0]
keep std::clamp. Remove the manual std::minmax workarounds and rewrite the
damaged-track jolt code value-first.
2026-07-02 00:37:52 +02:00
jerrrrycho
d85096f64d reformat: remove redundant parentheses 2026-06-30 21:19:46 +02:00
jerrrrycho
bf147dd155 refactor: replace null with nullptr 2026-06-29 02:48:25 +02:00
docentYT
fa2ed08955 Fix clamp min max values 2026-05-12 16:49:02 +02:00
docentYT
5367cb9940 Merge remote-tracking branch 'upstream/master' into utilities-simplification 2026-05-05 23:08:43 +02:00
9081282a47 Fix for lowercase python state parameters 2026-05-03 22:37:53 +02:00
docentYT
d464628a8e Fix problem with min value bigger than max value in std::clamps 2026-05-03 22:18:40 +02:00
docentYT
13c7317f6e Do not allow implicit cast for inline std::string to_string(bool Value) and change to_string to std::string for non boolean values 2026-05-03 15:49:29 +02:00
docentYT
7081dab3c2 Replace RadToDeg and DegToRad with glm::degrees and glm::radians 2026-05-02 14:51:13 +02:00
docentYT
3628eb0fc3 Replace interpolate with std::lerp and glm::mix 2026-05-02 01:31:38 +02:00
docentYT
d1f16411a1 Replace clamp with std::clamp 2026-05-01 22:14:29 +02:00
docentYT
ec1dfae953 Replace starts_with and ends_with with string class methods 2026-05-01 17:31:11 +02:00
docentYT
337e750ed1 Replace Max0R and Min0R with std::max and std::min 2026-04-30 23:47:32 +02:00
docentYT
ca839652bf Use the sq function to force constexpr expressions for numeric literals and enhance readability 2026-04-28 13:23:14 +02:00
docentYT
6be1b0886d Remove sad workaround 2026-04-28 01:23:53 +02:00
docentYT
623c4f827e Remove not needed casts, variables and switch from double precission to float precission for some angle vectors 2026-04-28 00:51:17 +02:00
docentYT
cba106e22e Use glm::length2 instead of glm::length where possible 2026-04-27 23:27:08 +02:00
docentYT
d5d1825e38 Remove dumb3d 2026-04-27 23:03:47 +02:00
docentYT
fae68642bc use glm instead of Math3D in vehicle
WARNING: Model rotation is broken
2026-04-27 13:07:38 +02:00
jakubg1
0d010e8c6a Simplify derailing logic, derail reason enum
- The `TMoverParameters::derail()` function has been renamed to `::Derail()`, with a capital D.
- All derail events now use that function.
  - Simplified and unified the logic behind different derail types.
  - The `dtrack_freerail` track type is now slightly increasing the chance of derailing on a tight curve, as it was the intention.
- A new `DerailReason` enum has been created which holds all derail types.
- The `DerailReason` field in the `TMoverParameters` class has been removed.
  - This was a transient field which is not necessary anymore.
  - The logging functionality as such has been moved from `DynObj.cpp` to `Mover.cpp`.
2026-04-04 02:05:49 +02:00
jerrrrycho
9f43dca48b refactor: create paths namespace instead of global variables 2026-03-15 11:55:30 +01:00
copilot-swe-agent[bot]
7e49aa8740 Rewrite #includes to use explicit subdirectory paths
Co-authored-by: Hirek193 <23196899+Hirek193@users.noreply.github.com>
2026-03-14 19:16:48 +00:00
copilot-swe-agent[bot]
0531086bb9 Reorganize source files into logical subdirectories
Co-authored-by: Hirek193 <23196899+Hirek193@users.noreply.github.com>
2026-03-14 19:01:57 +00:00