1 # SPDX-License-Identifier: GPL-2.0-or-later
4 from mathutils
import Vector
7 class AMTH_NODE_OT_AddTemplateVectorBlur(bpy
.types
.Operator
):
8 bl_idname
= "node.template_add_vectorblur"
9 bl_label
= "Add Vector Blur"
10 bl_description
= "Add a vector blur filter"
11 bl_options
= {"REGISTER", "UNDO"}
14 def poll(cls
, context
):
15 space
= context
.space_data
16 tree
= context
.scene
.node_tree
17 return space
.type == "NODE_EDITOR" \
18 and space
.node_tree
is not None \
19 and space
.tree_type
== "CompositorNodeTree" \
21 and tree
.nodes
.active \
22 and tree
.nodes
.active
.type == "R_LAYERS"
24 def _setupNodes(self
, context
):
26 space
= context
.space_data
27 tree
= scene
.node_tree
29 bpy
.ops
.node
.select_all(action
="DESELECT")
31 act_node
= tree
.nodes
.active
32 #rlayer = act_node.scene.render.layers[act_node.layer]
34 #if not rlayer.use_pass_vector:
35 #rlayer.use_pass_vector = True
37 vblur
= tree
.nodes
.new(type="CompositorNodeVecBlur")
38 vblur
.use_curved
= True
41 tree
.links
.new(act_node
.outputs
["Image"], vblur
.inputs
["Image"])
42 tree
.links
.new(act_node
.outputs
["Depth"], vblur
.inputs
["Z"])
43 tree
.links
.new(act_node
.outputs
["Vector"], vblur
.inputs
["Speed"])
46 vblur
.location
= tree
.nodes
.active
.location
47 vblur
.location
+= Vector((250.0, 0.0))
49 vblur
.location
+= Vector(
50 (space
.cursor_location
[0], space
.cursor_location
[1]))
54 def execute(self
, context
):
55 self
._setupNodes
(context
)