mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-12-22 15:44:11 +00:00
feat(Blenvy:Blender): started upgrading code relevant to save/load, dynamic entities etc
* using some of the newer components api to determine if an object/its collection is dynamic or not
This commit is contained in:
parent
3a528e447a
commit
ae9f07f549
@ -1,12 +1,14 @@
|
||||
import bpy
|
||||
|
||||
from ...bevy_components.components.metadata import get_bevy_component_value_by_long_name
|
||||
|
||||
# checks if an object is dynamic
|
||||
# TODO: for efficiency, it might make sense to write this flag semi automatically at the root level of the object so we can skip the inner loop
|
||||
# TODO: we need to recompute these on blueprint changes too
|
||||
# even better, keep a list of dynamic objects per scene , updated only when needed ?
|
||||
def is_object_dynamic(object):
|
||||
is_dynamic = object['Dynamic'] if 'Dynamic' in object else False
|
||||
is_dynamic = get_bevy_component_value_by_long_name(object, 'blenvy::save_load::Dynamic') is not None
|
||||
#is_dynamic = object['Dynamic'] if 'Dynamic' in object else False
|
||||
# only look for data in the original collection if it is not alread marked as dynamic at instance level
|
||||
if not is_dynamic and object.type == 'EMPTY' and hasattr(object, 'instance_collection') and object.instance_collection is not None :
|
||||
#print("collection", object.instance_collection, "object", object.name)
|
||||
@ -14,15 +16,18 @@ def is_object_dynamic(object):
|
||||
collection_name = object.instance_collection.name
|
||||
original_collection = bpy.data.collections[collection_name]
|
||||
|
||||
is_dynamic = get_bevy_component_value_by_long_name(original_collection, 'blenvy::save_load::Dynamic') is not None
|
||||
# scan original collection, look for a 'Dynamic' flag
|
||||
for object in original_collection.objects:
|
||||
"""for object in original_collection.objects:
|
||||
#print(" inner", object)
|
||||
if object.type == 'EMPTY' and object.name.endswith("components"):
|
||||
if object.type == 'EMPTY': #and object.name.endswith("components"):
|
||||
for component_name in object.keys():
|
||||
#print(" compo", component_name)
|
||||
if component_name == 'Dynamic':
|
||||
is_dynamic = True
|
||||
break
|
||||
break"""
|
||||
print("IS OBJECT DYNAMIC", object, is_dynamic)
|
||||
|
||||
return is_dynamic
|
||||
|
||||
def is_object_static(object):
|
||||
|
@ -1,10 +1,8 @@
|
||||
import os
|
||||
import bpy
|
||||
from pathlib import Path
|
||||
|
||||
from blenvy.core.helpers_collections import (traverse_tree)
|
||||
from blenvy.core.object_makers import make_cube
|
||||
from blenvy.materials.materials_helpers import add_material_info_to_objects, get_all_materials
|
||||
from ..common.generate_temporary_scene_and_export import generate_temporary_scene_and_export
|
||||
from ..common.export_gltf import (generate_gltf_export_settings)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user