mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
avoid unnecessary polygon transformations when adding SVGs to things.
rotate() requires center(), which is actually a bit expensive because of some paranoia about dupe pts.
This commit is contained in:
parent
4f7bed25cd
commit
62fb7bfd95
@ -456,8 +456,16 @@ impl GeomBatch {
|
||||
let dims = other.get_dims();
|
||||
let dx = center.x() - dims.width * scale / 2.0;
|
||||
let dy = center.y() - dims.height * scale / 2.0;
|
||||
for (color, poly) in other.consume() {
|
||||
self.push(color, poly.scale(scale).translate(dx, dy).rotate(rotate));
|
||||
for (color, mut poly) in other.consume() {
|
||||
// Avoid unnecessary transformations for slight perf boost
|
||||
if scale != 1.0 {
|
||||
poly = poly.scale(scale);
|
||||
}
|
||||
poly = poly.translate(dx, dy);
|
||||
if rotate != Angle::ZERO {
|
||||
poly = poly.rotate(rotate);
|
||||
}
|
||||
self.push(color, poly);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user