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

Fix exception when there is a material slot but no material #232

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
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
15 changes: 11 additions & 4 deletions io_ogre/ogre/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def dot_materials(materials, path=None, separate_files=True, prefix='mats', **kw
generator.copy_programs()
if kwargs.get('touch_textures', config.get('TOUCH_TEXTURES')):
generator.copy_textures()
fd.write(bytes(material_text+"\n",'utf-8'))
fd.write(bytes(material_text + "\n", 'utf-8'))

if include_missing:
fd.write(bytes(MISSING_MATERIAL + "\n",'utf-8'))
fd.write(bytes(MISSING_MATERIAL + "\n", 'utf-8'))

def dot_material(mat, path, **kwargs):
"""
Expand Down Expand Up @@ -114,16 +114,23 @@ def __init__(self, material, target_path, prefix=''):
self.target_path = target_path
self.w = util.IndentedWriter()
self.passes = []
self.material_name = material_name(self.material,prefix=prefix)
if self.material is None:
self.material_name = "_missing_material_"
else:
self.material_name = material_name(self.material, prefix=prefix)
self.images = set()

if material.node_tree:
if (self.material is not None and
material.node_tree is not None):
nodes = shader.get_subnodes( self.material.node_tree, type='MATERIAL_EXT' )
for node in nodes:
if node.material:
self.passes.append( node.material )

def generate(self):
if self.material is None:
return MISSING_MATERIAL

self.generate_header()
with self.w.iword('material').word(self.material_name).embed():
if self.material.shadow_method != "NONE":
Expand Down
Loading