Skip to content

Commit

Permalink
Merge pull request #172 from ynput/enhancement/AYON-Menu-_reorder-the…
Browse files Browse the repository at this point in the history
…-menu-items-to-more-following-the-workflow-logic

make the unreal settings more readable
  • Loading branch information
moonyuet authored Dec 8, 2024
2 parents b8d0d14 + ef94526 commit ec7e676
Show file tree
Hide file tree
Showing 18 changed files with 262 additions and 257 deletions.
22 changes: 11 additions & 11 deletions client/ayon_unreal/api/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,29 @@ def _job_finish_callback(job, success):
unreal.log("Individual job completed.")


def get_render_config(project_name, project_settings=None):
def get_render_config(project_name, project_render_settings=None):
"""Returns Unreal asset from render config.
Expects configured location of render config set in Settings. This path
must contain stored render config in Unreal project
Args:
project_name (str):
project_settings (dict): Settings from get_project_settings
project_settings (dict): Project render settings from get_project_settings
Returns
(str, uasset): path and UAsset
Raises:
RuntimeError if no path to config is set
"""
if not project_settings:
if not project_render_settings:
project_settings = get_project_settings(project_name)
project_render_settings = project_settings["unreal"]["unreal_setup"]

ar = unreal.AssetRegistryHelpers.get_asset_registry()
config_path = project_settings["unreal"]["render_config_path"]
config_path = project_render_settings["render_config_path"]

if not config_path:
raise RuntimeError("Please provide location for stored render "
"config in `ayon+settings://unreal/render_config_path`")
"config in `ayon+settings://unreal/render_setup/render_config_path`")

unreal.log(f"Configured config path {config_path}")
if not unreal.EditorAssetLibrary.does_asset_exist(config_path):
Expand Down Expand Up @@ -152,7 +153,8 @@ def start_rendering():
ar = unreal.AssetRegistryHelpers.get_asset_registry()

project_settings = get_project_settings(project_name)
_, config = get_render_config(project_name, project_settings)
render_settings = project_settings["unreal"]["render_setup"]
_, config = get_render_config(project_name, render_settings)

les = unreal.get_editor_subsystem(unreal.LevelEditorSubsystem)
current_level = les.get_current_level()
Expand Down Expand Up @@ -229,8 +231,8 @@ def start_rendering():
job_config.find_or_add_setting_by_class(
unreal.MoviePipelineDeferredPassBase)

render_format = project_settings.get("unreal").get("render_format",
"png")
render_format = render_settings.get("render_format",
"png")

set_output_extension_from_settings(render_format,
job_config)
Expand All @@ -239,9 +241,7 @@ def start_rendering():
if queue.get_jobs():
global executor
executor = unreal.MoviePipelinePIEExecutor()

preroll_frames = project_settings.get("unreal").get("preroll_frames",
0)
preroll_frames = render_settings.get("preroll_frames", 0)

settings = unreal.MoviePipelinePIEExecutorSettings()
settings.set_editor_property(
Expand Down
33 changes: 16 additions & 17 deletions client/ayon_unreal/plugins/load/load_alembic_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ class AnimationAlembicLoader(plugin.Loader):
def apply_settings(cls, project_settings):
super(AnimationAlembicLoader, cls).apply_settings(project_settings)
# Apply import settings
unreal_settings = project_settings.get("unreal", {})
if unreal_settings.get("abc_conversion_preset", cls.abc_conversion_preset):
cls.abc_conversion_preset = unreal_settings.get(
"abc_conversion_preset", cls.abc_conversion_preset)
if unreal_settings.get("loaded_asset_dir", cls.loaded_asset_dir):
cls.loaded_asset_dir = unreal_settings.get(
"loaded_asset_dir", cls.loaded_asset_dir)
if unreal_settings.get("show_dialog", cls.show_dialog):
cls.show_dialog = unreal_settings.get(
"show_dialog", cls.show_dialog)
unreal_settings = project_settings["unreal"]["import_settings"]
cls.abc_conversion_preset = unreal_settings["abc_conversion_preset"]
cls.loaded_asset_dir = unreal_settings["loaded_asset_dir"]
cls.show_dialog = unreal_settings["show_dialog"]

@classmethod
def get_options(cls, contexts):
Expand All @@ -48,7 +42,7 @@ def get_options(cls, contexts):
"abc_conversion_preset",
label="Alembic Conversion Preset",
items={
"custom": "custom",
"3dsmax": "3dsmax",
"maya": "maya"
},
default=cls.abc_conversion_preset
Expand All @@ -72,12 +66,17 @@ def get_task(self, filename, asset_dir, asset_name, replace, loaded_options=None
flip_u=False, flip_v=True,
rotation=[90.0, 0.0, 0.0],
scale=[1.0, -1.0, 1.0])
else:
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.CUSTOM,
flip_u=False, flip_v=False,
rotation=[0.0, 0.0, 0.0],
scale=[1.0, 1.0, 1.0])
elif abc_conversion_preset == "3dsmax":
if unreal_pipeline.UNREAL_VERSION.major >= 5 and (
unreal_pipeline.UNREAL_VERSION.minor >= 4):
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.MAX)
else:
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.CUSTOM,
flip_u=False, flip_v=True,
rotation=[0.0, 0.0, 0.0],
scale=[1.0, -1.0, 1.0])

options.sampling_settings.frame_start = loaded_options.get("frameStart")
options.sampling_settings.frame_end = loaded_options.get("frameEnd")
Expand Down
13 changes: 3 additions & 10 deletions client/ayon_unreal/plugins/load/load_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,9 @@ class AnimationFBXLoader(plugin.Loader):
def apply_settings(cls, project_settings):
super(AnimationFBXLoader, cls).apply_settings(project_settings)
# Apply import settings
unreal_settings = project_settings.get("unreal", {})
if unreal_settings.get("loaded_asset_dir", cls.loaded_asset_dir):
cls.loaded_asset_dir = unreal_settings.get(
"loaded_asset_dir", cls.loaded_asset_dir)
# Apply import settings
import_settings = (
project_settings.get("unreal", {}).get("import_settings", {})
)

cls.show_dialog = import_settings.get("show_dialog", cls.show_dialog)
unreal_settings = project_settings["unreal"]["import_settings"]
cls.loaded_asset_dir = unreal_settings["loaded_asset_dir"]
cls.show_dialog = unreal_settings["show_dialog"]

def _import_latest_skeleton(self, version_ids):
version_ids = set(version_ids)
Expand Down
5 changes: 3 additions & 2 deletions client/ayon_unreal/plugins/load/load_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def apply_settings(cls, project_settings):
project_settings
)
cls.loaded_asset_dir = (
project_settings["unreal"].get(
"loaded_asset_dir", cls.loaded_asset_dir)
project_settings["unreal"]
["import_settings"]
["loaded_asset_dir"]
)

def _import_camera(
Expand Down
32 changes: 15 additions & 17 deletions client/ayon_unreal/plugins/load/load_geometrycache_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,10 @@ class PointCacheAlembicLoader(plugin.Loader):
def apply_settings(cls, project_settings):
super(PointCacheAlembicLoader, cls).apply_settings(project_settings)
# Apply import settings
unreal_settings = project_settings.get("unreal", {})
if unreal_settings.get("abc_conversion_preset", cls.abc_conversion_preset):
cls.abc_conversion_preset = unreal_settings.get(
"abc_conversion_preset", cls.abc_conversion_preset)
if unreal_settings.get("loaded_asset_dir", cls.loaded_asset_dir):
cls.loaded_asset_dir = unreal_settings.get(
"loaded_asset_dir", cls.loaded_asset_dir)
if unreal_settings.get("show_dialog", cls.show_dialog):
cls.show_dialog = unreal_settings.get(
"show_dialog", cls.show_dialog)
unreal_settings = project_settings["unreal"]["import_settings"]
cls.abc_conversion_preset = unreal_settings["abc_conversion_preset"]
cls.loaded_asset_dir = unreal_settings["loaded_asset_dir"]
cls.show_dialog = unreal_settings["show_dialog"]

@classmethod
def get_options(cls, contexts):
Expand All @@ -54,7 +48,7 @@ def get_options(cls, contexts):
"abc_conversion_preset",
label="Alembic Conversion Preset",
items={
"custom": "custom",
"3dsmax": "3dsmax",
"maya": "maya"
},
default=cls.abc_conversion_preset
Expand Down Expand Up @@ -82,12 +76,16 @@ def get_task(
flip_u=False, flip_v=True,
rotation=[90.0, 0.0, 0.0],
scale=[1.0, -1.0, 1.0])
else:
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.CUSTOM,
flip_u=False, flip_v=True,
rotation=[-90.0, 0.0, 180.0],
scale=[100.0, 100.0, 100.0])
elif abc_conversion_preset == "3dsmax":
if UNREAL_VERSION.major >= 5 and UNREAL_VERSION.minor >= 4:
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.MAX)
else:
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.CUSTOM,
flip_u=False, flip_v=True,
rotation=[0.0, 0.0, 0.0],
scale=[1.0, -1.0, 1.0])

task.set_editor_property('filename', filename)
task.set_editor_property('destination_path', asset_dir)
Expand Down
5 changes: 2 additions & 3 deletions client/ayon_unreal/plugins/load/load_image_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ def apply_settings(cls, project_settings):
cls.pipeline_path = import_settings.get("interchange", {}).get(
"pipeline_path_static_mesh", cls.pipeline_path
)
if unreal_settings.get("loaded_asset_dir", cls.loaded_asset_dir):
cls.loaded_asset_dir = unreal_settings.get(
"loaded_asset_dir", cls.loaded_asset_dir)
cls.loaded_asset_dir = import_settings.get(
"loaded_asset_dir", cls.loaded_asset_dir)

@classmethod
def get_task(cls, filename, asset_dir, asset_name, replace):
Expand Down
40 changes: 15 additions & 25 deletions client/ayon_unreal/plugins/load/load_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,16 @@ class LayoutLoader(plugin.LayoutLoader):
def apply_settings(cls, project_settings):
super(LayoutLoader, cls).apply_settings(project_settings)
# Apply import settings
import_settings = project_settings["unreal"]["import_settings"]
cls.folder_representation_type = (
project_settings["unreal"].get(
"folder_representation_type",
cls.folder_representation_type)
)
cls.use_force_loaded = (
project_settings["unreal"].get(
"force_loaded", cls.force_loaded)
import_settings["folder_representation_type"]
)
cls.use_force_loaded = import_settings["force_loaded"]
cls.level_sequences_for_layouts = (
project_settings["unreal"].get(
"level_sequences_for_layouts",
cls.level_sequences_for_layouts)
)
cls.loaded_layout_dir = (
project_settings["unreal"].get(
"loaded_layout_dir", cls.loaded_layout_dir)
)
cls.remove_loaded_assets = (
project_settings["unreal"].get(
"remove_loaded_assets",
cls.remove_loaded_assets)
import_settings["level_sequences_for_layouts"]
)
cls.loaded_layout_dir = import_settings["loaded_layout_dir"]
cls.remove_loaded_assets = import_settings["remove_loaded_assets"]

@classmethod
def get_options(cls, contexts):
Expand Down Expand Up @@ -281,8 +268,9 @@ def load(self, context, name, namespace, options):
list(str): list of container content
"""
data = get_current_project_settings()
create_sequences = data["unreal"]["level_sequences_for_layouts"]

create_sequences = (
data["unreal"]["import_settings"]["level_sequences_for_layouts"]
)
# Create directory for asset and Ayon container
folder_entity = context["folder"]
folder_path = folder_entity["path"]
Expand All @@ -300,6 +288,9 @@ def load(self, context, name, namespace, options):
asset_level = f"{asset_dir}/{folder_name}_map.{folder_name}_map"
if not EditorAssetLibrary.does_asset_exist(asset_level):
EditorLevelLibrary.new_level(f"{asset_dir}/{folder_name}_map")

shot = None
sequences = []
if create_sequences:
shot, _, asset_level, sequences, frame_ranges = (
generate_master_level_sequence(
Expand Down Expand Up @@ -341,8 +332,6 @@ def load(self, context, name, namespace, options):
path, project_name, asset_dir, shot,
loaded_extension=extension,
force_loaded=self.force_loaded)
unreal.log("loaded assets")
unreal.log(loaded_assets)
for s in sequences:
EditorAssetLibrary.save_asset(s.get_path_name())

Expand Down Expand Up @@ -376,8 +365,9 @@ def load(self, context, name, namespace, options):
def update(self, container, context):
project_name = context["project"]["name"]
data = get_current_project_settings()
create_sequences = data["unreal"]["level_sequences_for_layouts"]

create_sequences = (
data["unreal"]["import_settings"]["level_sequences_for_layouts"]
)
ar = unreal.AssetRegistryHelpers.get_asset_registry()

curr_level_sequence = LevelSequenceLib.get_current_level_sequence()
Expand Down
13 changes: 4 additions & 9 deletions client/ayon_unreal/plugins/load/load_layout_existing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ def apply_settings(cls, project_settings):
super(ExistingLayoutLoader, cls).apply_settings(
project_settings
)
import_settings = project_settings["unreal"]["import_settings"]
cls.delete_unmatched_assets = (
project_settings["unreal"]["delete_unmatched_assets"]
)
cls.loaded_layout_dir = (
project_settings["unreal"].get(
"loaded_layout_dir", cls.loaded_layout_dir)
)
cls.remove_loaded_assets = (
project_settings["unreal"].get(
"remove_loaded_assets", cls.remove_loaded_assets)
import_settings["delete_unmatched_assets"]
)
cls.loaded_layout_dir = import_settings["loaded_layout_dir"]
cls.remove_loaded_assets = import_settings["remove_loaded_assets"]

def _spawn_actor(self, obj, lasset, sequence):
actor = EditorLevelLibrary.spawn_actor_from_object(
Expand Down
32 changes: 15 additions & 17 deletions client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,10 @@ class SkeletalMeshAlembicLoader(plugin.Loader):
def apply_settings(cls, project_settings):
super(SkeletalMeshAlembicLoader, cls).apply_settings(project_settings)
# Apply import settings
unreal_settings = project_settings.get("unreal", {})
if unreal_settings.get("abc_conversion_preset", cls.abc_conversion_preset):
cls.abc_conversion_preset = unreal_settings.get(
"abc_conversion_preset", cls.abc_conversion_preset)
if unreal_settings.get("loaded_asset_dir", cls.loaded_asset_dir):
cls.loaded_asset_dir = unreal_settings.get(
"loaded_asset_dir", cls.loaded_asset_dir)
if unreal_settings.get("show_dialog", cls.show_dialog):
cls.show_dialog = unreal_settings.get(
"show_dialog", cls.show_dialog)
unreal_settings = project_settings["unreal"]["import_settings"]
cls.abc_conversion_preset = unreal_settings["abc_conversion_preset"]
cls.loaded_asset_dir = unreal_settings["loaded_asset_dir"]
cls.show_dialog = unreal_settings["show_dialog"]

@classmethod
def get_options(cls, contexts):
Expand All @@ -53,7 +47,7 @@ def get_options(cls, contexts):
"abc_conversion_preset",
label="Alembic Conversion Preset",
items={
"custom": "custom",
"3dsmax": "3dsmax",
"maya": "maya"
},
default=cls.abc_conversion_preset
Expand Down Expand Up @@ -114,12 +108,16 @@ def get_task(filename, asset_dir, asset_name, replace, loaded_options):
flip_u=False, flip_v=True,
rotation=[90.0, 0.0, 0.0],
scale=[1.0, -1.0, 1.0])
else:
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.CUSTOM,
flip_u=False, flip_v=False,
rotation=[0.0, 0.0, 0.0],
scale=[1.0, 1.0, 1.0])
elif abc_conversion_preset == "3dsmax":
if UNREAL_VERSION.major >= 5 and UNREAL_VERSION.minor >= 4:
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.MAX)
else:
conversion_settings = unreal.AbcConversionSettings(
preset=unreal.AbcConversionPreset.CUSTOM,
flip_u=False, flip_v=True,
rotation=[0.0, 0.0, 0.0],
scale=[1.0, -1.0, 1.0])

options.conversion_settings = conversion_settings

Expand Down
12 changes: 3 additions & 9 deletions client/ayon_unreal/plugins/load/load_skeletalmesh_fbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ class SkeletalMeshFBXLoader(plugin.Loader):

@classmethod
def apply_settings(cls, project_settings):
unreal_settings = project_settings.get("unreal", {})
unreal_settings = project_settings["unreal"]["import_settings"]
super(SkeletalMeshFBXLoader, cls).apply_settings(project_settings)
if unreal_settings.get("loaded_asset_dir", cls.loaded_asset_dir):
cls.loaded_asset_dir = unreal_settings.get(
"loaded_asset_dir", cls.loaded_asset_dir)
# Apply import settings
import_settings = (
project_settings.get("unreal", {}).get("import_settings", {})
)
cls.show_dialog = import_settings.get("show_dialog", cls.show_dialog)
cls.loaded_asset_dir = unreal_settings["loaded_asset_dir"]
cls.show_dialog = unreal_settings["show_dialog"]

@classmethod
def get_task(cls, filename, asset_dir, asset_name, replace):
Expand Down
Loading

0 comments on commit ec7e676

Please sign in to comment.