Skip to content

Commit 04234f3

Browse files
Fixed various 3d layer bugs (#1439)
* Add support for animated layer effects and a keyframe-based timeline (#1417) * Start working on animatable layer effects * Interpolate colors & animated effects work on apply * Add nodes to change tween properties * Use smaller texts for the tween property option buttons * Fix crash when enabling animation, disabling and enabling it again * Remove keyframes * Load and save animated parameters in pxo files * Format * Start working on a keyframe based timeline * Create keyframes in the UI * Start working on keyframe value changing * Remove animated layer effect code from the layer FX settings * Refactor animated_params dictionary * Probably fix pxo loading At least old pxo files seem to be working properly * Update timeline when adding/removing keyframes * Use a tree for the layer elements Need to implement folding logic for the keyframes themselves though * Add a timeline cursor * Improve cursor moving logic * More timeline cursor improvements * Some UI improvements * Make timeline a bit prettier * Fix animated params pxo loading * Some small improvements * Fix scrolling * Don't create keyframe if there already is one * Fix frame container not resizing when clicking on keyframes * Added Constant transition * Add undo/redo when adding and deleting keyframes * Fix keyframe unselection * Start working on multiple selected keyframes * Change name of a script * Change properties of all selected keyframes With undo/redo support * [WIP] Move keyframes While it technically works, the UI side is not being updated. Also, I just realized that the way we're handling keyframe creation and deletion is wrong, because the nodes get freed when switching to a different layer, or a different project. So we most likely should just re-create the keyframe nodes when we add, delete or move them. Which means I also need to change the selected_keyframes array to store param_name and frame_index, instead of nodes. * Add IDs to keyframes for easier handling * Don't allow keyframes to go below frame 0 Mostly so they can't be lost. The proper solution would be to support negative frames, like Godot's animation player editor does, but this should work for now. * Zoom in the timeline * Support booleans and colors, scroll timeline when changing cel or layer * Implement the keyframe timeline inside the main timeline panel I feel like the UI does need some improvements still * Make properties grid container and delete keyframe button persistent nodes * Undo/redo refreshes the keyframe property UI * Hide tags when keyframe timeline is visible * Fix property nodes not having the correct name * Use a custom node to draw frames instead of using labels * Fix group layers passthrough mode not having its effect be animated * Don't create tracks for properties that currently cannot be animated Such as textures * Better documentation and future-proofing * Keyframe Animation QOL inprovements (#1420) * Fix keyframe getting created at the wrong frame when the uses right clicks at the same 'x-position' as the frame marking * Hide extra UI when no FX are present * formatting * Rename _hide_extra_UI to _hide_extra_ui Fix linting error --------- Co-authored-by: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> * Fix tracks being created twice if a project is loaded on startup * Some more futureproofing of the keyframe timeline code * Allow non-integer values in keyframe property sliders * QOL improvements when adding or selecting keyframes (#1423) * Add support for animated layer effects and a keyframe-based timeline (#1417) * Start working on animatable layer effects * Interpolate colors & animated effects work on apply * Add nodes to change tween properties * Use smaller texts for the tween property option buttons * Fix crash when enabling animation, disabling and enabling it again * Remove keyframes * Load and save animated parameters in pxo files * Format * Start working on a keyframe based timeline * Create keyframes in the UI * Start working on keyframe value changing * Remove animated layer effect code from the layer FX settings * Refactor animated_params dictionary * Probably fix pxo loading At least old pxo files seem to be working properly * Update timeline when adding/removing keyframes * Use a tree for the layer elements Need to implement folding logic for the keyframes themselves though * Add a timeline cursor * Improve cursor moving logic * More timeline cursor improvements * Some UI improvements * Make timeline a bit prettier * Fix animated params pxo loading * Some small improvements * Fix scrolling * Don't create keyframe if there already is one * Fix frame container not resizing when clicking on keyframes * Added Constant transition * Add undo/redo when adding and deleting keyframes * Fix keyframe unselection * Start working on multiple selected keyframes * Change name of a script * Change properties of all selected keyframes With undo/redo support * [WIP] Move keyframes While it technically works, the UI side is not being updated. Also, I just realized that the way we're handling keyframe creation and deletion is wrong, because the nodes get freed when switching to a different layer, or a different project. So we most likely should just re-create the keyframe nodes when we add, delete or move them. Which means I also need to change the selected_keyframes array to store param_name and frame_index, instead of nodes. * Add IDs to keyframes for easier handling * Don't allow keyframes to go below frame 0 Mostly so they can't be lost. The proper solution would be to support negative frames, like Godot's animation player editor does, but this should work for now. * Zoom in the timeline * Support booleans and colors, scroll timeline when changing cel or layer * Implement the keyframe timeline inside the main timeline panel I feel like the UI does need some improvements still * Make properties grid container and delete keyframe button persistent nodes * Undo/redo refreshes the keyframe property UI * Hide tags when keyframe timeline is visible * Fix property nodes not having the correct name * Use a custom node to draw frames instead of using labels * Fix group layers passthrough mode not having its effect be animated * Don't create tracks for properties that currently cannot be animated Such as textures * Better documentation and future-proofing * Keyframe Animation QOL inprovements (#1420) * Fix keyframe getting created at the wrong frame when the uses right clicks at the same 'x-position' as the frame marking * Hide extra UI when no FX are present * formatting * Rename _hide_extra_UI to _hide_extra_ui Fix linting error --------- Co-authored-by: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> * Select newly added keyframe * only select keyframe if it's added for the first time * Improve selection of keyframes * Formatting * To move single keyframe, you no longer have to select it first * Formatting * Snap cursor to frame when drag is released * formatting --------- Co-authored-by: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> * Add a method in Global for creating nodes from variables Used for keyframe property node generation and for the future 3D layer object properties * Animate Basis variables as well * Use a hint_string parameter in create_node_from_variable * Add more options to V2, V3 and Basis sliders in Global.create_node_from_variable * Emit KeyframeButton.updated_position only when the position has changed Otherwise it is being called every time the user clicks on a keyframe button, filling the undo history with unnecessary actions * Fix steps, min and max values Needs extra checks to see if the min and max values are floats or ints, and if they are, make them be Vector2/3/Basis * Make Global.create_node_from_variable() handle Fonts and Textures * 3D Layer Rewrite (#1429) * Begin rewrite -- remove nodes from cel and add them to layer * Select objects * Improve object picking * Remove 3D object * Improve object picking again, make gizmos usable No undo/redo for property changing yet * Make lights pickable, besides the directional light Not entirely sure why RenderingServer.instances_cull_ray() does not pick up DirectionalLight3Ds, considering it picks the other light types and the documentation clearly states that it does pick up DirectionalLight3Ds * Undo redo for gizmos * Add a material to every newly added mesh * Start working on slider generation when selecting an object * Make sliders functional * Use an AnimationPlayer to store properties for each frame Does not currently animate properly because it needs each Cel3D to have a unique viewport texture, which only updates when the current cel is active * Make Cel3Ds use unique textures * 3D cel animation fixes * Fix image_texture regeneration when changing cel size * Remove tracks when removing a 3D node * Make undo/redo steps for track & key creation I don't like that they are separate steps, but this is the only way I could get it to work for now. * Pick lights from their gizmo positions * Node property nodes are now better categorized in multiple foldable containers * Change 3D text * Change fonts * Fix undoing adding and deleting not updating the canvas * Remove depracated code from Cel3D * Save and load scenes in pxo files * Refuse to load scenes that contain scripts in them * Add lights to gizmos when loading from pxo * Create a 3DObjectTree panel * Add the new panel to the UI * Give readable names to 3D nodes * Load GLTF files as 3D layers * Remove some sliders * Another attempt at unifying animation track and key creation with change of property This time it seems to be working well, fingers crossed. * Formatting/linting * Make get_points() work for non-VisualInstance3D nodes as well * Remove unused script * Support enums * More slider improvements * Support editing multiple materials in ArrayMeshes * Remove properties from WorldEnvironment * Fix canvas flickering when switching to a different 3D cel * Update current 3D cel when undoing/redoing a property on another cel Needed to update interpolated data * Remove unneeded RenderingServer.frame_post_draw At least it should be unneeded, more testing would be nice * Fix crash when loading a pre-v1.2 pxo with 3D layers * Use Global.create_node_from_variable() to generate property editing nodes * Update Global.create_node_from_variable() parameters * Load & modify textures * Modify image button now works better when there is no initial image and if that image has been modified while that node is active * Write code for detecting UV coords based on mouse position Can later be used for directly drawing on 3D models * Detect the correct surface in get_3d_node_uvs() * Start working on pencil support for 3D layers Undo does not work yet * Undo/redo support for drawing on primitive meshes * Undo/redo should now work properly for all cases of drawing on a 3D model * Raise pxo version * Show rotation in sliders in degrees * Fix position sliders having way too broad limits Not the most elegant solution but works for now. * Fix crash if a 3D object is selected during exit * Fix layer tools not updating when added at startup * Fixed Cut function on a 3d Cel Crashing the application --------- Co-authored-by: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com>
1 parent fe5cac3 commit 04234f3

4 files changed

Lines changed: 21 additions & 8 deletions

File tree

src/Autoload/Tools.gd

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,12 @@ func _ready() -> void:
413413
)
414414
assign_color(color_value, MOUSE_BUTTON_RIGHT, false)
415415
update_tool_cursors()
416-
var layer: BaseLayer = Global.current_project.layers[Global.current_project.current_layer]
417-
var layer_type := layer.get_layer_type()
418416

419-
# Await is necessary to hide irrelevant tools added by extensions
417+
# Await is necessary to hide tools irrelevant to the current layer (That may have been
418+
# added by extensions), And to make sure projects loaded at startup have correct visible tools
420419
await get_tree().process_frame
420+
var layer: BaseLayer = Global.current_project.layers[Global.current_project.current_layer]
421+
var layer_type := layer.get_layer_type()
421422
_show_relevant_tools(layer_type)
422423

423424

src/Classes/Cels/Cel3D.gd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ func size_changed(new_size: Vector2i) -> void:
2121
# Overridden methods
2222

2323

24-
func get_image() -> Image:
25-
return image_texture.get_image()
24+
func get_image() -> ImageExtended:
25+
var image := image_texture.get_image()
26+
if image:
27+
# We are returning an ImageExtended because it's required by selection-cut to work properly.
28+
var extended_image := ImageExtended.new()
29+
extended_image.copy_from_custom(image, false)
30+
return extended_image
31+
return null
2632

2733

2834
func duplicate_cel() -> Cel3D:

src/Tools/3DTools/3DShapeEdit.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ func _object_property_changed(object: Node, prop_name: String, frame_index: int)
194194
func _on_selected_object(object: Node3D, old_object: Node3D) -> void:
195195
if object == old_object:
196196
return
197-
get_tree().call_group(FOLDABLE_CONTAINER_GROUP_NAME, &"queue_free")
197+
if is_instance_valid(get_tree()): # Needed to avoid crash if an object is selected during exit.
198+
get_tree().call_group(FOLDABLE_CONTAINER_GROUP_NAME, &"queue_free")
198199
if is_instance_valid(object):
199200
_create_object_property_nodes(object)
200201
else:

src/UI/Canvas/Selection.gd

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ func _get_selected_draw_images(tile_cel_pointer: Array[CelTileMap]) -> Array[Ima
241241
tile_cel_pointer.append(cel)
242242
continue
243243
if project.layers[cel_index[1]].can_layer_get_drawn():
244-
images.append(cel.get_image())
244+
var image := cel.get_image()
245+
if is_instance_valid(image) and image is ImageExtended: # Avoid type conflicts
246+
images.append(cel.get_image())
245247
return images
246248

247249

@@ -488,7 +490,10 @@ func delete(selected_cels := true) -> void:
488490
if selected_cels:
489491
images = _get_selected_draw_images(tile_cels)
490492
else:
491-
images = [project.get_current_cel().get_image()]
493+
var current_cel_image := project.get_current_cel().get_image()
494+
# Avoid type conflict
495+
if is_instance_valid(current_cel_image) and current_cel_image is ImageExtended:
496+
images = [current_cel_image]
492497
if project.get_current_cel() is CelTileMap:
493498
if Tools.is_placing_tiles():
494499
images.clear()

0 commit comments

Comments
 (0)