Skip to content

Commit

Permalink
Feat: Build anim use SetDress world datablock (ynput#39)
Browse files Browse the repository at this point in the history
* added setdress world for build anim

* optimize setdress detection

* Update openpype/hosts/blender/scripts/build_workfile.py

Co-authored-by: Félix David <felixg.david@gmail.com>

---------

Co-authored-by: Félix David <felixg.david@gmail.com>
  • Loading branch information
kaamaurice and Tilix4 committed Dec 12, 2023
1 parent 958f191 commit c6e4670
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions openpype/hosts/blender/scripts/build_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,13 +589,19 @@ def build_anim(project_name, asset_name):

# Switch hero containers to versioned and linked setdress to appended
errors = []
setdress_container = None
for container in bpy.context.scene.openpype_containers:
container_metadata = container["avalon"]
family = container_metadata.get("family")

if family not in {"rig", "model", "setdress"}:
continue

# hold SetDress container
is_setdress = (family == "setdress")
if is_setdress and not setdress_container:
setdress_container = container

# Get version representation
current_version = get_version_by_id(
project_name,
Expand Down Expand Up @@ -637,7 +643,7 @@ def build_anim(project_name, asset_name):
)

# get loader
if family == "setdress":
if is_setdress:
loader_name = "AppendWoollySetdressLoader"
else:
loader_name = container_metadata.get("loader")
Expand All @@ -649,7 +655,7 @@ def build_anim(project_name, asset_name):
if (
current_version["_id"] != version_id
or container_metadata.get("loader") != loader_name
or family == "setdress" # force reload to relink world datablock
or is_setdress # force reload to relink world datablock
):
try:
switch_container(
Expand Down Expand Up @@ -677,6 +683,18 @@ def build_anim(project_name, asset_name):
bpy.data.collections.remove(gdeform_collection)
create_gdeformer_collection(bpy.context.scene.collection)

# Get world from setdress
setdress_world = None
if setdress_container:
for world in setdress_container.get_datablocks(bpy.types.World):
setdress_world = world

# Assign setdress or last loaded world
if setdress_world:
bpy.context.scene.world = setdress_world
else:
errors.append("World from SetDress not found!")

# Load camera
try:
cam_container, _cam_datablocks = load_subset(
Expand Down

0 comments on commit c6e4670

Please sign in to comment.