Skip to content

Commit

Permalink
fix #14433
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 1, 2024
1 parent 72cec36 commit a7a54a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/guisim/GUIBaseVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,9 @@ GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos
int requiredSeats = getNumPassengers();
int requiredContainerPositions = getNumContainers();
const Position back = (p1 + Position(-scaledLength * upscaleLength, 0)).rotateAround2D(angle, p1);
computeSeats(p1, back, SUMO_const_waitingPersonWidth, getVType().getPersonCapacity(), upscale, requiredSeats, mySeatPositions);
computeSeats(p1, back, SUMO_const_waitingContainerWidth, getVType().getContainerCapacity(), upscale, requiredContainerPositions, myContainerPositions);
double extraOffset = scaledLength * 0.15;
computeSeats(p1, back, SUMO_const_waitingPersonWidth, getVType().getPersonCapacity(), upscale, requiredSeats, mySeatPositions, extraOffset);
computeSeats(p1, back, SUMO_const_waitingContainerWidth, getVType().getContainerCapacity(), upscale, requiredContainerPositions, myContainerPositions, extraOffset);
}

GLHelper::popMatrix();
Expand Down Expand Up @@ -1153,7 +1154,7 @@ GUIBaseVehicle::getDeviceDescription() {


void
GUIBaseVehicle::computeSeats(const Position& front, const Position& back, double seatOffset, int maxSeats, double exaggeration, int& requiredSeats, Seats& into) const {
GUIBaseVehicle::computeSeats(const Position& front, const Position& back, double seatOffset, int maxSeats, double exaggeration, int& requiredSeats, Seats& into, double extraOffset) const {
if (requiredSeats <= 0) {
return;
}
Expand All @@ -1162,9 +1163,10 @@ GUIBaseVehicle::computeSeats(const Position& front, const Position& back, double
const double vehWidth = getVType().getSeatingWidth() * exaggeration;
const double length = front.distanceTo2D(back);
const int rowSize = MAX2(1, (int)floor(vehWidth / seatOffset));
const double rowOffset = MAX2(1.0, (length - getVType().getFrontSeatPos() - 1)) / ceil((double)maxSeats / rowSize);
const double frontSeatPos = getVType().getFrontSeatPos() + extraOffset;
const double rowOffset = MAX2(1.0, (length - frontSeatPos - 1)) / ceil((double)maxSeats / rowSize);
const double sideOffset = (rowSize - 1) / 2.0 * seatOffset;
double rowPos = getVType().getFrontSeatPos() - rowOffset;
double rowPos = frontSeatPos - rowOffset;
double angle = back.angleTo2D(front);
const int fillDirection = MSGlobals::gLefthand ? -1 : 1;
//if (myVehicle.getID() == "v0") std::cout << SIMTIME << " seatOffset=" << seatOffset << " max=" << maxSeats << " ex=" << exaggeration << " req=" << requiredSeats << " rowSize=" << rowSize << " sideOffset=" << sideOffset << " front=" << front << " back=" << back << " a=" << angle << " da=" << RAD2DEG(angle) << "\n";
Expand Down
2 changes: 1 addition & 1 deletion src/guisim/GUIBaseVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class GUIBaseVehicle : public GUIGlObject {
bool drawAction_drawVehicleAsPolyWithCarriagges(const GUIVisualizationSettings& s, double scaledLength, bool asImage = false) const;

/// @brief add seats to mySeatPositions and update requiredSeats
void computeSeats(const Position& front, const Position& back, double seatOffset, int maxSeats, double exaggeration, int& requiredSeats, Seats& into) const;
void computeSeats(const Position& front, const Position& back, double seatOffset, int maxSeats, double exaggeration, int& requiredSeats, Seats& into, double extraOffset = 0) const;

/// @brief whether to reverse trains in their reversed state
bool drawReversed(const GUIVisualizationSettings& s) const;
Expand Down

0 comments on commit a7a54a0

Please sign in to comment.