mirror of https://github.com/AxioDL/metaforce.git
Patching and lightmap updates
This commit is contained in:
parent
432924ccd5
commit
009545d716
|
@ -317,6 +317,12 @@ BlenderConnection::BlenderConnection(bool silenceBlender)
|
|||
BlenderLog.report(LogVisor::FatalError, "unable to install blender addon using '%s'", blenderAddonPath.c_str());
|
||||
continue;
|
||||
}
|
||||
else if (!strcmp(lineBuf, "ADDONINSTALLED"))
|
||||
{
|
||||
_closePipe();
|
||||
blenderAddonPath = _S("SKIPINSTALL");
|
||||
continue;
|
||||
}
|
||||
else if (strcmp(lineBuf, "READY"))
|
||||
{
|
||||
_closePipe();
|
||||
|
|
|
@ -29,30 +29,30 @@ def find_project_root():
|
|||
return path[0]
|
||||
return None
|
||||
|
||||
def get_patching_dir(make_dirs=False):
|
||||
def get_patching_dirs(make_dirs=False):
|
||||
proj_root = find_project_root()
|
||||
if not proj_root:
|
||||
return None
|
||||
return None, None
|
||||
rel_to_blend = os.path.relpath(bpy.data.filepath, start=proj_root)
|
||||
rel_to_blend_comps = path_components(rel_to_blend)
|
||||
trace_dir = os.path.join(proj_root, '.hecl', 'patches')
|
||||
global_out = trace_dir
|
||||
if not make_dirs and not os.path.exists(trace_dir):
|
||||
return None
|
||||
return None, global_out
|
||||
_mkdir(trace_dir)
|
||||
for comp in rel_to_blend_comps:
|
||||
ext_pair = os.path.splitext(comp)
|
||||
if ext_pair[1] == '.blend':
|
||||
trace_dir = os.path.join(trace_dir, ext_pair[0])
|
||||
if not make_dirs and not os.path.exists(trace_dir):
|
||||
return None
|
||||
return None, global_out
|
||||
_mkdir(trace_dir)
|
||||
return trace_dir
|
||||
return trace_dir, global_out
|
||||
trace_dir = os.path.join(trace_dir, comp)
|
||||
if not make_dirs and not os.path.exists(trace_dir):
|
||||
return None
|
||||
return None, global_out
|
||||
_mkdir(trace_dir)
|
||||
|
||||
|
||||
class FILE_OT_hecl_patching_save(bpy.types.Operator):
|
||||
'''Save text datablocks to hecl patching directory'''
|
||||
bl_idname = "file.hecl_patching_save"
|
||||
|
@ -60,13 +60,13 @@ class FILE_OT_hecl_patching_save(bpy.types.Operator):
|
|||
bl_options = {'REGISTER'}
|
||||
|
||||
def execute(self, context):
|
||||
patching_dir = get_patching_dir(make_dirs=True)
|
||||
patching_dir, global_dir = get_patching_dirs(make_dirs=True)
|
||||
if not patching_dir:
|
||||
self.report({'ERROR'}, 'Unable to save patches for ' + bpy.data.filepath)
|
||||
self.report({'WARNING'}, 'Unable to save patches for ' + bpy.data.filepath)
|
||||
return {'CANCELLED'}
|
||||
count = 0
|
||||
for text in bpy.data.texts:
|
||||
if not text.name.endswith('.py'):
|
||||
if not text.name.endswith('.py') or text.name.startswith('g_'):
|
||||
continue
|
||||
text_abspath = os.path.join(patching_dir, text.name)
|
||||
text_file = open(text_abspath, 'w')
|
||||
|
@ -86,23 +86,40 @@ class FILE_OT_hecl_patching_load(bpy.types.Operator):
|
|||
bl_options = {'REGISTER'}
|
||||
|
||||
def execute(self, context):
|
||||
patching_dir = get_patching_dir()
|
||||
if not patching_dir:
|
||||
self.report({'ERROR'}, 'Unable to load patches for ' + bpy.data.filepath)
|
||||
return {'CANCELLED'}
|
||||
p = Path(patching_dir)
|
||||
patching_dir, global_dir = get_patching_dirs()
|
||||
count = 0
|
||||
for path in p.glob('*.py'):
|
||||
path = path.name
|
||||
text_abspath = os.path.join(patching_dir, path)
|
||||
text_file = open(text_abspath, 'r')
|
||||
if path in bpy.data.texts:
|
||||
text = bpy.data.texts[path]
|
||||
else:
|
||||
text = bpy.data.texts.new(path)
|
||||
text.from_string(text_file.read())
|
||||
text_file.close()
|
||||
count += 1
|
||||
|
||||
# Locals
|
||||
if patching_dir:
|
||||
p = Path(patching_dir)
|
||||
for path in p.glob('*.py'):
|
||||
path = path.name
|
||||
text_abspath = os.path.join(patching_dir, path)
|
||||
text_file = open(text_abspath, 'r')
|
||||
if path in bpy.data.texts:
|
||||
text = bpy.data.texts[path]
|
||||
else:
|
||||
text = bpy.data.texts.new(path)
|
||||
text.from_string(text_file.read())
|
||||
text_file.close()
|
||||
count += 1
|
||||
|
||||
# Globals
|
||||
if global_dir:
|
||||
p = Path(global_dir)
|
||||
print('CHECKING', global_dir)
|
||||
for path in p.glob('g_*.py'):
|
||||
path = path.name
|
||||
text_abspath = os.path.join(global_dir, path)
|
||||
text_file = open(text_abspath, 'r')
|
||||
if path in bpy.data.texts:
|
||||
text = bpy.data.texts[path]
|
||||
else:
|
||||
text = bpy.data.texts.new(path)
|
||||
text.from_string(text_file.read())
|
||||
text_file.close()
|
||||
count += 1
|
||||
|
||||
if count == 1:
|
||||
self.report({'INFO'}, 'loaded 1 patch')
|
||||
else:
|
||||
|
|
|
@ -18,6 +18,7 @@ Nodegrid = Nodegrid.Nodegrid
|
|||
import bpy, os, sys
|
||||
from bpy.app.handlers import persistent
|
||||
|
||||
|
||||
# Appendable list allowing external addons to register additional resource types
|
||||
hecl_typeS = [
|
||||
('NONE', "None", "Active scene not using HECL", None, None),
|
||||
|
|
|
@ -324,6 +324,9 @@ class SREAInitializeCycles(bpy.types.Operator):
|
|||
initialize_nodetree_cycles(mat, pixel_size)
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
return context.window_manager.invoke_confirm(self, event)
|
||||
|
||||
# Lightmap render operator
|
||||
class SREARenderLightmaps(bpy.types.Operator):
|
||||
bl_idname = "scene.hecl_area_render_lightmaps"
|
||||
|
@ -347,7 +350,7 @@ class SREARenderLightmaps(bpy.types.Operator):
|
|||
|
||||
# Mmm Cycles
|
||||
context.scene.render.engine = 'CYCLES'
|
||||
context.scene.render.bake.margin = pixel_size // 128
|
||||
context.scene.render.bake.margin = pixel_size // 256
|
||||
|
||||
# Iterate materials and setup cycles
|
||||
for mat in bpy.data.materials:
|
||||
|
|
|
@ -34,9 +34,11 @@ def quitblender():
|
|||
bpy.ops.wm.quit_blender()
|
||||
|
||||
# If there's a third argument, use it as the .zip path containing the addon
|
||||
if len(args) >= 3:
|
||||
did_install = False
|
||||
if len(args) >= 3 and args[2] != 'SKIPINSTALL':
|
||||
bpy.ops.wm.addon_install(overwrite=True, target='DEFAULT', filepath=args[2])
|
||||
bpy.ops.wm.addon_refresh()
|
||||
did_install = True
|
||||
|
||||
# Make addon available to commands
|
||||
if bpy.context.user_preferences.addons.find('hecl') == -1:
|
||||
|
@ -51,6 +53,11 @@ except:
|
|||
writepipeline(b'NOADDON')
|
||||
bpy.ops.wm.quit_blender()
|
||||
|
||||
# Quit if just installed
|
||||
if did_install:
|
||||
writepipeline(b'ADDONINSTALLED')
|
||||
bpy.ops.wm.quit_blender()
|
||||
|
||||
# Intro handshake
|
||||
writepipeline(b'READY')
|
||||
ackbytes = readpipeline()
|
||||
|
|
Loading…
Reference in New Issue