Merge pull request #2367 from MoritzBrueckner/fix-library-textures
Fix exporting textures from linked libraries
This commit is contained in:
commit
9094154440
|
@ -737,7 +737,9 @@ def node_name(s: str) -> str:
|
|||
|
||||
##
|
||||
|
||||
|
||||
def make_texture(image_node: bpy.types.ShaderNodeTexImage, tex_name: str, matname: str = None) -> Optional[Dict[str, Any]]:
|
||||
"""Creates a texture reference for the export data for a given texture node."""
|
||||
tex = {'name': tex_name}
|
||||
|
||||
if matname is None:
|
||||
|
@ -768,6 +770,8 @@ def make_texture(image_node: bpy.types.ShaderNodeTexImage, tex_name: str, matnam
|
|||
else:
|
||||
log.warn(matname + '/' + image.name + ' - invalid file path')
|
||||
return None
|
||||
else:
|
||||
filepath = arm.utils.to_absolute_path(filepath, image.library)
|
||||
|
||||
# Reference image name
|
||||
texpath = arm.utils.asset_path(filepath)
|
||||
|
|
|
@ -104,7 +104,8 @@ def blend_name():
|
|||
def build_dir():
|
||||
return 'build_' + safestr(blend_name())
|
||||
|
||||
def get_fp():
|
||||
|
||||
def get_fp() -> str:
|
||||
wrd = bpy.data.worlds['Arm']
|
||||
if wrd.arm_project_root != '':
|
||||
return bpy.path.abspath(wrd.arm_project_root)
|
||||
|
@ -127,9 +128,22 @@ def get_fp():
|
|||
s += os.path.sep
|
||||
return s
|
||||
|
||||
|
||||
def get_fp_build():
|
||||
return os.path.join(get_fp(), build_dir())
|
||||
|
||||
|
||||
def to_absolute_path(path: str, from_library: Optional[bpy.types.Library] = None) -> str:
|
||||
"""Convert the given absolute or relative path into an absolute path.
|
||||
|
||||
- If `from_library` is not set (default), a given relative path will be
|
||||
interpreted as relative to the project directory.
|
||||
- If `from_library` is set, a given relative path will be interpreted as
|
||||
relative to the filepath of the specified library.
|
||||
"""
|
||||
return os.path.normpath(bpy.path.abspath(path, start=get_fp(), library=from_library))
|
||||
|
||||
|
||||
def get_os() -> str:
|
||||
s = platform.system()
|
||||
if s == 'Windows':
|
||||
|
|
Loading…
Reference in New Issue