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

[godot] SpineSprite disappears when window is resized #2119

Closed
badlogic opened this issue Jul 19, 2022 · 8 comments
Closed

[godot] SpineSprite disappears when window is resized #2119

badlogic opened this issue Jul 19, 2022 · 8 comments
Labels

Comments

@badlogic
Copy link
Collaborator

Confirmed on Windows.

@Dssdiego
Copy link

Dssdiego commented Aug 4, 2022

This sometimes will cause flickering for low end PC's as well (when launching a game that contains multiple sprites in the same screen)

@Aeister
Copy link

Aeister commented Aug 16, 2022

Any news on the issue?

@badlogic badlogic added the bug label Sep 27, 2022
@tarragonfly
Copy link

This is a major reason why we can't use Spine for our next project. Hope this gets addressed sometime in the future.

@DASilverStraw
Copy link

I was able to stop SpineSprite from disappearing when the window is resizing by using this GDScript combination.

func _ready() -> void:
	self.get_tree().connect( 'screen_resized', self, '_on_scene_tree_screen_resized' )

func _on_scene_tree_screen_resized() -> void:
	VisualServer.force_draw()
	VisualServer.render_loop_enabled = false
	yield( self.get_tree(), 'idle_frame' )
	VisualServer.render_loop_enabled = true

@badlogic
Copy link
Collaborator Author

badlogic commented Feb 3, 2023 via email

@badlogic
Copy link
Collaborator Author

badlogic commented Feb 6, 2023 via email

@DASilverStraw
Copy link

The rendering of the debug options don't seem to be affected when resizing the window.
Sorry I haven't really looked into the cause of the issue.

@badlogic
Copy link
Collaborator Author

badlogic commented Feb 7, 2023

Spend most of the day figuring this out and finally fixed it.

SpineSprite would instantiate one MeshInstance2D per skeleton slot. Every frame, it would clear the meshes' canvas item, then set the new triangles via VisualServer::canvas_add_triangle_array(). That's actually "illegal" in the Godot world it seems. The method must be called by the MeshInstance2D node itself in the handler code for the NOTIFICATION_DRAW event.

I've fixed this by creating a custom Node2D called SpineMesh2D. It stores the triangles, indices, and material for a single slot in a skeleton. The SpineSprite updates those triangles, indices, and materials of every SpineMesh2D when it processes an update. The SpineMesh2D instances then are responsible for actually submitting the triangles to the VisualServer.

That fixes this issue and likely fixes other issues yet unseen/unnoticed related to "illegally" modifying the canvas item of child nodes outside their respective NOTIFICATION_DRAW handler code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

5 participants