[Bf-blender-cvs] [7d60b146762] soc-2018-npr: Added one click composition to LANPR.
Yiming Wu
noreply at git.blender.org
Fri Dec 28 14:20:58 CET 2018
Commit: 7d60b1467624cde7256c3f12c60ef735fd1d2000
Author: Yiming Wu
Date: Fri Dec 28 21:20:19 2018 +0800
Branches: soc-2018-npr
https://developer.blender.org/rB7d60b1467624cde7256c3f12c60ef735fd1d2000
Added one click composition to LANPR.
===================================================================
M release/scripts/startup/bl_operators/__init__.py
A release/scripts/startup/bl_operators/lanpr.py
M release/scripts/startup/bl_ui/properties_scene.py
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index 4d9038684d1..94c57faa6c8 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -32,6 +32,7 @@ _modules = [
"constraint",
"file",
"image",
+ "lanpr",
"mask",
"mesh",
"node",
diff --git a/release/scripts/startup/bl_operators/lanpr.py b/release/scripts/startup/bl_operators/lanpr.py
new file mode 100644
index 00000000000..7cb896b4ae1
--- /dev/null
+++ b/release/scripts/startup/bl_operators/lanpr.py
@@ -0,0 +1,164 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+import bpy
+import string
+
+def lanpr_get_composition_scene(scene):
+ n = scene.name+'_lanpr_comp'
+ for s in bpy.data.scenes:
+ if s.name == n: return s
+ return None
+
+def lanpr_make_composition_scene(scene):
+ name = scene.name;
+ new_name = scene.name+'_lanpr_comp'
+ scene.name = new_name
+ bpy.ops.scene.new(type='LINK_OBJECTS')
+ for s in bpy.data.scenes:
+ if s.name == new_name+'.001':
+ new_scene = s
+ break
+ scene.name = name
+ new_scene.name = new_name
+
+ s = new_scene
+
+ s.render.engine = 'BLENDER_LANPR'
+ s.use_nodes = True
+
+ comp = s.node_tree
+
+ comp.nodes.clear()
+ n1 = comp.nodes.new("CompositorNodeRLayers")
+ n1.scene = scene
+ n1.location = (0,0)
+ n2 = comp.nodes.new("CompositorNodeRLayers")
+ n2.scene = s
+ n2.location = (0,-300)
+
+ mix = comp.nodes.new("CompositorNodeAlphaOver")
+ mix.location = (300,-150)
+ comp.links.new(n1.outputs['Image'],mix.inputs[1])
+ comp.links.new(n2.outputs['Image'],mix.inputs[2])
+
+ out = comp.nodes.new("CompositorNodeComposite")
+ out.location = (500,-150)
+ comp.links.new(mix.outputs['Image'],out.inputs['Image'])
+
+
+class LANPR_make_composition_scene(bpy.types.Operator):
+ """Make Composition Scene"""
+ bl_idname = "lanpr.make_composition_scene"
+ bl_label = "Make Composition Scene"
+
+ @classmethod
+ def poll(cls, context):
+ return (lanpr_get_composition_scene(context.scene) is None)
+
+ def execute(self, context):
+ lanpr_make_composition_scene(context.scene)
+ return {'FINISHED'}
+
+def lanpr_remove_composition_scene(scene):
+ bpy.data.scenes.remove(lanpr_get_composition_scene(scene))
+
+class LANPR_remove_composition_scene(bpy.types.Operator):
+ """Remove Composition Scene"""
+ bl_idname = "lanpr.remove_composition_scene"
+ bl_label = "Remove Composition Scene"
+
+ @classmethod
+ def poll(cls, context):
+ return (lanpr_get_composition_scene(context.scene) is not None)
+
+ def execute(self, context):
+ lanpr_remove_composition_scene(context.scene)
+ return {'FINISHED'}
+
+def lanpr_is_composition_scene(scene):
+ return scene.name.endswith('_lanpr_comp')
+
+def lanpr_goto_original_scene(scene):
+ name = scene.name[:-len('_lanpr_comp')]
+ for s in bpy.data.scenes:
+ if s.name == name:
+ bpy.context.window.scene = s
+ break
+
+class LANPR_goto_original_scene(bpy.types.Operator):
+ """Goto Original Scene"""
+ bl_idname = "lanpr.goto_original_scene"
+ bl_label = "Goto Original Scene"
+
+ @classmethod
+ def poll(cls, context):
+ return lanpr_is_composition_scene(context.scene)
+
+ def execute(self, context):
+ lanpr_goto_original_scene(context.scene)
+ return {'FINISHED'}
+
+def lanpr_goto_composition_scene(scene):
+ name = scene.name+'_lanpr_comp'
+ for s in bpy.data.scenes:
+ if s.name == name:
+ bpy.context.window.scene = s
+ break
+
+class LANPR_goto_composition_scene(bpy.types.Operator):
+ """Goto Composition Scene"""
+ bl_idname = "lanpr.goto_composition_scene"
+ bl_label = "Goto Composition Scene"
+
+ @classmethod
+ def poll(cls, context):
+ return lanpr_get_composition_scene(context.scene) is not None
+
+ def execute(self, context):
+ lanpr_goto_composition_scene(context.scene)
+ return {'FINISHED'}
+
+ at persistent
+def lanpr_render_composited_still(scene):
+
+ at persistent
+def lanpr_render_composited_still(scene):
+
+
+class LANPR_render_composited_still(bpy.types.Operator):
+ """Render Composited Still"""
+ bl_idname = "lanpr.goto_composition_scene"
+ bl_label = "Render Composited Still"
+
+ @classmethod
+ def poll(cls, context):
+ return lanpr_get_composition_scene(context.scene) is not None
+
+ def execute(self, context):
+ lanpr_goto_composition_scene(context.scene)
+ return {'FINISHED'}
+
+classes=(
+ LANPR_make_composition_scene,
+ LANPR_remove_composition_scene,
+ LANPR_goto_original_scene,
+ LANPR_goto_composition_scene,
+)
\ No newline at end of file
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 7169080a6dc..957c92eea29 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -622,8 +622,17 @@ class LANPR_linesets(UIList):
layout.alignment = 'CENTER'
layout.label("", icon_value=icon)
+def lanpr_get_composition_scene(scene):
+ n = scene.name+'_lanpr_comp'
+ for s in bpy.data.scenes:
+ if s.name == n: return s
+ return None
+
+def lanpr_is_composition_scene(scene):
+ return scene.name.endswith('_lanpr_comp')
+
class SCENE_PT_lanpr(SceneButtonsPanel, Panel):
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL', 'BLENDER_EEVEE'}
bl_label = "LANPR"
bl_options = {'DEFAULT_CLOSED'}
@@ -635,7 +644,30 @@ class SCENE_PT_lanpr(SceneButtonsPanel, Panel):
layout = self.layout
scene = context.scene
lanpr = scene.lanpr
- active_layer = lanpr.layers.active_layer
+ active_layer = lanpr.layers.active_layer
+
+ sc = lanpr_get_composition_scene(scene)
+
+ if lanpr_is_composition_scene(scene):
+ row = layout.row()
+ row.scale_y=1.5
+ row.operator("lanpr.goto_original_scene")
+
+ if sc is not None:
+ layout.label(text = 'You are adjusting values for LANPR compostion scene.')
+ row = layout.row()
+ row.scale_y=1.5
+ row.operator("lanpr.goto_composition_scene")
+ layout.operator("lanpr.remove_composition_scene")
+ scene = sc
+ lanpr = scene.lanpr
+ active_layer = lanpr.layers.active_layer
+ return
+ elif scene.render.engine!='BLENDER_LANPR':
+ layout.label(text = 'Select LANPR engine or use composition scene.')
+ layout.operator("lanpr.make_composition_scene")
+ return
+
layout.prop(lanpr, "master_mode", expand=True)
@@ -668,19 +700,17 @@ class SCENE_PT_lanpr(SceneButtonsPanel, Panel):
layout.operator("scene.lanpr_rebuild_all_commands")
else:
layout.operator("scene.lanpr_add_line_layer")
-
- layout.label(text= "Normal:")
- layout.prop(active_layer,"normal_mode", expand = True)
- if active_layer.normal_mode != "DISABLED":
- layout.prop(active_layer,"normal_control_object")
- layout.prop(active_layer,"normal_effect_inverse", toggle = True)
- layout.prop(active_layer,"normal_ramp_begin")
- layout.prop(active_layer,"normal_ramp_end")
- layout.prop(active_layer,"normal_thickness_begin", slider=True)
- layout.prop(active_layer,"normal_thickness_end", slider=True)
-
- elif not lanpr.layers.active_layer:
- layout.operator("scene.lanpr_add_line_layer")
+
+ if active_layer:
+ layout.label(text= "Normal:")
+ layout.prop(active_layer,"normal_mode", expand = True)
+ if active_layer.normal_mode != "DISABLED":
+ layout.prop(active_layer,"normal_control_object")
+ layout.prop(active_layer,"normal_effect_inverse", toggle = True)
+ layout.prop(active_layer,"normal_ramp_begin")
+ layout.prop(active_layer,"normal_ramp_end")
+ layout.prop(active_layer,"normal_thickness_begin", slider=True)
+ layout.prop(active_layer,"normal_thickness_end", slider=True)
else:
layout.label(text="Vectorization:")
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 4f70ae87077..3857f52678c 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1578,6 +1578,10 @@ typedef struct SceneLANPR {
int enable_intersections;
int enable_chaining;
+ /* composite utility */
+ int composite_render_animation;
+ int what;
+
} SceneLANPR;
/* *************************************************************** */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 7314f5210d6..e8f146c8116
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list