mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 19:57:06 +01:00
Deer: on curved track too, only the switches keep them away
The track at the place no longer has to be straight: a curve is fine. Only a switch (or a crossing of roads) from the train to 100 m past the place keeps a deer from being put there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GXgG7F4L42c2F9sDSAJbT2
This commit is contained in:
+3
-15
@@ -77,11 +77,8 @@ constexpr double Waystep{0.45};
|
||||
constexpr double Wayrange{1.2};
|
||||
// where there's no such ground at the place, the next deer is looked for this much farther, metres
|
||||
constexpr double Retrydistance{200.0};
|
||||
// the track at the place: plain (no switch) from the train to this much past the place, and turning at most Straightturn degrees
|
||||
// over Straightspan metres before and after it, metres
|
||||
// the track at the place: plain (no switch) from the train to this much past the place, metres
|
||||
constexpr double Clearpast{100.0};
|
||||
constexpr double Straightspan{50.0};
|
||||
constexpr double Straightturn{3.0};
|
||||
// no deer this near a platform: an instance of a model of peronowe/ (or another folder named so), metres
|
||||
constexpr double Platformrange{150.0};
|
||||
// nor where the ground beside the track, this far from its axis, rises this much over the sleepers (a platform of the terrain)
|
||||
@@ -319,24 +316,15 @@ bool path_ahead(TTrack *Track, double Offset, double Direction, double Distance,
|
||||
return false;
|
||||
}
|
||||
|
||||
// the way ahead of the train to Distance and Clearpast past it plain track, the track there about straight: Place the place
|
||||
// the way ahead of the train to Distance and Clearpast past it plain track (straight or curved, no switch): Place the place
|
||||
bool plain_way(TTrack *Track, double const Offset, double const Direction, double const Distance, path_place &Place)
|
||||
{
|
||||
if ((Track == nullptr) || (Track->eType != tt_Normal))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
path_place before;
|
||||
path_place past;
|
||||
if ((false == path_ahead(Track, Offset, Direction, Distance + Clearpast, past)) ||
|
||||
(false == path_ahead(Track, Offset, Direction, Distance - Straightspan, before)) ||
|
||||
(false == path_ahead(Track, Offset, Direction, Distance, Place)) ||
|
||||
(false == path_ahead(Track, Offset, Direction, Distance + Straightspan, past)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto const limit{std::cos(Straightturn * std::numbers::pi / 180.0)};
|
||||
return (glm::dot(before.forward, Place.forward) >= limit) && (glm::dot(Place.forward, past.forward) >= limit);
|
||||
return path_ahead(Track, Offset, Direction, Distance + Clearpast, past) && path_ahead(Track, Offset, Direction, Distance, Place);
|
||||
}
|
||||
|
||||
// a model of a platform: in a folder named peron... (peronowe/)
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ class deer_herd
|
||||
};
|
||||
// the train at Train, its horn sounding, at the time Now: the deer takes fright, runs, or goes (true) once the train is past it
|
||||
bool tend(deer &Animal, glm::dvec3 const &Train, bool const Horn, double const Now) const;
|
||||
// puts a deer on the path ahead of the train, where it's plain and straight track with flat ground beside it and no platform near;
|
||||
// puts a deer on the path ahead of the train, where it's plain track (no switch) with flat ground beside it and no platform near;
|
||||
// false where there's none
|
||||
bool spawn(TDynamicObject const &Vehicle);
|
||||
// the deer took fright: when it starts, where it looks
|
||||
|
||||
Reference in New Issue
Block a user