Compare commits

..

1 Commits

Author SHA1 Message Date
Mark Moissette
3c20464e93
Merge a001ee21f6 into 9f21df035b 2024-03-20 16:58:21 +00:00
4 changed files with 12 additions and 42 deletions

View File

@ -17,6 +17,4 @@ pub struct AnimationPlayerLink(pub Entity);
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct Animated{
pub animations: Vec<String>
}
pub struct Animated;

View File

@ -3520,16 +3520,8 @@
"additionalProperties": false,
"isComponent": true,
"isResource": false,
"properties": {
"animations": {
"type": {
"$ref": "#/$defs/alloc::vec::Vec<alloc::string::String>"
}
}
},
"required": [
"animations"
],
"properties": {},
"required": [],
"short_name": "Animated",
"title": "bevy_gltf_blueprints::animation::Animated",
"type": "object",

View File

@ -25,40 +25,19 @@ def remove_unwanted_custom_properties(object):
del object[cp]
# TODO: rename actions ?
# reference https://github.com/KhronosGroup/glTF-Blender-IO/blob/main/addons/io_scene_gltf2/blender/exp/animation/gltf2_blender_gather_action.py#L481
def copy_animation_data(source, target):
"""if source.data:
data = source.data.copy()
target.data = data"""
if source.animation_data and source.animation_data:
#print("copying animation data from", source.name, "to", target.name)
print("I have animation data")
"""print("I have animation data")
ad = source.animation_data
"""if ad.action:
print(source.name,'uses',ad.action.name)"""
animations = []
blender_actions = []
blender_tracks = {}
# TODO: this might need to be modified/ adapted to match the standard gltf exporter settings
for track in ad.nla_tracks:
#print("track", track.name, track.active)
non_muted_strips = [strip for strip in track.strips if strip.action is not None and strip.mute is False]
for strip in non_muted_strips: #t.strips:
print(" ", source.name,'uses',strip.action.name, "active", strip.active, "action", strip.action)
blender_actions.append(strip.action)
blender_tracks[strip.action.name] = track.name
# Remove duplicate actions.
blender_actions = list(set(blender_actions))
# sort animations alphabetically (case insensitive) so they have a defined order and match Blender's Action list
blender_actions.sort(key = lambda a: a.name.lower())
for action in blender_actions:
animations.append(blender_tracks[action.name])
print("animations", animations)
if ad.action:
print(source.name,'uses',ad.action.name)
for t in ad.nla_tracks:
for s in t.strips:
print(source.name,'uses',s.action.name)"""
"""if target.animation_data == None:
target.animation_data_create()
@ -67,7 +46,7 @@ def copy_animation_data(source, target):
with bpy.context.temp_override(active_object=source, selected_editable_objects=[target]):
bpy.ops.object.make_links_data(type='ANIMATION')
# we add an "animated" flag component
target['Animated'] = f'(animations: {animations})'.replace("'", '"') #'(animations: [])' #
target['Animated'] = '()'
"""print("copying animation data for", source.name, target.animation_data)
properties = [p.identifier for p in source.animation_data.bl_rna.properties if not p.is_readonly]
for prop in properties:
@ -118,7 +97,8 @@ def duplicate_object(object, parent, combine_mode, destination_collection, libra
"""if object.parent == None:
if parent_empty is not None:
copy.parent = parent_empty
"""
if object.animation_data:
copy['Animated'] = '()'"""
print(nester, "copy", copy)
# do this both for empty replacements & normal copies