Skip to content

Commit

Permalink
Updated engon from monorepo commit e1c3142c15d6a12d4dcd799d7402e3e471…
Browse files Browse the repository at this point in the history
…f61207
  • Loading branch information
Griperis committed Mar 14, 2024
1 parent 29a23ce commit 3a49845
Show file tree
Hide file tree
Showing 45 changed files with 2,070 additions and 1,054 deletions.
17 changes: 11 additions & 6 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
from . import asset_helpers
from . import preferences
from . import panel
from . import mapr_browser
from . import browser
from . import blend_maintenance

from . import aquatiq
Expand All @@ -104,12 +104,12 @@
bl_info = {
"name": "engon",
"author": "polygoniq xyz s.r.o.",
"version": (1, 0, 1), # bump doc_url as well!
"version": (1, 0, 2), # bump doc_url as well!
"blender": (3, 3, 0),
"location": "polygoniq tab in the sidebar of the 3D View window",
"description": "",
"category": "Object",
"doc_url": "https://docs.polygoniq.com/engon/1.0.1/",
"doc_url": "https://docs.polygoniq.com/engon/1.0.2/",
"tracker_url": "https://polygoniq.com/discord/"
}

Expand All @@ -127,7 +127,7 @@ def register():
panel.register()
scatter.register()
blend_maintenance.register()
mapr_browser.register()
browser.register()
aquatiq.register()
botaniq.register()
materialiq.register()
Expand All @@ -137,7 +137,12 @@ def register():
# We need to call the first pack refresh manually, then it's called when paths change
bpy.app.timers.register(
lambda: preferences.get_preferences(bpy.context).refresh_packs(),
first_interval=0
first_interval=0,
# This is important. If an existing blend file is opened with double-click or on command
# line with e.g. "blender.exe path/to/blend", this register() is called in the startup blend
# file but right after the target blend file is opened which would discards the callback
# without persistent=True.
persistent=True
)

# Make engon preferences open after first registration
Expand All @@ -153,7 +158,7 @@ def unregister():
materialiq.unregister()
botaniq.unregister()
aquatiq.unregister()
mapr_browser.unregister()
browser.unregister()
blend_maintenance.unregister()
scatter.unregister()
panel.unregister()
Expand Down
4 changes: 2 additions & 2 deletions addon_updater_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def draw(self, context):
else:
col = layout.column()
col.label(
text="Addon successfully installed", icon="FILE_TICK")
text="Addon successfully installed", icon='CHECKBOX_HLT')
alert_row = col.row()
alert_row.alert = True
alert_row.operator(
Expand All @@ -550,7 +550,7 @@ def draw(self, context):
col = layout.column()
col.scale_y = 0.7
col.label(
text="Addon successfully installed", icon="FILE_TICK")
text="Addon successfully installed", icon='CHECKBOX_HLT')
col.label(
text="Consider restarting blender to fully reload.",
icon="BLANK1")
Expand Down
5 changes: 4 additions & 1 deletion aquatiq/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def draw_header(self, context: bpy.types.Context):

def draw_header_preset(self, context: bpy.types.Context) -> None:
polib.ui_bpy.draw_doc_button(
self.layout, preferences.__package__, rel_url="panels/aquatiq/panel_overview")
self.layout,
polib.utils_bpy.get_top_level_package_name(__package__),
rel_url="panels/aquatiq/panel_overview"
)

def draw(self, context: bpy.types.Context):
pass
Expand Down
43 changes: 38 additions & 5 deletions asset_pack_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,45 @@ def draw_pack_info(
if header != "":
col.box().label(text=header, icon='INFO')

col = col.box().column(align=True)
col.label(text=f"Name: {instance.full_name}")
col.label(text=f"Version: {instance.version}")
col.label(text=f"Vendor: {instance.vendor}")
row = col.box().row(align=True)
label_col = row.column(align=True)
label_col.alignment = 'LEFT'
row.separator(factor=2.0)
value_col = row.column(align=True)
value_col.alignment = 'LEFT'

label_col.label(text="Name:")
value_col.label(text=instance.full_name)
label_col.label(text="Version:")
value_col.label(text=instance.version)
label_col.label(text="Vendor:")
value_col.label(text=instance.vendor)
if show_install_path:
col.label(text=f"Install Path: {instance.install_path}")
label_col.label(text="Install Path:")
value_col.label(text=instance.install_path)

def draw_installer_info(self, layout: bpy.types.UILayout) -> None:
row = layout.row(align=True)
label_col = row.column(align=True)
label_col.alignment = 'LEFT'
row.separator(factor=2.0)
value_col = row.column(align=True)
value_col.alignment = 'LEFT'

label_col.label(text=f"Pack Folder Name:")
value_col.label(text=instance.pack_root_directory)
if instance._operation == InstallerOperation.UNINSTALL:
label_col.label(text=f"Estimated Freed Disk Space:")
value_col.label(text=instance.pack_size)
else:
if instance._operation == InstallerOperation.UPDATE:
label_col.label(text=f"Estimated Extra Space Required:")
value_col.label(text=instance.pack_size)
else:
label_col.label(text=f"Estimated Pack Size:")
value_col.label(text=instance.pack_size)
label_col.label(text=f"Free Disk Space:")
value_col.label(text=instance.free_space)

def check_should_dialog_close(self) -> bool:
return not instance.can_installer_proceed
Expand Down
4 changes: 2 additions & 2 deletions asset_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def check_pack_validity(self) -> None:
raise ValueError(
f"Given install_path {self.install_path} is not a valid directory!")

# Paths to MAPR index JSONs, this will be used by MAPR browser to browse this asset pack.
# Paths to MAPR index JSONs, this will be used by browser to browse this asset pack.
# These paths should be relative to self.install_path
for index_path in self.index_paths:
if os.path.isabs(index_path):
Expand Down Expand Up @@ -324,7 +324,7 @@ def __init__(self):
collections.defaultdict(list)
self._packs_by_pack_info_path: typing.Dict[str, AssetPack] = {}
self.master_asset_provider: mapr.asset_provider.AssetProvider = \
mapr.asset_provider.AssetProviderMultiplexer()
mapr.asset_provider.CachedAssetProviderMultiplexer()
self.master_file_provider: mapr.file_provider.FileProvider = \
mapr.file_provider.FileProviderMultiplexer()
self.on_refresh: typing.List[typing.Callable[[], None]] = []
Expand Down
6 changes: 5 additions & 1 deletion blend_maintenance/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ def execute(self, context: bpy.types.Context):
datablocks_to_reload.append(datablock)

for datablock in datablocks_to_reload:
datablock.reload()
try:
datablock.reload()
logger.info(f"Reloaded '{datablock.name}'")
except ReferenceError:
logger.error("ReferenceError: Failed to reload some data")

return {'FINISHED'}

Expand Down
41 changes: 21 additions & 20 deletions botaniq/animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
MODULE_CLASSES: typing.List[typing.Type] = []


DEFAULT_PRESET = preferences.WindPreset.WIND
DEFAULT_PRESET = preferences.botaniq_preferences.WindPreset.WIND
DEFAULT_WIND_STRENGTH = 0.5
MODIFIER_STACK_NAME_PREFIX = "bq_Modifier-Stack"
ANIMATION_INSTANCES_COLLECTION = "animation_instances"
Expand Down Expand Up @@ -520,7 +520,7 @@ def set_animation_frame_range(
keyframe.handle_right.x = keyframe.co.x - (r_handle_distance * multiplier)


def get_wind_style(action: bpy.types.Action) -> preferences.WindStyle:
def get_wind_style(action: bpy.types.Action) -> preferences.botaniq_preferences.WindStyle:
"""Infers animation style from looking at status of FCurve Noise modifier in stack.
"""
for fcurve in action.fcurves:
Expand All @@ -533,16 +533,16 @@ def get_wind_style(action: bpy.types.Action) -> preferences.WindStyle:
continue

if noise.mute:
return preferences.WindStyle.LOOP
return preferences.WindStyle.PROCEDURAL
return preferences.botaniq_preferences.WindStyle.LOOP
return preferences.botaniq_preferences.WindStyle.PROCEDURAL

return preferences.WindStyle.UNKNOWN
return preferences.botaniq_preferences.WindStyle.UNKNOWN


def change_anim_style(
obj: bpy.types.Object,
helper_objs: typing.Iterable[bpy.types.Object],
style: preferences.WindStyle
style: preferences.botaniq_preferences.WindStyle
) -> None:
"""Set animation style of given objects and its given helper empties.
Expand All @@ -551,7 +551,7 @@ def change_anim_style(
Fails if given 'obj' doesn't have animation_data.action and only logs warning if some of the
'helper_objs' doesn't have it.
"""
def change_anim_style_of_action(action: bpy.types.Action, style: preferences.WindStyle) -> None:
def change_anim_style_of_action(action: bpy.types.Action, style: preferences.botaniq_preferences.WindStyle) -> None:
"""Set animation style of action to the provided one by changing the mute status on specific FCurves."""
for fcurve in action.fcurves:
if len(fcurve.modifiers) < len(WIND_ANIMATION_FCURVE_STYLE_MODS):
Expand All @@ -568,7 +568,7 @@ def change_anim_style_of_action(action: bpy.types.Action, style: preferences.Win
loop_mod_type, loop_mod_status = LOOPING_STACK_STATUS[i]
if loop_mod_type != modifier.type:
continue
if style == preferences.WindStyle.LOOP:
if style == preferences.botaniq_preferences.WindStyle.LOOP:
modifier.mute = not loop_mod_status
else:
modifier.mute = loop_mod_status
Expand Down Expand Up @@ -601,7 +601,7 @@ def change_preset(obj: bpy.types.Object, preset: str, strength: float) -> int:

if obj.animation_data is None:
obj.animation_data_create()
animation_style = preferences.WindStyle.LOOP
animation_style = preferences.botaniq_preferences.WindStyle.LOOP
else:
old_action = obj.animation_data.action
animation_style = get_wind_style(old_action)
Expand Down Expand Up @@ -802,7 +802,7 @@ def build_animation_type_objs_map(
"""
# Return early with direct map of animation_type -> objects if selected animation type
# is different from BEST_FIT
if animation_type != preferences.AnimationType.WIND_BEST_FIT.value:
if animation_type != preferences.botaniq_preferences.AnimationType.WIND_BEST_FIT.value:
return {animation_type: list(objects)}

animation_type_objs_map: typing.Dict[
Expand Down Expand Up @@ -878,7 +878,8 @@ def animate_objects(
# Adjust the frame interval to scene fps to maintain default speed
set_animation_frame_range(obj, fps, fps_adjusted_interval)
helper_objs = get_animated_objects_hierarchy(obj, load_helper_object_names())
change_anim_style(obj, helper_objs, preferences.WindStyle.PROCEDURAL)
change_anim_style(obj, helper_objs,
preferences.botaniq_preferences.WindStyle.PROCEDURAL)

animated_object_names.append(obj.name)
if make_instance:
Expand Down Expand Up @@ -1260,17 +1261,17 @@ class AnimationSetAnimStyle(AnimationOperatorBase):
description="Choose the desired animation style",
items=[
(
preferences.WindStyle.PROCEDURAL.name,
preferences.WindStyle.PROCEDURAL.value,
preferences.botaniq_preferences.WindStyle.PROCEDURAL.name,
preferences.botaniq_preferences.WindStyle.PROCEDURAL.value,
"Procedural botaniq animation"
),
(
preferences.WindStyle.LOOP.name,
preferences.WindStyle.LOOP.value,
preferences.botaniq_preferences.WindStyle.LOOP.name,
preferences.botaniq_preferences.WindStyle.LOOP.value,
"Looping botaniq animation"
),
],
default=preferences.WindStyle.PROCEDURAL.name,
default=preferences.botaniq_preferences.WindStyle.PROCEDURAL.name,
)

def draw(self, context: bpy.types.Context) -> None:
Expand All @@ -1279,10 +1280,10 @@ def draw(self, context: bpy.types.Context) -> None:
super().draw(context)

def execute(self, context: bpy.types.Context):
if self.style == preferences.WindStyle.PROCEDURAL.name:
style_enum = preferences.WindStyle.PROCEDURAL
elif self.style == preferences.WindStyle.LOOP.name:
style_enum = preferences.WindStyle.LOOP
if self.style == preferences.botaniq_preferences.WindStyle.PROCEDURAL.name:
style_enum = preferences.botaniq_preferences.WindStyle.PROCEDURAL
elif self.style == preferences.botaniq_preferences.WindStyle.LOOP.name:
style_enum = preferences.botaniq_preferences.WindStyle.LOOP
else:
raise ValueError(f"Unknown operation '{self.style}', expected LOOP or PROCEDURAL!")

Expand Down
7 changes: 5 additions & 2 deletions botaniq/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def draw_header(self, context: bpy.types.Context):

def draw_header_preset(self, context: bpy.types.Context) -> None:
polib.ui_bpy.draw_doc_button(
self.layout, preferences.__package__, rel_url="panels/botaniq/panel_overview")
self.layout,
polib.utils_bpy.get_top_level_package_name(__package__),
rel_url="panels/botaniq/panel_overview"
)

def draw(self, context: bpy.types.Context):
pass
Expand Down Expand Up @@ -405,7 +408,7 @@ def draw_object_anim_details(
split.label(text="Strength:")
split.label(text=f"{wind_strength:.3f}x")

if animation_style == preferences.WindStyle.LOOP:
if animation_style == preferences.botaniq_preferences.WindStyle.LOOP:
frame_range = animations.get_frame_range(action)
if frame_range is not None:
# Loop Interval
Expand Down
File renamed without changes.
10 changes: 8 additions & 2 deletions mapr_browser/browser.py → browser/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def draw_asset_previews(
mapr_prefs: preferences.MaprPreferences
) -> None:
pm = previews.manager_instance
assets = filters.asset_repository.get_current_assets()
assets = filters.asset_repository.current_assets
if len(asset_registry.instance.get_registered_packs()) == 0:
col = layout.column()
col.separator()
Expand Down Expand Up @@ -313,7 +313,7 @@ def prefs_header_draw_override(self, context: bpy.types.Context):

row.separator_spacer()
sub = row.row(align=True)
sub.popover(panel=spawn.SpawnOptionsPopoverPanel.bl_idname, text="", icon='FILE_TICK')
sub.popover(panel=spawn.SpawnOptionsPopoverPanel.bl_idname, text="", icon='OPTIONS')
sub.prop(mapr_filters, "sort_mode", text="", icon='SORTALPHA', icon_only=True)
sub.prop(prefs, "preview_scale_percentage", slider=True, text="")
sub.popover(
Expand Down Expand Up @@ -377,6 +377,12 @@ def open_browser(cls, context: bpy.types.Context, area: bpy.types.Area) -> None:
cls.prev_area_ui_types[area] = area.ui_type
area.ui_type = 'PREFERENCES'
preferences.get_preferences(context).mapr_preferences.prefs_hijacked = True
# If the asset repository doesn't contain any view (it wasn't queried previously) we
# query and reconstruct the filters manually within the root category.
if filters.asset_repository.last_view is None:
filters.get_filters(context).query_and_reconstruct(
mapr.category.DEFAULT_ROOT_CATEGORY.id_)

cls.hijack_preferences(context)


Expand Down
4 changes: 2 additions & 2 deletions mapr_browser/categories.py → browser/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def draw_category_pills_header(
ui_scale = context.preferences.system.ui_scale
estimated_row_width_px = 0
current_category = master_provider.get_category_id_from_string(
filters.asset_repository.get_current_category_id())
filters.asset_repository.current_category_id)
col = layout.column()
row = col.row(align=True)
row.alignment = 'LEFT'
Expand Down Expand Up @@ -120,7 +120,7 @@ def draw_tree_category_navigation(
context: bpy.types.Context,
layout: bpy.types.UILayout,
) -> None:
current_category = filters.asset_repository.get_current_category_id()
current_category = filters.asset_repository.current_category_id
child_categories = asset_registry.instance.master_asset_provider.list_sorted_categories(
current_category)

Expand Down
5 changes: 2 additions & 3 deletions mapr_browser/dev.py → browser/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class MAPR_BrowserDeleteCache(bpy.types.Operator):
bl_label = "Delete Cache"

def execute(self, context: bpy.types.Context):
if filters.asset_repository.data_view_cache is not None:
filters.asset_repository.data_view_cache.clear()
filters.asset_repository.clear_cache()
return {'FINISHED'}


Expand All @@ -58,7 +57,7 @@ class MAPR_BrowserReloadPreviews(bpy.types.Operator):
bl_label = "Reload Previews (In Current View)"

def execute(self, context: bpy.types.Context):
assets = filters.asset_repository.get_current_view().assets
assets = filters.asset_repository.current_assets
previews.manager_instance.clear_ids({asset.id_ for asset in assets})
previews.ensure_loaded_previews(assets)
return {'FINISHED'}
Expand Down
Loading

0 comments on commit 3a49845

Please sign in to comment.