Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upstream Vivy material system #600

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
adaabf9
feat: Upstream Vivy material system
StandingPadAnimations Jul 7, 2024
c3c551f
feat: Add build option to expose Vivy in UI
StandingPadAnimations Jul 7, 2024
aabc157
build: Add action to build with Vivy exposed in the UI
StandingPadAnimations Jul 7, 2024
8d9b0a6
build: Fix typo in hook
StandingPadAnimations Jul 7, 2024
0a4b53f
fix: Add missing import in mcprep_ui.py
StandingPadAnimations Jul 7, 2024
cd0b9b2
fix: Add mcprep.open_file operator
StandingPadAnimations Jul 7, 2024
d08fced
fix: Add missing json import
StandingPadAnimations Jul 7, 2024
c923a28
fix: Fix basic loading issues with Vivy textureswap
StandingPadAnimations Jul 7, 2024
5e738bb
fix: Fix error check performed in Vivy textureswap
StandingPadAnimations Jul 8, 2024
a8ffed4
fix: Don't call set_material twice
StandingPadAnimations Jul 8, 2024
bf421c4
fix: Only register Vivy modules if enabled
StandingPadAnimations Aug 12, 2024
ea03a93
refactor(vivy): Remove vivy_editor.py for now
StandingPadAnimations Aug 23, 2024
cf5c888
Merge branch 'dev' into vivy-material-system
StandingPadAnimations Aug 23, 2024
583e388
util: Add is_experimental function
StandingPadAnimations Aug 23, 2024
caf2b20
feat: Mark Vivy as an experimental feature
StandingPadAnimations Aug 23, 2024
9152d94
docs: Add basic docs on Vivy JSON spec
StandingPadAnimations Aug 23, 2024
db2eece
Merge branch 'dev' into vivy-material-system
StandingPadAnimations Aug 23, 2024
eaa2fe8
vivy: Remove refinements from the UI layer
StandingPadAnimations Aug 30, 2024
92f8d0c
Merge branch 'dev' into vivy-material-system
StandingPadAnimations Aug 30, 2024
c1f470b
feat: Add Vivy config editor
StandingPadAnimations Aug 31, 2024
610aaf3
feat: Make Vivy materials be sourced from a user defined path
StandingPadAnimations Sep 6, 2024
2418db3
refactor: Remove Vivy Export and Import operators
StandingPadAnimations Sep 6, 2024
17ebcce
fix: Make sure updating the Vivy path resets Vivy cache
StandingPadAnimations Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions MCprep_addon/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import enum
import os
import gettext
import json

import bpy
from bpy.utils.previews import ImagePreviewCollection
Expand Down Expand Up @@ -67,7 +68,6 @@ class Engine(enum.Enum):

MCPREP_RESOURCES: Path = Path(os.path.dirname(__file__), "MCprep_resources")


# -----------------------------------------------------------------------------
# ADDON GLOBAL VARIABLES AND INITIAL SETTINGS
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -137,12 +137,32 @@ def __init__(self):

# Whether we use PO files directly or use the converted form
self.use_direct_i18n = False
# i18n using Python's gettext module
#
# This only runs if translations.py does not exist
self.languages: dict[str, gettext.NullTranslations] = {}

self.languages: Dict[str, gettext.NullTranslations] = {}
self._load_translations()

# Cache for Vivy materials. Identical to self.material_sync_cache, but
# as a seperate variable to avoid conflicts
self.vivy_cache = None

# The JSON file for Vivy's materials
self.vivy_material_json: Dict = {}

# State for name changes in the Vivy config
#
# This is reverse, so the new name refers to the previous name
self.vivy_name_changes: Dict[str, str] = {}

def reload_vivy_json(self, path: Path) -> None:
json_path = Path(path, "vivy_materials.json")
if not json_path.exists():
json_path.touch()
self.vivy_material_json = {}
else:
with open(json_path, 'r') as f:
self.vivy_material_json = json.load(f) if json_path.stat().st_size != 0 else {}


def _load_translations(self) -> None:
"""Loads in mo file translation maps"""
try:
Expand Down Expand Up @@ -370,3 +390,4 @@ def unregister():
env.skin_list = []
env.rig_categories = []
env.material_sync_cache = []
env.vivy_cache = []
17 changes: 17 additions & 0 deletions MCprep_addon/load_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@
importlib.reload(generate)
else:
from .materials import generate
if "vivy_materials" in locals():
importlib.reload(vivy_materials)
else:
from .materials import vivy_materials

if "vivy_ui" in locals():
importlib.reload(vivy_ui)
else:
from . import vivy_ui

if "vivy_editor" in locals():
importlib.reload(vivy_editor)
else:
from . import vivy_editor

# Only include those with a register function, which is not all
module_list = (
Expand All @@ -162,6 +176,9 @@
world_tools,
# bridge,
mcprep_ui,
vivy_materials,
vivy_ui,
vivy_editor
)


Expand Down
Loading