Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/scene_builder/Commands/push_to_grid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func execute():

undo_redo.create_action("Snap to Grid")

var grid_size: float = 0.25 # Todo: this should be adjustable by the user
var grid_size: float = 1.0 # Todo: this should be adjustable by the user

for selected in selected_nodes:
if not selected is Node3D:
Expand Down
1 change: 1 addition & 0 deletions addons/scene_builder/icon_studio.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ shadow_enabled = true

[node name="Camera3D" type="Camera3D" parent="SubViewport"]
transform = Transform3D(0.866025, 0.12941, -0.482963, 0, 0.965926, 0.258819, 0.5, -0.224144, 0.836516, -5.62264, 3.24522, 9.7387)
projection = 1
fov = 60.0
2 changes: 1 addition & 1 deletion addons/scene_builder/scene_builder_commands.gd
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func _on_scene_submenu_item_selected(id: int):
SceneCommands.instantiate_in_a_row_1:
instantiate_in_a_row(1)
SceneCommands.instantiate_in_a_row_2:
instantiate_in_a_row(5)
instantiate_in_a_row(3)
SceneCommands.instantiate_in_a_row_3:
instantiate_in_a_row(10)
SceneCommands.push_to_grid:
Expand Down
2 changes: 0 additions & 2 deletions addons/scene_builder/scene_builder_config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ class_name SceneBuilderConfig

@export var root_dir: String = "res://Data/scene_builder/"
@export var disable_hotkeys: bool = false

@export_group("Command Palette")
@export var command_palette_key: Key = KEY_QUOTELEFT
19 changes: 0 additions & 19 deletions addons/scene_builder/scene_builder_config.tres
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,3 @@

[resource]
script = ExtResource("1_64inv")
root_dir = "res://Data/scene_builder/"
disable_hotkeys = false
instantiate_in_a_row_1 = 76
instantiate_in_a_row_2 = 59
instantiate_in_a_row_5 = 39
alphabetize_nodes = 48
reset_node_name = 78
change_places = 67
find_mismatched_types = 57
swap_nodes = 83
set_visibility = 72
reset_transform = 84
reset_transform_rotation = 82
push_to_grid = 80
push_parent_offset_to_child = 79
create_audio_stream_player_3d = 44
create_scene_builder_items = 47
create_standard_material_3d = 77
temporary_debug = 46
65 changes: 63 additions & 2 deletions addons/scene_builder/scene_builder_dock.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const TransformMode = SceneBuilderToolbox.TransformMode

@onready var config: SceneBuilderConfig = SceneBuilderConfig.new()

var _is_reloading: bool = false

# Paths
var data_dir: String = ""
var path_to_collection_names: String
Expand Down Expand Up @@ -43,6 +45,7 @@ var btn_parent_node_selector: Button
var btn_group_surface_orientation: ButtonGroup
var btn_find_world_3d: Button
var btn_reload_all_items: Button
var btn_clear_items: Button
var btn_force_root_node: CheckButton
# Fence Tool
var spinbox_spacing_multiplier: SpinBox
Expand Down Expand Up @@ -167,11 +170,13 @@ func _enter_tree() -> void:
#
btn_find_world_3d = scene_builder_dock.get_node("%FindWorld3D")
btn_reload_all_items = scene_builder_dock.get_node("%ReloadAllItems")
btn_clear_items = scene_builder_dock.get_node("%ClearItems")
btn_disable_hotkeys = scene_builder_dock.get_node("%DisableHotkeys")
btn_force_root_node = scene_builder_dock.get_node("%ForceRootNode")
btn_find_world_3d.pressed.connect(update_world_3d)
btn_reload_all_items.pressed.connect(reload_all_items)
btn_force_root_node.toggled.connect(on_force_root_toggled)
btn_clear_items.pressed.connect(clear_items)

# Fence Tool tab
spinbox_spacing_multiplier = scene_builder_dock.get_node("%Fence/SpacingMultiplier/SpinBox")
Expand Down Expand Up @@ -235,7 +240,7 @@ func _enter_tree() -> void:

func _delayed_reload():
await EditorInterface.get_resource_filesystem().filesystem_changed
reload_all_items()
await reload_all_items()


func _exit_tree() -> void:
Expand Down Expand Up @@ -624,6 +629,11 @@ func set_parent_node(node_path: NodePath) -> void:


func reload_all_items() -> void:
if _is_reloading:
print("[SceneBuilderDock] Reload already in progress, skipping")
return
_is_reloading = true

print("[SceneBuilderDock] Freeing all texture buttons")

# Free all existing buttons from all palettes
Expand All @@ -638,7 +648,29 @@ func reload_all_items() -> void:

print("[SceneBuilderDock] Loading all items from all collections")

# Load items for all palettes
# Collect all unique scene paths for batch thumbnail generation
var all_scene_paths: Array = []
var queued_paths: Dictionary = {}

for palette_idx in range(num_palettes):
var palette_collection_names = all_collection_names[palette_idx]
for i in range(num_collections):
var collection_name = palette_collection_names[i]
if collection_name != "" and collection_name != " ":
load_items_from_database(collection_name)
for key: String in ordered_keys_by_collection[collection_name]:
var item_data: Dictionary = items_by_collection[collection_name][key]
var uid = ResourceUID.text_to_id(item_data["uid"])
if not ResourceUID.has_id(uid):
continue
var scene_path = ResourceUID.get_id_path(uid)
if not queued_paths.has(scene_path):
queued_paths[scene_path] = true
all_scene_paths.append(scene_path)

var thumbnails = await thumbnail_generator.generate_thumbnails_batch(all_scene_paths)

# Create buttons using pre-generated thumbnails
for palette_idx in range(num_palettes):
var tc = tab_containers[palette_idx]
var palette_collection_names = all_collection_names[palette_idx]
Expand Down Expand Up @@ -685,6 +717,7 @@ func reload_all_items() -> void:
texture_button.add_child(nine_patch)

select_collection(0)
_is_reloading = false
print("[SceneBuilderDock] Reload complete")


Expand Down Expand Up @@ -1451,3 +1484,31 @@ func snap_scale_to_grid(scale: Vector3) -> Vector3:
round(scale.y / snap_amount) * snap_amount,
round(scale.z / snap_amount) * snap_amount
)


func clear_items() -> void:
# Clear thumbnail cache
var count = thumbnail_generator.thumbnail_cache.size()
thumbnail_generator.thumbnail_cache.clear()
print("[SceneBuilderDock] Thumbnail cache cleared (%d entries)" % count)

# Clear loaded collections
items_by_collection.clear()
ordered_keys_by_collection.clear()
item_highlighters_by_collection.clear()

# Free all texture buttons from all palettes
for palette_idx in range(num_palettes):
var tc = tab_containers[palette_idx]
for i in range(1, num_collections + 1):
var grid_container: GridContainer = tc.get_node("%s/Grid" % i)
for _node in grid_container.get_children():
_node.queue_free()

# Clear selection state
end_placement_mode()
selected_collection.clear()
selected_collection_name = ""
selected_collection_index = 0

print("[SceneBuilderDock] All items cleared")
21 changes: 12 additions & 9 deletions addons/scene_builder/scene_builder_dock.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ layout_mode = 2
[node name="TabContainer" type="TabContainer" parent="PaletteContainer/Palette 1"]
layout_mode = 2
size_flags_vertical = 3
current_tab = 3
current_tab = 1
tabs_visible = false

[node name="1" type="ScrollContainer" parent="PaletteContainer/Palette 1/TabContainer"]
Expand All @@ -280,7 +280,6 @@ size_flags_horizontal = 3
columns = 4

[node name="2" type="ScrollContainer" parent="PaletteContainer/Palette 1/TabContainer"]
visible = false
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
Expand All @@ -306,6 +305,7 @@ size_flags_horizontal = 3
columns = 4

[node name="4" type="ScrollContainer" parent="PaletteContainer/Palette 1/TabContainer"]
visible = false
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
Expand Down Expand Up @@ -837,7 +837,6 @@ horizontal_scroll_mode = 0
metadata/_tab_index = 1

[node name="Grid" type="GridContainer" parent="PaletteContainer/Palette 2/TabContainer/2"]
visible = false
custom_minimum_size = Vector2(32, 0)
layout_mode = 2
size_flags_horizontal = 3
Expand Down Expand Up @@ -1389,7 +1388,6 @@ horizontal_scroll_mode = 0
metadata/_tab_index = 1

[node name="Grid" type="GridContainer" parent="PaletteContainer/Palette 3/TabContainer/2"]
visible = false
custom_minimum_size = Vector2(32, 0)
layout_mode = 2
size_flags_horizontal = 3
Expand Down Expand Up @@ -1918,10 +1916,11 @@ layout_mode = 2
[node name="TabContainer" type="TabContainer" parent="PaletteContainer/Palette 4"]
layout_mode = 2
size_flags_vertical = 3
current_tab = 0
current_tab = 2
tabs_visible = false

[node name="1" type="ScrollContainer" parent="PaletteContainer/Palette 4/TabContainer"]
visible = false
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
Expand All @@ -1941,14 +1940,12 @@ horizontal_scroll_mode = 0
metadata/_tab_index = 1

[node name="Grid" type="GridContainer" parent="PaletteContainer/Palette 4/TabContainer/2"]
visible = false
custom_minimum_size = Vector2(32, 0)
layout_mode = 2
size_flags_horizontal = 3
columns = 4

[node name="3" type="ScrollContainer" parent="PaletteContainer/Palette 4/TabContainer"]
visible = false
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
Expand Down Expand Up @@ -2790,10 +2787,9 @@ layout_mode = 2
[node name="Tab" type="TabContainer" parent="Settings"]
custom_minimum_size = Vector2(320, 0)
layout_mode = 2
current_tab = 1
current_tab = 0

[node name="Options" type="VBoxContainer" parent="Settings/Tab"]
visible = false
layout_mode = 2
metadata/_tab_index = 0

Expand Down Expand Up @@ -2903,8 +2899,15 @@ layout_mode = 2
size_flags_vertical = 4
text = "Reload items"

[node name="ClearItems" type="Button" parent="Settings/Tab/Options/Bottom"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 4
text = "Clear Items"

[node name="Fence" type="VBoxContainer" parent="Settings/Tab"]
unique_name_in_owner = true
visible = false
layout_mode = 2
metadata/_tab_index = 1

Expand Down
Loading