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

a few small bug fixes #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion render_ribmosaic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def register():
RibmosaicInfo("ribify module not found, using script level exporter")

bpy.utils.register_module(__name__)
bpy.ops.wm.ribmosaic_modal_sync()
bpy.ops.wm.ribmosaic_pipeline_sync()


def unregister():
Expand Down
13 changes: 9 additions & 4 deletions render_ribmosaic/rm_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,8 @@ def open_rib_archive(self, archive_mode='DEFAULT'):
"""

# determine what type of export to do
archive_mode = self.pointer_datablock.ribmosaic_rib_archive
archive_mode = getattr(self.pointer_datablock, "ribmosaic_rib_archive",
'DEFUALT')
# for now just testing inline and readarchive
if archive_mode == 'DEFAULT':
if self.data_type in ['MESH']:
Expand Down Expand Up @@ -1507,6 +1508,9 @@ def riOpacity(self, color=(0, 0, 0)):
def riTransform(self, mat):
self.write_text('Transform %s\n' % rib_mat_str(mat))

def riSides(self, useTwoSides=True):
self.write_text('Sides %s\n' % (2 if useTwoSides else 1))



# #### Pipeline panel sub classes (all derived from ExporterArchive)
Expand Down Expand Up @@ -1929,8 +1933,6 @@ def export_rib(self):
raise rm_error.RibmosaicError("Failed to build camera " +
sys.exc_info())

self.write_text("Sides 1\n")

world = ExportWorld(self, datablock.world)
world.export_rib()
del world
Expand Down Expand Up @@ -2200,6 +2202,7 @@ def export_rib(self):
self._export_camera_rib()
else:

self.riAttributeBegin()
# TODO
# need to group mesh data with associated material
# if the mesh uses more than one material then mesh has to be
Expand Down Expand Up @@ -2227,7 +2230,6 @@ def export_rib(self):
mat = ob.matrix_world
#print(mat)

self.riAttributeBegin()
self.write_text('Attribute "identifier" "name" [ "%s" ]\n' %
self.data_name)
self.riTransform(mat)
Expand Down Expand Up @@ -2532,6 +2534,9 @@ def export_rib(self):

# determine what type of object data needs to be exported
if self.blender_object.type in ('MESH', 'EMPTY'):
if self.get_scene().ribmosaic_use_sides:
self.riSides(self.pointer_datablock.show_double_sided)

self. _export_geometry()

self.close_archive()
Expand Down
53 changes: 30 additions & 23 deletions render_ribmosaic/rm_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@
# GLOBAL OPERATORS
# #############################################################################

class WM_OT_ribmosaic_modal_sync(bpy.types.Operator):
'''Allow user to demand the pipeline manager to execute
its sync method. This operator is temporary until
background callbacks are supported
'''
bl_idname = "wm.ribmosaic_modal_sync"
bl_label = "sync pipelines"

def execute(self, context):
print("wm.ribmosaic_modal_sync()")

# Sync pipeline tree with current .rmp files
rm.pipeline_manager.sync()

return {'FINISHED'}


class RibmosaicOperator():
"""Super class for all RIB Mosaic operators providing helper methods"""
Expand Down Expand Up @@ -134,9 +118,9 @@ def _dialog_message(self, layout, message):

def _refresh_panels(self):
"""Refreshes UI panels by simply toggling Blender's render engine"""

bpy.context.scene.render.engine = 'BLENDER_RENDER'
bpy.context.scene.render.engine = rm.ENGINE
if bpy.context.scene is not None:
bpy.context.scene.render.engine = 'BLENDER_RENDER'
bpy.context.scene.render.engine = rm.ENGINE

