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