Skip to content

Conversation

@danvervlad
Copy link
Contributor

@danvervlad danvervlad commented Sep 16, 2025

Summary

This PR disables hitbox updates for SpineRuntimeObject by making updateHitBoxes() a no-op and leaving hitBoxes empty. Continuously invalidating and recomputing hitboxes provided no benefit and added per-frame overhead.

Context & motivation

  • Spine animations update every frame, which previously triggered invalidateHitboxes() often.
  • Making updateHitBoxes() a no-op removes wasted work and reduces CPU usage in scenes with multiple Spine animations.

What’s changed

  • Extensions/Spine/spineruntimeobject.ts: updateHitBoxes() is now intentionally empty; hitBoxes remains empty for Spine objects. Other calls to invalidateHitboxes() remain but will not trigger any heavy recomputation for Spine.

@4ian
Copy link
Owner

4ian commented Sep 16, 2025

Hi!

Thanks for the PR. This will remove entirely hitboxes for this kind of object, is that right?
That's a bit risky when it's used for actual collision or boundary checks in some games.
Instead, I think we could only have the hitboxes invalidated when the object is moved or animation changed (during an animation, the hitboxes would not change). This could already help a lot reducing unnecessary CPU usage.

@danvervlad
Copy link
Contributor Author

Hi!

Thanks for the PR. This will remove entirely hitboxes for this kind of object, is that right? That's a bit risky when it's used for actual collision or boundary checks in some games. Instead, I think we could only have the hitboxes invalidated when the object is moved or animation changed (during an animation, the hitboxes would not change). This could already help a lot reducing unnecessary CPU usage.

Hi! During animation, parts of spine can move out of previous boundaries, so I guess, that was the reason of placing invalidateHitboxes() in update(). I think moving invalidateHitboxes() from update() to setAnimation*() methods will not update hit boxes correctly.
image

What's your opinion regarding these options?

  1. Add custom "static" hitbox for runtime object from GDevelop UI. It will be updated on changing transform of RuntimeObject, but not on its content. It can be like "Behavior" which you can add to object. I understand, it's long term complex task.
  2. Add global flag for SpineRuntimeObject, to turn off hitbox calculations from the code.

@4ian
Copy link
Owner

4ian commented Sep 26, 2025

Hello @danvervlad! After thinking a bit more about this, I think it's safer and faster to start with a global flag, or a property in the Spine Runtime object that can be toggled on/off from the object editor/object panel, to deactivate hitboxes update.
I think it's still important to return hitboxes, but they can be never updated when the flag is set.

@danvervlad
Copy link
Contributor Author

danvervlad commented Sep 30, 2025

Hi @4ian! What do you think about global static flag for SpineRuntimeObject to disable hitboxes update, as a quick solution, which I've just committed?

@4ian 4ian marked this pull request as ready for review October 3, 2025 16:29
@4ian 4ian self-requested a review as a code owner October 3, 2025 16:29
@4ian 4ian merged commit 77f8212 into 4ian:master Oct 3, 2025
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants