Resonite-Issues icon indicating copy to clipboard operation
Resonite-Issues copied to clipboard

ActiveInHierarchyDriver

Open bdunderscore opened this issue 7 months ago • 6 comments

Is your feature request related to a problem? Please describe.

I'd like to disable DynamicBones for which the corresponding mesh is disabled. To do this I'd like to be able to find whether the meshes that reference it are active. While obtaining ActiveSelf is easy, getting the active state of the object is harder.

Describe the solution you'd like

An ActiveInHierarchyDriver that drives a bool field with the overall active state of its own (or another?) slot.

Describe alternatives you've considered

Using protoflux OnActivate/OnDeactivate is an option, but harder if you want to generically support active fields that are potentially driven by unsynced systems, and requires multiple slots to be attached to meshes throughout your avatar, adding more on-load overhead and cluttering the hierarchy. Additionally, it's unclear if this might get out of sync if an object is loaded in an initially-inactive state. It would be a lot simpler to just have a driver for it...

Additional Context

No response

Requesters

bd_

bdunderscore avatar May 24 '25 04:05 bdunderscore

This seems like a really good, generally useful feature!

anquietas-sys avatar May 24 '25 04:05 anquietas-sys

This is like... Very awesome idea. Massive w idea Maybe we could also get it for persistant as well?

Redd56 avatar May 24 '25 04:05 Redd56

What are the reasons that using the Get Active (for whichever target slots you're interested in) and/or Get Component Enabled ProtoFlux nodes aren't sufficient for this? Get Active will return false if a slot is itself active, but is present under an inactive parent.

Zyzyl avatar May 24 '25 05:05 Zyzyl

Protoflux drives won't execute when inactive, so this would require the detection logic to live outside of the object being detected.

bdunderscore avatar May 24 '25 17:05 bdunderscore

Ah I see. So a component that would drive a bool field based on wether it itself (or rather the slot it's attached to) is in an enabled or disabled hierarchy, and would also update correctly when it's in a disabled hierarchy (Because some components also stop updating when they are in an inactive hierarchy, that's not exclusive to ProtoFlux).

Yeah I can see the use of that!

JackTheFoxOtter avatar May 24 '25 17:05 JackTheFoxOtter

Yes. One potential use would be something like:

  • ActiveInHierarchyDriver drives BooleanDriver
  • BooleanDriver drives a DynamicValueVariable's variable name field to null when false, Avatar/DynamicBone_Foo_Enable when true
  • DynamicValueVariable is set to value true and OverrideOnLink

Attach this to a mesh that is deformed by DynamicBone_Foo, and have a DynamicVariableDriver on the dynamic bone to activate it only when the DV is true.

The nice thing about this construction is it's composable - I can delete the mesh permanently without breaking anything, or I can add it after the fact, and it all composes into a nice implicit OR gate automatically.

bdunderscore avatar May 24 '25 18:05 bdunderscore