feat(): added 'animated' flag component (wip) to mark any worlds/blueprints entities that have animations

* allows to not be restricted by bevy's a bit weird logic for AnimationPlayers
 * updated crate & tooling
 * updated testing example with a bit more complex nesting cases for testing
This commit is contained in:
kaosat.dev 2024-03-19 22:12:37 +01:00
parent 7584078f6d
commit c2f09fbf22
4 changed files with 17 additions and 1 deletions

View File

@ -14,3 +14,7 @@ pub struct Animations {
/// this is for convenience, because currently , Bevy's gltf parsing inserts `AnimationPlayers` "one level down" /// this is for convenience, because currently , Bevy's gltf parsing inserts `AnimationPlayers` "one level down"
/// ie armature/root for animated models, which means more complex queries to trigger animations that we want to avoid /// ie armature/root for animated models, which means more complex queries to trigger animations that we want to avoid
pub struct AnimationPlayerLink(pub Entity); pub struct AnimationPlayerLink(pub Entity);
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct Animated;

View File

@ -120,6 +120,7 @@ impl Plugin for BlueprintsPlugin {
.register_type::<MaterialInfo>() .register_type::<MaterialInfo>()
.register_type::<SpawnHere>() .register_type::<SpawnHere>()
.register_type::<Animations>() .register_type::<Animations>()
.register_type::<Animated>()
.register_type::<BlueprintsList>() .register_type::<BlueprintsList>()
.register_type::<Vec<String>>() .register_type::<Vec<String>>()
.register_type::<HashMap<String, Vec<String>>>() .register_type::<HashMap<String, Vec<String>>>()

View File

@ -112,6 +112,15 @@ def copy_hollowed_collection_into(source_collection, destination_collection, par
get_sub_collections([object.instance_collection], root_node, children_per_collection) get_sub_collections([object.instance_collection], root_node, children_per_collection)
empty_obj["BlueprintsList"] = f"({json.dumps(dict(children_per_collection))})" empty_obj["BlueprintsList"] = f"({json.dumps(dict(children_per_collection))})"
#empty_obj["Assets"] = {"Animations": [], "Materials": [], "Models":[], "Textures":[], "Audio":[], "Other":[]} #empty_obj["Assets"] = {"Animations": [], "Materials": [], "Models":[], "Textures":[], "Audio":[], "Other":[]}
if object.animation_data:
print("I have animation data")
ad = object.animation_data
if ad.action:
print(object.name,'uses',ad.action.name)
for t in ad.nla_tracks:
for s in t.strips:
print(object.name,'uses',s.action.name)
empty_obj['Animated'] = '()'
copy_animation_data(object, empty_obj) copy_animation_data(object, empty_obj)
# we copy custom properties over from our original object to our empty # we copy custom properties over from our original object to our empty
@ -126,6 +135,8 @@ def copy_hollowed_collection_into(source_collection, destination_collection, par
copy = duplicate_object_recursive(object, None, destination_collection) copy = duplicate_object_recursive(object, None, destination_collection)
if parent_empty is not None: if parent_empty is not None:
copy.parent = parent_empty copy.parent = parent_empty
if object.animation_data:
copy['Animated'] = '()'
# for every sub-collection of the source, copy its content into a new sub-collection of the destination # for every sub-collection of the source, copy its content into a new sub-collection of the destination
for collection in source_collection.children: for collection in source_collection.children: