Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarDrawable.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-25 18:12:54 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-25 18:12:54 +1000
commit7d205330dbf1c2fd44d9d58393ab46434ac8bb5e (patch)
treee73db06236120e2399f0b4863257477eec528295 /source/game/StarDrawable.cpp
parente2424b7dcf60d18b277b092eb7f2a947fff27415 (diff)
More directives optimization
Diffstat (limited to 'source/game/StarDrawable.cpp')
-rw-r--r--source/game/StarDrawable.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/game/StarDrawable.cpp b/source/game/StarDrawable.cpp
index aeb8cb6..90b36c5 100644
--- a/source/game/StarDrawable.cpp
+++ b/source/game/StarDrawable.cpp
@@ -29,6 +29,28 @@ Drawable::ImagePart& Drawable::ImagePart::addDirectives(Directives const& direct
return *this;
}
+Drawable::ImagePart& Drawable::ImagePart::addDirectivesGroup(DirectivesGroup const& directivesGroup, bool keepImageCenterPosition) {
+ if (directivesGroup.empty())
+ return *this;
+
+ if (keepImageCenterPosition) {
+ auto imageMetadata = Root::singleton().imageMetadataDatabase();
+ Vec2F imageSize = Vec2F(imageMetadata->imageSize(image));
+ for (Directives const& directives : directivesGroup.list())
+ image.directives += directives;
+ Vec2F newImageSize = Vec2F(imageMetadata->imageSize(image));
+
+ // If we are trying to maintain the image center, PRE translate the image by
+ // the change in size / 2
+ transformation *= Mat3F::translation((imageSize - newImageSize) / 2);
+ } else {
+ for (Directives const& directives : directivesGroup.list())
+ image.directives += directives;
+ }
+
+ return *this;
+}
+
Drawable::ImagePart& Drawable::ImagePart::removeDirectives(bool keepImageCenterPosition) {
if (keepImageCenterPosition) {
auto imageMetadata = Root::singleton().imageMetadataDatabase();