-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial conversion and error fixing * Better static typing * Replace dictionaries with classes for better static typing There seems to be a tiny performance increase with this * Change stretch mode from "2d" to "canvas_item" 2d was the Godot 3.x name of the mode and is no longer valid in Godot 4.x * Put an AspectRatioContainer node for the texture in the main scene
- Loading branch information
1 parent
2804e61
commit 5d65d2f
Showing
6 changed files
with
167 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
extends TextureRect | ||
|
||
var rect_data: Dictionary | ||
var rect_data: RegionUnpacker.RectData | ||
|
||
# roughly 665886 with old imp | ||
func _on_Button_pressed() -> void: | ||
var time = Time.get_ticks_usec() | ||
var unpak := RegionUnpacker.new(10, 3) | ||
rect_data = unpak.get_used_rects(texture.get_data()) | ||
$Control.show_preview(rect_data["rects"]) | ||
rect_data = unpak.get_used_rects(texture.get_image()) | ||
$Control.show_preview(rect_data.rects) | ||
print(Time.get_ticks_usec() - time) | ||
|
||
|
||
|
||
func _on_Texture_item_rect_changed() -> void: | ||
if "rects" in rect_data.keys(): | ||
$Control.show_preview(rect_data["rects"]) | ||
if is_instance_valid(rect_data) and not rect_data.rects.is_empty(): | ||
$Control.show_preview(rect_data.rects) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,47 @@ | ||
[gd_scene load_steps=4 format=2] | ||
[gd_scene load_steps=4 format=3 uid="uid://d35eiq1krfqyk"] | ||
|
||
[ext_resource path="res://Example/Texture.gd" type="Script" id=1] | ||
[ext_resource path="res://Example/example sheet.png" type="Texture" id=2] | ||
[ext_resource path="res://addons/SmartSlicer/SmartSlicePreview.gd" type="Script" id=3] | ||
[ext_resource type="Script" path="res://Example/Texture.gd" id="1"] | ||
[ext_resource type="Texture2D" uid="uid://bwh16a5td5gwe" path="res://Example/example sheet.png" id="2"] | ||
[ext_resource type="Script" path="res://addons/SmartSlicer/SmartSlicePreview.gd" id="3"] | ||
|
||
[node name="Texture" type="TextureRect"] | ||
[node name="Control" type="Control"] | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
texture = ExtResource( 2 ) | ||
stretch_mode = 6 | ||
script = ExtResource( 1 ) | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
|
||
[node name="Control" type="Control" parent="."] | ||
[node name="AspectRatioContainer" type="AspectRatioContainer" parent="."] | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
script = ExtResource( 3 ) | ||
offset_right = 1.0 | ||
offset_bottom = -2.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
ratio = 1.9912 | ||
|
||
[node name="Texture" type="TextureRect" parent="AspectRatioContainer"] | ||
layout_mode = 2 | ||
texture = ExtResource("2") | ||
stretch_mode = 5 | ||
script = ExtResource("1") | ||
|
||
[node name="Control" type="Control" parent="AspectRatioContainer/Texture"] | ||
anchors_preset = 0 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
script = ExtResource("3") | ||
|
||
[node name="Button" type="Button" parent="."] | ||
margin_left = 791.0 | ||
margin_top = 495.0 | ||
margin_right = 984.0 | ||
margin_bottom = 563.0 | ||
layout_mode = 0 | ||
offset_left = 791.0 | ||
offset_top = 495.0 | ||
offset_right = 984.0 | ||
offset_bottom = 563.0 | ||
text = "Slice" | ||
|
||
[connection signal="item_rect_changed" from="." to="." method="_on_Texture_item_rect_changed"] | ||
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"] | ||
[connection signal="item_rect_changed" from="AspectRatioContainer/Texture" to="AspectRatioContainer/Texture" method="_on_Texture_item_rect_changed"] | ||
[connection signal="pressed" from="Button" to="AspectRatioContainer/Texture" method="_on_Button_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/example sheet.png-0360b514ecb50cc6e83b9cd009b2aff9.stex" | ||
type="CompressedTexture2D" | ||
uid="uid://bwh16a5td5gwe" | ||
path="res://.godot/imported/example sheet.png-0360b514ecb50cc6e83b9cd009b2aff9.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://Example/example sheet.png" | ||
dest_files=[ "res://.import/example sheet.png-0360b514ecb50cc6e83b9cd009b2aff9.stex" ] | ||
dest_files=["res://.godot/imported/example sheet.png-0360b514ecb50cc6e83b9cd009b2aff9.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=false | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
process/normal_map_invert_y=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Oops, something went wrong.