rayxuln / spine-runtime-for-godot

This project is a module for godot that allows it to load/play Spine skeleton animation.
MIT License
93 stars 22 forks source link

add_child single frame flicker #45

Open stefano-elysium opened 2 years ago

stefano-elysium commented 2 years ago

if I change the parent of my spine sprite, it becomes transparent for a single frame. Is there a way to avoid this? I've been looking through the source but I can't find where it comes from.

stefano-elysium commented 2 years ago

Might be this check???

void SpineSprite::_update_all(float delta) {
    if (!(skeleton.is_valid() && animation_state.is_valid()) || mesh_instances.empty())
        return;
rayxuln commented 2 years ago

How do you change the parent?

stefano-elysium commented 2 years ago

How do you change the parent?

    var pos = obj.global_position;
    var scale = obj.global_scale;
    obj.get_parent().remove_child(obj);
    newparent.add_child(obj);
    obj.global_scale = scale;
    obj.global_position = pos;

I have to do this otherwise it moves the spinesprite around.

rayxuln commented 2 years ago

Not sure if it's a Godot bug or this module bug.

Could you provide a demo project?

stefano-elysium commented 2 years ago

@rayxuln testflicker.zip This flickers like crazy on my screen. If you comment out the delay, the lantern doesn't appear at all.

stefano-elysium commented 2 years ago

Interesting behaviour: if you change it to _physics_process, it doesn't flicker. In my case, I can add yield(get_tree(), "physics_frame"); before doing the switch... Weird behaviour!

stefano-elysium commented 2 years ago

Using yield(VisualServer, "frame_post_draw"); and yield(VisualServer, "frame_pre_draw"); also stops the flickering

stefano-elysium commented 2 years ago

@rayxuln do you have any updates?