Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for rotated images #6

Merged
merged 3 commits into from
May 2, 2024
Merged

Fix for rotated images #6

merged 3 commits into from
May 2, 2024

Conversation

JCash
Copy link
Contributor

@JCash JCash commented May 1, 2024

Related PR: defold/defold#8874

@@ -88,7 +88,7 @@

<!-- If enabled TexturePacker allows the user to choose non-power-of-2 sizes for sprite
sheets. Otherwise, only power-of-2 (POT) sizes are enabled in the user interface. -->
<supportsNPOT>false</supportsNPOT>
<supportsNPOT>true</supportsNPOT>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well update the settings when updating the version number more officially to 1.1 as it's a bit of a turnaorund for the TP team to integrate the changes.

<writePivotPoints>trufalsee</writePivotPoints> <!-- true, false -->
<defaultPivotPoint>0.0,0.0</defaultPivotPoint>
<writePivotPoints>false</writePivotPoints> <!-- true, false -->
<defaultPivotPoint>0.5,0.5</defaultPivotPoint>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit coords. I.e. middle of our sprites which is exactly what we currently use.

@@ -130,8 +130,8 @@
<borderPadding>0</borderPadding>
<trimMode>Polygon</trimMode> <!-- None, Trim, Crop, CropKeepPos, Polygon -->
<sizeConstraints>POT</sizeConstraints> <!-- POT, WordAligned, AnySize -->
<writePivotPoints>trufalsee</writePivotPoints> <!-- true, false -->
<defaultPivotPoint>0.0,0.0</defaultPivotPoint>
<writePivotPoints>false</writePivotPoints> <!-- true, false -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only write the pivot if the user has enabled the check box for the sprite.

Comment on lines +25 to +26
default_texture_min_filter = nearest
default_texture_mag_filter = nearest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes it look a lot nicer when inspecting the test data

Comment on lines +142 to +143
float originalWidth = image.rotated ? image.rect.height : image.rect.width;
float originalHeight = image.rotated ? image.rect.width : image.rect.height;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the original size when using it with the vertices (as they're not rotated)

@@ -0,0 +1,48 @@
# The .tpinfo format
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a small readme, so that others may help writing exporters from other tools.

Comment on lines +219 to +224
// When rotated, the "top left" of the image is now the top right
// and we need to use the tight rect to find it
float corner_x = tightRect.getX() + tightRect.getWidth() + offsety;
float corner_y = tightRect.getY() - offsetx;
x = corner_x - originalSize.getHeight();
y = corner_y;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconstructing the rectangle when it's rotated, and also uses an offset.
Perhaps that's something that the .tpinfo format should provide, but that's for a future task.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a separate ticket for that to keep it in mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #7

@JCash JCash requested a review from AGulev May 2, 2024 09:04
Copy link
Contributor

@AGulev AGulev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It's a bit complicated logic with rotation, but as I remember we have similiar in the main atlas in bob as well

Comment on lines +219 to +224
// When rotated, the "top left" of the image is now the top right
// and we need to use the tight rect to find it
float corner_x = tightRect.getX() + tightRect.getWidth() + offsety;
float corner_y = tightRect.getY() - offsetx;
x = corner_x - originalSize.getHeight();
y = corner_y;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a separate ticket for that to keep it in mind?

@JCash JCash merged commit b2a4847 into main May 2, 2024
17 checks passed
@JCash JCash deleted the sprite-rotate-fix branch May 2, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants