From cd9d38f2b80d0a650274f8f9807a2aaf1abd5d5c Mon Sep 17 00:00:00 2001 From: Marco Zimmermann Date: Wed, 10 Jan 2024 19:58:17 +0100 Subject: [PATCH 1/6] remove ats --- .../shader/ColorCircleShaderOpenGl.cpp | 8 ++++---- .../cpp/graphics/shader/ColorShaderOpenGl.cpp | 8 ++++---- .../cpp/graphics/shader/TextShaderOpenGl.cpp | 20 +++++++++---------- shared/public/LoaderHelper.h | 4 ++-- shared/src/graphics/helpers/Matrix.cpp | 8 ++++---- .../Tiled2dMapVectorLayerParserHelper.cpp | 14 ++++++------- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/android/src/main/cpp/graphics/shader/ColorCircleShaderOpenGl.cpp b/android/src/main/cpp/graphics/shader/ColorCircleShaderOpenGl.cpp index 17bef964e..091ec9667 100644 --- a/android/src/main/cpp/graphics/shader/ColorCircleShaderOpenGl.cpp +++ b/android/src/main/cpp/graphics/shader/ColorCircleShaderOpenGl.cpp @@ -47,10 +47,10 @@ void ColorCircleShaderOpenGl::preRender(const std::shared_ptr<::RenderingContext void ColorCircleShaderOpenGl::setColor(float red, float green, float blue, float alpha) { std::lock_guard lock(dataMutex); - color.at(0) = red; - color.at(1) = green; - color.at(2) = blue; - color.at(3) = alpha; + color[0] = red; + color[1] = green; + color[2] = blue; + color[3] = alpha; } std::string ColorCircleShaderOpenGl::getFragmentShader() { diff --git a/android/src/main/cpp/graphics/shader/ColorShaderOpenGl.cpp b/android/src/main/cpp/graphics/shader/ColorShaderOpenGl.cpp index 503a5c323..41ed9b9c0 100644 --- a/android/src/main/cpp/graphics/shader/ColorShaderOpenGl.cpp +++ b/android/src/main/cpp/graphics/shader/ColorShaderOpenGl.cpp @@ -47,10 +47,10 @@ void ColorShaderOpenGl::preRender(const std::shared_ptr<::RenderingContextInterf void ColorShaderOpenGl::setColor(float red, float green, float blue, float alpha) { std::lock_guard lock(dataMutex); - color.at(0) = red; - color.at(1) = green; - color.at(2) = blue; - color.at(3) = alpha; + color[0] = red; + color[1] = green; + color[2] = blue; + color[3] = alpha; } std::string ColorShaderOpenGl::getVertexShader() { diff --git a/android/src/main/cpp/graphics/shader/TextShaderOpenGl.cpp b/android/src/main/cpp/graphics/shader/TextShaderOpenGl.cpp index d214189af..bd6d3a09e 100644 --- a/android/src/main/cpp/graphics/shader/TextShaderOpenGl.cpp +++ b/android/src/main/cpp/graphics/shader/TextShaderOpenGl.cpp @@ -16,21 +16,21 @@ const std::string TextShaderOpenGl::programName = "UBMAP_TextShaderOpenGl"; std::string TextShaderOpenGl::getProgramName() { return programName; } -void TextShaderOpenGl::setColor(const ::Color & color) { +void TextShaderOpenGl::setColor(const ::Color & c) { std::lock_guard lock(dataMutex); - this->color.at(0) = color.r; - this->color.at(1) = color.g; - this->color.at(2) = color.b; - this->color.at(3) = color.a; + color[0] = c.r; + color[1] = c.g; + color[2] = c.b; + color[3] = c.a; } void TextShaderOpenGl::setHaloColor(const ::Color & color, double width) { std::lock_guard lock(dataMutex); - haloColor.at(0) = color.r; - haloColor.at(1) = color.g; - haloColor.at(2) = color.b; - haloColor.at(3) = color.a; - this->haloWidth = width; + haloColor[0] = color.r; + haloColor[1] = color.g; + haloColor[2] = color.b; + haloColor[3] = color.a; + haloWidth = width; } void TextShaderOpenGl::setOpacity(float opacity) { this->opacity = opacity; } diff --git a/shared/public/LoaderHelper.h b/shared/public/LoaderHelper.h index 311140e6d..d2584663d 100644 --- a/shared/public/LoaderHelper.h +++ b/shared/public/LoaderHelper.h @@ -57,7 +57,7 @@ class LoaderHelper { if (loaderIndex >= loaders.size()) { promise->setValue(std::move(TextureLoaderResult(nullptr, std::nullopt, LoaderStatus::NOOP, std::nullopt))); } else { - loaders.at(loaderIndex)->loadTextureAsnyc(url, etag).then([url, etag, &loaders, loaderIndex, promise](::djinni::Future<::TextureLoaderResult> result) { + loaders[loaderIndex]->loadTextureAsnyc(url, etag).then([url, etag, &loaders, loaderIndex, promise](::djinni::Future<::TextureLoaderResult> result) { const auto textureResult = result.get(); if (textureResult.status != LoaderStatus::NOOP || loaderIndex == loaders.size() - 1) { promise->setValue(std::move(textureResult)); @@ -72,7 +72,7 @@ class LoaderHelper { if (loaderIndex >= loaders.size()) { promise->setValue(DataLoaderResult(std::nullopt, std::nullopt, LoaderStatus::NOOP, std::nullopt)); } else { - loaders.at(loaderIndex)->loadDataAsync(url, etag).then([url, etag, &loaders, loaderIndex, promise](::djinni::Future<::DataLoaderResult> result) { + loaders[loaderIndex]->loadDataAsync(url, etag).then([url, etag, &loaders, loaderIndex, promise](::djinni::Future<::DataLoaderResult> result) { const auto dataResult = result.get(); if (dataResult.status != LoaderStatus::NOOP || loaderIndex == loaders.size() - 1) { promise->setValue(std::move(dataResult)); diff --git a/shared/src/graphics/helpers/Matrix.cpp b/shared/src/graphics/helpers/Matrix.cpp index f207ef1a4..0a0638bef 100644 --- a/shared/src/graphics/helpers/Matrix.cpp +++ b/shared/src/graphics/helpers/Matrix.cpp @@ -570,8 +570,8 @@ std::vector Matrix::multiply(const std::vector &M, const std::vect } void Matrix::multiply(const std::vector &M, const std::vector &x, std::vector &result) { - result[0] = M[I(0, 0)] * x[0] + M[I(1, 0)] * x[1] + M[I(2, 0)] * x[2] + M[I(3, 0)] * x[3]; - result[1] = M[I(0, 1)] * x[0] + M[I(1, 1)] * x[1] + M[I(2, 1)] * x[2] + M[I(3, 1)] * x[3]; - result[2] = M[I(0, 2)] * x[0] + M[I(1, 2)] * x[1] + M[I(2, 2)] * x[2] + M[I(3, 2)] * x[3]; - result[3] = M[I(0, 3)] * x[0] + M[I(1, 3)] * x[1] + M[I(2, 3)] * x[2] + M[I(3, 3)] * x[3]; + result[0] = M[0] * x[0] + M[4] * x[1] + M[8] * x[2] + M[12] * x[3]; + result[1] = M[1] * x[0] + M[5] * x[1] + M[9] * x[2] + M[13] * x[3]; + result[2] = M[2] * x[0] + M[6] * x[1] + M[10] * x[2] + M[14] * x[3]; + result[3] = M[3] * x[0] + M[7] * x[1] + M[11] * x[2] + M[15] * x[3]; } diff --git a/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp b/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp index 0f49fa087..c1dc22974 100644 --- a/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp +++ b/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp @@ -108,8 +108,8 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ tmpBounds.push_back(el.value().get()); } if (tmpBounds.size() == 4) { - const auto topLeft = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds.at(0), tmpBounds.at(1), 0); - const auto bottomRight = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds.at(2), tmpBounds.at(3), 0); + const auto topLeft = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds[0], tmpBounds[1], 0); + const auto bottomRight = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds[2], tmpBounds[3], 0); bounds = RectCoord(topLeft, bottomRight); } } @@ -135,8 +135,8 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ tmpBounds.push_back(el.value().get()); } if (tmpBounds.size() == 4) { - const auto topLeft = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds.at(0), tmpBounds.at(1), 0); - const auto bottomRight = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds.at(2), tmpBounds.at(3), 0); + const auto topLeft = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds[0], tmpBounds[1], 0); + const auto bottomRight = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds[2], tmpBounds[3], 0); bounds = RectCoord(topLeft, bottomRight); } } @@ -246,7 +246,7 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ layers.push_back(layerDesc); } else if (val["type"] == "raster" && rasterLayerMap.count(val["source"]) != 0) { - auto layer = rasterLayerMap.at(val["source"]); + auto layer = rasterLayerMap[val["source"]]; RasterVectorStyle style = RasterVectorStyle(parser.parseValue(val["paint"]["raster-opacity"]), parser.parseValue(val["paint"]["raster-brightness-min"]), parser.parseValue(val["paint"]["raster-brightness-max"]), @@ -387,8 +387,8 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ tmpBounds.push_back(d); } if (tmpBounds.size() == 4) { - const auto topLeft = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds.at(0), tmpBounds.at(1), 0); - const auto bottomRight = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds.at(2), tmpBounds.at(3), 0); + const auto topLeft = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds[0], tmpBounds[1], 0); + const auto bottomRight = Coord(CoordinateSystemIdentifiers::EPSG4326(), tmpBounds[2], tmpBounds[3], 0); bounds = RectCoord(topLeft, bottomRight); } } From 0a55989d986e0f70e84742eefef8148a0cfe1952 Mon Sep 17 00:00:00 2001 From: Marco Zimmermann Date: Wed, 10 Jan 2024 19:58:50 +0100 Subject: [PATCH 2/6] reuse already computed points --- shared/public/TextLayerObject.h | 2 +- .../src/map/layers/text/TextLayerObject.cpp | 31 ++++++++++--------- .../Tiled2dMapVectorSymbolLabelObject.cpp | 10 +++--- .../Tiled2dMapVectorSymbolLabelObject.h | 4 +-- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/shared/public/TextLayerObject.h b/shared/public/TextLayerObject.h index 8374bc6ec..b9538b7ed 100644 --- a/shared/public/TextLayerObject.h +++ b/shared/public/TextLayerObject.h @@ -78,7 +78,7 @@ class TextLayerObject : public LayerObjectInterface { std::pair findReferencePointIndices(); Coord pointAtIndex(const std::pair &index, bool useRender = true); - std::pair indexAtDistance(const std::pair &index, double distance); + std::pair indexAtDistance(const std::pair &index, double distance, const std::optional &indexCoord); private: std::shared_ptr text; diff --git a/shared/src/map/layers/text/TextLayerObject.cpp b/shared/src/map/layers/text/TextLayerObject.cpp index a8e3b6633..f63ba694f 100644 --- a/shared/src/map/layers/text/TextLayerObject.cpp +++ b/shared/src/map/layers/text/TextLayerObject.cpp @@ -388,7 +388,7 @@ float TextLayerObject::layoutLine(float scale, bool updateObject) { } } - currentIndex = indexAtDistance(currentIndex, -size * 0.5); + currentIndex = indexAtDistance(currentIndex, -size * 0.5, std::nullopt); int total = 0; int rotated = 0; @@ -403,7 +403,7 @@ float TextLayerObject::layoutLine(float scale, bool updateObject) { for(auto &i : splittedTextInfo) { if(i.glyphIndex < 0) { - currentIndex = indexAtDistance(currentIndex, spaceAdvance * fontSize * i.scale); + currentIndex = indexAtDistance(currentIndex, spaceAdvance * fontSize * i.scale, std::nullopt); lastAngle = 0; preLastAngle = 0; index = 0; @@ -417,8 +417,8 @@ float TextLayerObject::layoutLine(float scale, bool updateObject) { auto p = pointAtIndex(currentIndex); // get before and after to calculate angle - auto before = pointAtIndex(indexAtDistance(currentIndex, -size.x * 0.5), false); - auto after = pointAtIndex(indexAtDistance(currentIndex, size.x * 0.5), false); + auto before = pointAtIndex(indexAtDistance(currentIndex, -size.x * 0.5, p), false); + auto after = pointAtIndex(indexAtDistance(currentIndex, size.x * 0.5, p), false); double angle = atan2((before.y - after.y), -(before.x - after.x)); angle *= (180.0 / M_PI); @@ -454,7 +454,7 @@ float TextLayerObject::layoutLine(float scale, bool updateObject) { auto yh = y + size.y; auto lastIndex = currentIndex; - currentIndex = indexAtDistance(currentIndex, advance.x * (1.0 + letterSpacing)); + currentIndex = indexAtDistance(currentIndex, advance.x * (1.0 + letterSpacing), p); // if we are at the end, and we were at the end (lastIndex), then clear and skip if(currentIndex.first == renderLineCoordinates.size() - 1 && lastIndex.first == currentIndex.first && (lastIndex.second == currentIndex.second)) { @@ -553,19 +553,20 @@ std::pair TextLayerObject::findReferencePointIndices() { int iMin = 0; for(int i=1; i 0) { - auto dot = Vec2D(point.x - start.x, point.y - start.y) * Vec2D(end.x - start.x, end.y - start.y); - t = dot / (length * length); + if(lengthSquared > 0) { + auto dot = Vec2D(point.x - start.x, point.y - start.y) * dir; + t = dot / lengthSquared; } - auto proj = Vec2D(start.x + t * (end.x - start.x), start.y + t * (end.y - start.y)); - auto dist = Vec2DHelper::distance(proj, Vec2D(point.x, point.y)); + auto proj = Vec2D(start.x + t * dir.x, start.y + t * dir.y); + auto dist = Vec2DHelper::distanceSquared(proj, Vec2D(point.x, point.y)); if(dist < distance && t >= 0.0 && t <= 1.0) { tMin = t; @@ -583,8 +584,8 @@ Coord TextLayerObject::pointAtIndex(const std::pair &index, bool us return Coord(s.systemIdentifier, s.x + (e.x - s.x) * index.second, s.y + (e.y - s.y) * index.second, s.z + (e.z - s.z) * index.second); } -std::pair TextLayerObject::indexAtDistance(const std::pair &index, double distance) { - auto current = pointAtIndex(index); +std::pair TextLayerObject::indexAtDistance(const std::pair &index, double distance, const std::optional &indexCoord) { + auto current = indexCoord ? *indexCoord : pointAtIndex(index); auto currentIndex = index; auto dist = std::abs(distance); diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolLabelObject.cpp b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolLabelObject.cpp index 5eea47ca9..84ec97092 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolLabelObject.cpp +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolLabelObject.cpp @@ -609,7 +609,7 @@ double Tiled2dMapVectorSymbolLabelObject::updatePropertiesLine(std::vectorfontData->glyphs[i.glyphIndex]; @@ -644,8 +644,8 @@ double Tiled2dMapVectorSymbolLabelObject::updatePropertiesLine(std::vector indexAtDistance(const std::pair &index, double distance) { - auto current = pointAtIndex(index, true); + inline std::pair indexAtDistance(const std::pair &index, double distance, const std::optional &indexCoord) { + auto current = indexCoord ? *indexCoord : pointAtIndex(index, true); auto currentIndex = index; auto dist = std::abs(distance); From 58fca2070287f6ed240aa14f7565ff84698a5b57 Mon Sep 17 00:00:00 2001 From: Marco Zimmermann Date: Wed, 10 Jan 2024 20:00:58 +0100 Subject: [PATCH 3/6] get symbols faster --- .../vector/symbol/SymbolObjectCollisionWrapper.h | 4 ++-- .../Tiled2dMapVectorSourceSymbolDataManager.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h b/shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h index b79a2d857..c9edd6b78 100644 --- a/shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h +++ b/shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h @@ -19,11 +19,11 @@ class SymbolObjectCollisionWrapper { size_t symbolTileIndex; bool isColliding; - SymbolObjectCollisionWrapper(const std::shared_ptr object) + SymbolObjectCollisionWrapper(const std::shared_ptr &object) : symbolObject(object), symbolSortKey(object->symbolSortKey), symbolTileIndex(object->symbolTileIndex), isColliding(object->animationCoordinator->isColliding()) {}; - SymbolObjectCollisionWrapper(SymbolObjectCollisionWrapper&& other) noexcept + SymbolObjectCollisionWrapper(const SymbolObjectCollisionWrapper& other) noexcept : symbolObject(std::move(other.symbolObject)), symbolSortKey(other.symbolSortKey), symbolTileIndex(other.symbolTileIndex), diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp index 7763a95a8..ffd2c8664 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp @@ -627,25 +627,26 @@ void Tiled2dMapVectorSourceSymbolDataManager::collisionDetection(std::vector(objectsIt->second)) { symbolGroup.syncAccess([&allObjects, zoomIdentifier, persistingPlacement = persistingSymbolPlacement](auto group){ - auto objects = group->getSymbolObjectsForCollision(); + const auto &objects = group->getSymbolObjectsForCollision(); if (persistingPlacement) { for (auto &object : objects) { if (object.symbolObject->largestCollisionZoom == -1 || object.symbolObject->largestCollisionZoom < zoomIdentifier) { - allObjects.push_back(std::move(object)); + allObjects.push_back(object); } else { object.symbolObject->setHideFromCollision(true); } } } else { - allObjects.reserve(allObjects.size() + objects.size()); - allObjects.insert(allObjects.end(), std::make_move_iterator(objects.begin()), - std::make_move_iterator(objects.end())); + for(auto& o : objects) { + allObjects.push_back(o); + } } }); } } } + std::stable_sort(allObjects.rbegin(), allObjects.rend()); for (const auto &objectWrapper: allObjects) { From f1462ccc462596fcc9e950f1f6239f8baa00f155 Mon Sep 17 00:00:00 2001 From: Marco Zimmermann Date: Wed, 10 Jan 2024 20:01:30 +0100 Subject: [PATCH 4/6] remove zoom dependant feature calculation --- shared/public/Value.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/public/Value.h b/shared/public/Value.h index c66b2ab67..479308667 100644 --- a/shared/public/Value.h +++ b/shared/public/Value.h @@ -629,7 +629,7 @@ class Value { template class ValueEvaluator { public: - inline ResultType getResult(const std::shared_ptr &value, const EvaluationContext &context, const ResultType defaultValue) { + inline ResultType getResult(const std::shared_ptr &value, const EvaluationContext &context, const ResultType &defaultValue) { std::lock_guard lock(mutex); if (!value) { return defaultValue; @@ -637,7 +637,7 @@ class ValueEvaluator { if (lastValuePtr != value.get()) { lastResults.clear(); staticValue = std::nullopt; - const auto usedKeysCollection = value->getUsedKeys(); + const auto &usedKeysCollection = value->getUsedKeys(); isStatic = usedKeysCollection.empty(); if (isStatic) { staticValue = value->evaluateOr(context, defaultValue); @@ -652,12 +652,12 @@ class ValueEvaluator { return *staticValue; } - if(isStateDependant && isZoomDependent && !context.featureStateManager->empty()) { + if((isStateDependant && !context.featureStateManager->empty()) || isZoomDependent) { return value->evaluateOr(context, defaultValue); } - auto identifier = (context.feature->identifier << 12) | (uint64_t)((isZoomDependent ? context.zoomLevel : 0.f) * 100); + auto identifier = context.feature->identifier; if(isStateDependant && !context.featureStateManager->empty()) { identifier = (context.feature->identifier << 32) | (uint64_t)(context.featureStateManager->getCurrentState()); } From d49f2ef628907c4bd32e0b06e37d67c9df8fa60c Mon Sep 17 00:00:00 2001 From: Marco Zimmermann Date: Wed, 10 Jan 2024 20:02:07 +0100 Subject: [PATCH 5/6] improve collision grid performance and fix radius --- shared/public/CollisionGrid.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/shared/public/CollisionGrid.h b/shared/public/CollisionGrid.h index 75e7f7df4..c12feadec 100644 --- a/shared/public/CollisionGrid.h +++ b/shared/public/CollisionGrid.h @@ -42,7 +42,7 @@ struct IndexRange { } } - bool isValid(int16_t maxX, int16_t maxY) { + bool isValid(int16_t maxX, int16_t maxY) const { return xMin <= maxX && xMax >= 0 && yMin <= maxY && yMax >= 0; } }; @@ -72,8 +72,8 @@ class CollisionGrid { * return true (1) if collision, or true (2) if outside of bounds */ uint8_t addAndCheckCollisionAlignedRect(const CollisionRectF &rectangle) { - RectF projectedRectangle = getProjectedRectangle(rectangle); - IndexRange indexRange = getIndexRangeForRectangle(projectedRectangle); + const RectF &projectedRectangle = getProjectedRectangle(rectangle); + const IndexRange &indexRange = getIndexRangeForRectangle(projectedRectangle); if (!indexRange.isValid(numCellsX - 1, numCellsY - 1)) { return 2; // Fully outside of bounds - not relevant } @@ -215,22 +215,22 @@ class CollisionGrid { temp2[2] = 0.0; temp2[3] = 1.0; Matrix::multiply(vpMatrix, temp2, temp1); - float originX = ((temp1.at(0) / temp1.at(3)) * halfWidth + halfWidth); - float originY = ((temp1.at(1) / temp1.at(3)) * halfHeight + halfHeight); + float originX = ((temp1[0] / temp1[3]) * halfWidth + halfWidth); + float originY = ((temp1[1] / temp1[3]) * halfHeight + halfHeight); temp2[0] = rectangle.width * cosNegGridAngle; temp2[1] = rectangle.width * sinNegGridAngle; temp2[2] = 0.0; temp2[3] = 0.0; Matrix::multiply(vpMatrix, temp2, temp1); - float w = temp1.at(0); - float h = temp1.at(1); + float w = temp1[0]; + float h = temp1[1]; temp2[0] = -rectangle.height * sinNegGridAngle; temp2[1] = rectangle.height * cosNegGridAngle; temp2[2] = 0.0; temp2[3] = 0.0; Matrix::multiply(vpMatrix, temp2, temp1); - w += temp1.at(0); - h += temp1.at(1); + w += temp1[0]; + h += temp1[1]; float width = (w * halfWidth); // by assumption aligned with projected space float height = (h * halfHeight); // by assumption aligned with projected space originX = std::min(originX, originX + width); @@ -245,16 +245,16 @@ class CollisionGrid { temp2[2] = 0.0; temp2[3] = 1.0; Matrix::multiply(vpMatrix, temp2, temp1); - float originX = ((temp1.at(0) / temp1.at(3)) * halfWidth + halfWidth); - float originY = ((temp1.at(1) / temp1.at(3)) * halfHeight + halfHeight); + float originX = ((temp1[0] / temp1[3]) * halfWidth + halfWidth); + float originY = ((temp1[1] / temp1[3]) * halfHeight + halfHeight); temp2[0] = circle.radius; temp2[1] = circle.radius; temp2[2] = 0.0; temp2[3] = 0.0; Matrix::multiply(vpMatrix, temp2, temp1); - temp1.at(0) = temp1.at(0) * halfWidth; - temp1.at(1) = temp1.at(1) * halfHeight; - float iRadius = std::abs((std::sqrt(temp1.at(0) * temp1.at(0) + temp1.at(1) + temp1.at(1)))); + temp1[0] = temp1[0] * halfWidth; + temp1[1] = temp1[1] * halfHeight; + float iRadius = std::sqrt(temp1[0] * temp1[0] + temp1[1] * temp1[1]); return {originX, originY, iRadius}; } From b4442ea4202cd43c89343825ff485015123448f3 Mon Sep 17 00:00:00 2001 From: Christoph Maurhofer Date: Mon, 15 Jan 2024 16:54:44 +0100 Subject: [PATCH 6/6] Remove move in copy constructor --- .../layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h b/shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h index c9edd6b78..c19b713b0 100644 --- a/shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h +++ b/shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h @@ -24,7 +24,7 @@ class SymbolObjectCollisionWrapper { isColliding(object->animationCoordinator->isColliding()) {}; SymbolObjectCollisionWrapper(const SymbolObjectCollisionWrapper& other) noexcept - : symbolObject(std::move(other.symbolObject)), + : symbolObject(other.symbolObject), symbolSortKey(other.symbolSortKey), symbolTileIndex(other.symbolTileIndex), isColliding(other.isColliding) {}