def _unique_name(self, name, names):
"""Checks name against names list to build a unique name by appending
Expand Down Expand Up @@ -328,15 +312,17 @@ def execute(self, context):
index = wm.ribmosaic_pipelines.active_index
# determine the path to the slmeta file for the shader in the text
# editor
slmetaname = text.name[:-2] + "slmeta"
slmetapath = (rm.export_manager.export_directory +
rm.export_manager.make_shader_export_path() +
text.name[:-2] + "slmeta")
slmetaname)
# only try to add the shader panel if a pipeline is selected
# and the slmeta file exists
if index >= 0 and os.path.isfile(slmetapath):
bpy.ops.wm.ribmosaic_library_addpanel('INVOKE_DEFAULT',
filepath=slmetapath,
pipeline=wm.ribmosaic_pipelines.collection[index].xmlpath)
pipeline=wm.ribmosaic_pipelines.collection[index].xmlpath,
filename=slmetaname)

except rm_error.RibmosaicError as err:
err.ReportError(self)
Expand Down Expand Up @@ -1238,7 +1224,10 @@ def invoke(self, context, event):
self.filepath = lib + "*.slmeta"
else:
self.library = ""
#self.filepath = "//*.slmeta"
if self.filename != "":
self.files.add().name = self.filename
else:
self.filepath = "//*.slmeta"
else:
raise rm_error.RibmosaicError("Blend must be saved before "
"shaders can be added")
Expand All @@ -1251,11 +1240,29 @@ def invoke(self, context, event):
return {'RUNNING_MODAL'}



# #############################################################################
# PIPELINE OPERATORS
# #############################################################################

class WM_OT_ribmosaic_pipeline_sync(rm_context.ExportContext,
RibmosaicOperator,
bpy.types.Operator):
'''Allow user to demand the pipeline manager to execute
its sync method. This operator is temporary until
background callbacks are supported
'''
bl_idname = "wm.ribmosaic_pipeline_sync"
bl_label = "Sync Pipelines"

def execute(self, context):
print("wm.ribmosaic_pipeline_sync()")

# Sync pipeline tree with current .rmp files
rm.pipeline_manager.sync()
self._refresh_panels()
return {'FINISHED'}


class WM_OT_ribmosaic_pipeline_enable(rm_context.ExportContext,
RibmosaicOperator,
bpy.types.Operator):
Expand Down
2 changes: 1 addition & 1 deletion render_ribmosaic/rm_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def draw(self, context):
rows = 2

row = layout.row()
row.operator("wm.ribmosaic_modal_sync")
row.operator("wm.ribmosaic_pipeline_sync")
row = layout.row()
row.template_list(wm.ribmosaic_pipelines, "collection",
wm.ribmosaic_pipelines, "active_index", rows=rows)
Expand Down
39 changes: 39 additions & 0 deletions render_ribmosaic/rm_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,45 @@ def load_pipeline(self, filepath):
raise rm_error.RibmosaicError("PipelineManager.load_pipeline: " +
self._error_register)

#if pipeline has a library path then check to see if it is relative
lib = self.get_attr(self, pipeline, "library", False)
if lib:
# special case for relative shader library:
# when loading a pipeline with a library that is relative
# assume that the relative path contains a sub directory for
# the shaders that are used by the library that is relative
# to the directory of where the pipeline was loaded from
if lib[:2] == "//":
# build a list of the sub directories that make up the
# library path in reverse order
subdirs = lib[2:].split("/")
subdirs.reverse()
subpath = ""
founddirectory = ""
# build sub directories and test if a valid one is found
# start with the last sub directory and work our way left
# until a valid path can be found
for subd in subdirs:
# don't process empty strings
if subd:
# build up the subpath
subpath = subd + os.sep + subpath
# get the full real path
full_lib_path = os.path.realpath(
os.path.split(filepath)[0] + os.sep + subpath)
# test if the path exists
if os.path.isdir(full_lib_path):
founddirectory = full_lib_path
break

#if a valid pipeline directory was found save it in the xml
if founddirectory:
#make the lib path relative to the blend
founddirectory = bpy.path.relpath(founddirectory) + os.sep
#make the change to the library path
#in the pipeline xml text
self.set_attrs(pipeline, library=founddirectory)

self.revisions += 1
return pipeline

Expand Down