Skip to content

Commit

Permalink
cars can now see trains on shared bidi lane #13313
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed May 25, 2023
1 parent 9ece67d commit 3f7857c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/microsim/MSLane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ MSLane::incorporateVehicle(MSVehicle* veh, double pos, double speed, double posL
if (wasInactive) {
MSNet::getInstance()->getEdgeControl().gotActive(this);
}
if (!isRailway(veh->getVClass()) && getBidiLane() != nullptr) {
if (getBidiLane() != nullptr && (!isRailway(veh->getVClass()) || (getPermissions() & ~SVC_RAIL_CLASSES) != 0)) {
// railways don't need to "see" each other when moving in opposite directions on the same track (efficiency)
getBidiLane()->setPartialOccupation(veh);
}
Expand Down
9 changes: 6 additions & 3 deletions src/microsim/MSVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5292,8 +5292,9 @@ MSVehicle::enterLaneAtMove(MSLane* enteredLane, bool onTeleporting) {
const double range2 = (myLane->getWidth() - getVehicleType().getWidth()) * 0.5 + overlap;
myState.myPosLat *= range2 / range;
}
if (!isRailway(getVClass()) && myLane->getBidiLane() != nullptr) {
if (myLane->getBidiLane() != nullptr && (!isRailway(getVClass()) || (myLane->getPermissions() & ~SVC_RAIL_CLASSES) != 0)) {
// railways don't need to "see" each other when moving in opposite directions on the same track (efficiency)
// (unless the lane is shared with cars)
myLane->getBidiLane()->setPartialOccupation(this);
}
} else {
Expand Down Expand Up @@ -5331,8 +5332,9 @@ MSVehicle::enterLaneAtLaneChange(MSLane* enteredLane) {
std::cout << SIMTIME << " enterLaneAtLaneChange entered=" << Named::getIDSecure(enteredLane) << " oldFurther=" << toString(myFurtherLanes) << "\n";
}
#endif
if (!isRailway(getVClass()) && myLane->getBidiLane() != nullptr) {
if (myLane->getBidiLane() != nullptr && (!isRailway(getVClass()) || (myLane->getPermissions() & ~SVC_RAIL_CLASSES) != 0)) {
// railways don't need to "see" each other when moving in opposite directions on the same track (efficiency)
// (unless the lane is shared with cars)
myLane->getBidiLane()->setPartialOccupation(this);
}
for (int i = 0; i < (int)myFurtherLanes.size(); i++) {
Expand Down Expand Up @@ -5516,7 +5518,8 @@ MSVehicle::leaveLane(const MSMoveReminder::Notification reason, const MSLane* ap
if ((reason == MSMoveReminder::NOTIFICATION_JUNCTION || reason == MSMoveReminder::NOTIFICATION_TELEPORT) && myLane != nullptr) {
myOdometer += getLane()->getLength();
}
if (myLane != nullptr && myLane->getBidiLane() != nullptr && myAmOnNet && !isRailway(getVClass())) {
if (myLane != nullptr && myLane->getBidiLane() != nullptr && myAmOnNet
&& (!isRailway(getVClass()) || (myLane->getPermissions() & ~SVC_RAIL_CLASSES) != 0)) {
myLane->getBidiLane()->resetPartialOccupation(this);
}
if (reason != MSMoveReminder::NOTIFICATION_JUNCTION && reason != MSMoveReminder::NOTIFICATION_LANE_CHANGE) {
Expand Down

0 comments on commit 3f7857c

Please sign in to comment.