Skip to content

Commit

Permalink
Merge pull request #1 from cityflow-project/master
Browse files Browse the repository at this point in the history
fix(UI): vehicles with different width (#64)
  • Loading branch information
only-changer authored Oct 22, 2019
2 parents 9a4766a + c4d4412 commit 0ba40f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frontend/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,24 +705,27 @@ function drawStep(step) {

carContainer.removeChildren();
turnSignalContainer.removeChildren();
let carLog, position, length;
let carLog, position, length, width;
for (let i = 0, len = carLogs.length - 1;i < len;++i) {
carLog = carLogs[i].split(' ');
position = transCoord([parseFloat(carLog[0]), parseFloat(carLog[1])]);
length = parseFloat(carLog[5]);
width = parseFloat(carLog[6]);
carPool[i][0].position.set(position[0], position[1]);
carPool[i][0].rotation = 2*Math.PI - parseFloat(carLog[2]);
carPool[i][0].name = carLog[3];
let carColorId = stringHash(carLog[3]) % CAR_COLORS_NUM;
carPool[i][0].tint = CAR_COLORS[carColorId];
carPool[i][0].width = length;
carPool[i][0].height = width;
carContainer.addChild(carPool[i][0]);

let laneChange = parseInt(carLog[4]) + 1;
carPool[i][1].position.set(position[0], position[1]);
carPool[i][1].rotation = carPool[i][0].rotation;
carPool[i][1].texture = turnSignalTextures[laneChange];
carPool[i][1].width = length;
carPool[i][1].height = width;
turnSignalContainer.addChild(carPool[i][1]);
}
nodeCarNum.innerText = carLogs.length-1;
Expand Down
3 changes: 2 additions & 1 deletion src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ namespace CityFlow {
int lc = vehicle->lastLaneChangeDirection();
result.append(
double2string(pos.x) + " " + double2string(pos.y) + " " + double2string(atan2(dir.y, dir.x)) + " "
+ vehicle->getId() + " " + std::to_string(lc) + " " + double2string(vehicle->getLen())+ ",");
+ vehicle->getId() + " " + std::to_string(lc) + " " + double2string(vehicle->getLen()) + " "
+ double2string(vehicle->getWidth()) + ",");
}
result.append(";");

Expand Down

0 comments on commit 0ba40f9

Please sign in to comment.