Не подтверждена Коммит 6019f8e8 создал по автору Sergey's avatar Sergey Зафиксировано автором GitHub
Просмотр файлов

Scene handler (#4299)

add new scene handler
should update nodes reading data from Blender upon changes in the scene

* remove update live mode

* Remove AnimatableNode mix-in class and create is_animation_dependent property instead. Also add is_scene_dependent property which handled nodes to be updated upon user changes in scene
владелец 86957d45
...@@ -33,6 +33,7 @@ class TreeEvent: ...@@ -33,6 +33,7 @@ class TreeEvent:
NODES_UPDATE = 'nodes_update' # changes in node properties, update animated nodes NODES_UPDATE = 'nodes_update' # changes in node properties, update animated nodes
FORCE_UPDATE = 'force_update' # rebuild tree and reevaluate every node FORCE_UPDATE = 'force_update' # rebuild tree and reevaluate every node
FRAME_CHANGE = 'frame_change' # unlike other updates this one should be un-cancellable FRAME_CHANGE = 'frame_change' # unlike other updates this one should be un-cancellable
SCENE_UPDATE = 'scene_update' # something was changed in the scene
def __init__(self, event_type: str, tree: SverchCustomTree, updated_nodes: Iterable[SvNode] = None, cancel=True): def __init__(self, event_type: str, tree: SverchCustomTree, updated_nodes: Iterable[SvNode] = None, cancel=True):
self.type = event_type self.type = event_type
...@@ -40,6 +41,9 @@ class TreeEvent: ...@@ -40,6 +41,9 @@ class TreeEvent:
self.updated_nodes = updated_nodes self.updated_nodes = updated_nodes
self.cancel = cancel self.cancel = cancel
def __repr__(self):
return f"<TreeEvent type={self.type}>"
class GroupEvent: class GroupEvent:
GROUP_NODE_UPDATE = 'group_node_update' GROUP_NODE_UPDATE = 'group_node_update'
......
...@@ -215,12 +215,19 @@ def update_frame_change_mode(): ...@@ -215,12 +215,19 @@ def update_frame_change_mode():
set_frame_change(mode) set_frame_change(mode)
@persistent
def update_trees_scene_change(scene):
for ng in BlTrees().sv_main_trees:
ng.scene_update()
handler_dict = { handler_dict = {
'undo_pre': sv_handler_undo_pre, 'undo_pre': sv_handler_undo_pre,
'undo_post': sv_handler_undo_post, 'undo_post': sv_handler_undo_post,
'load_pre': sv_pre_load, 'load_pre': sv_pre_load,
'load_post': sv_post_load, 'load_post': sv_post_load,
'depsgraph_update_pre': sv_main_handler 'depsgraph_update_pre': sv_main_handler,
'depsgraph_update_post': update_trees_scene_change,
} }
......
...@@ -40,6 +40,17 @@ class TreeHandler: ...@@ -40,6 +40,17 @@ class TreeHandler:
list(global_updater(event.type)) list(global_updater(event.type))
return return
# something changed in scene and it duplicates some tree events which should be ignored
elif event.type == TreeEvent.SCENE_UPDATE:
# Either the scene handler was triggered by changes in the tree or tree is still in progress
if NodesUpdater.has_task():
return # ignore the event
# this event was caused my update system itself and should be ignored
elif 'SKIP_UPDATE' in event.tree:
del event.tree['SKIP_UPDATE']
return
ContextTrees.mark_nodes_outdated(event.tree, event.updated_nodes)
# mark given nodes as outdated # mark given nodes as outdated
elif event.type == TreeEvent.NODES_UPDATE: elif event.type == TreeEvent.NODES_UPDATE:
ContextTrees.mark_nodes_outdated(event.tree, event.updated_nodes) ContextTrees.mark_nodes_outdated(event.tree, event.updated_nodes)
...@@ -239,6 +250,12 @@ def global_updater(event_type: str) -> Generator[Node, None, None]: ...@@ -239,6 +250,12 @@ def global_updater(event_type: str) -> Generator[Node, None, None]:
bl_tree.update_ui() # this only will update UI of main trees bl_tree.update_ui() # this only will update UI of main trees
trees_ui_to_update.discard(bl_tree) # protection from double updating trees_ui_to_update.discard(bl_tree) # protection from double updating
# this only need to trigger scene changes handler again
bl_tree.nodes[-1].use_custom_color = not bl_tree.nodes[-1].use_custom_color
bl_tree.nodes[-1].use_custom_color = not bl_tree.nodes[-1].use_custom_color
# this indicates that process of the tree is finished and next scene event can be skipped
bl_tree['SKIP_UPDATE'] = True
# this will update all opened trees (in group editors) # this will update all opened trees (in group editors)
# regardless whether the trees was changed or not, including group nodes # regardless whether the trees was changed or not, including group nodes
for bl_tree in trees_ui_to_update: for bl_tree in trees_ui_to_update:
......
...@@ -136,13 +136,6 @@ Node property / socket property changes ...@@ -136,13 +136,6 @@ Node property / socket property changes
`Update all` operator (:ref:`layout_manager`) `Update all` operator (:ref:`layout_manager`)
It is the same as `re-update all nodes` operator but effect all trees in a file. It is the same as `re-update all nodes` operator but effect all trees in a file.
.. _live_update_operator:
Live update modal operator (:ref:`3d_panel`)
It makes update some nodes, which read information from Blender objects, via timer with update period
about 1/10 second. If the tree did not manage to update while this period next event will be ignored.
In this case there can be a visible lag between user action and tree response.
Frame changes Frame changes
Update upon frame changes. Extra information `Animation`_. Update upon frame changes. Extra information `Animation`_.
...@@ -152,19 +145,30 @@ Frame changes ...@@ -152,19 +145,30 @@ Frame changes
Also you can add shortcut for the operator by pressing :kbd:`RMB` on the button of the operator (active tree panel). Also you can add shortcut for the operator by pressing :kbd:`RMB` on the button of the operator (active tree panel).
Another way to update is enabling `Live update` mode. In this case only changed put of the tree will be updated. Another way to update is enabling `Live update` mode. In this case only changed put of the tree will be updated.
Scene changes
This trigger reacts on arbitrary changes in scene. Those can be: moving
objects, changing edit / object mode, mesh editing, assign materials etc.
Modes (:ref:`active_tree_panel`) Modes (:ref:`active_tree_panel`)
-------------------------------- --------------------------------
Live update Live update
If enabled it means that the tree will be evaluated upon changes in topology or changes in properties of a node If enabled it means that the tree will be evaluated upon changes in its
made by user. This property does not effect evaluation upon frame changes or by `re-update all nodes` operator. topology, changes in node properties or scene changes made by user.
This property does not effect evaluation upon frame changes or by
`re-update all nodes` operator.
Enabling the property will call the tree topology changes trigger. Enabling the property will call the tree topology changes trigger.
Animate Animate
If enabled the tree will be reevaluated upon frame change. The update can effect not all nodes but only those If enabled the tree will be reevaluated upon frame change. The update can effect not all nodes but only those
which have property `to_animate` enabled. which have property `to_animate` enabled.
Scene update
If enabled togather with Live Update the tree will be reevaluated upon
changes in the scene. It will effect only nodes with `interactive`
property enabled.
Animation Animation
========= =========
...@@ -183,9 +187,10 @@ enabled the node will be update each frame change. This can serve two purposes. ...@@ -183,9 +187,10 @@ enabled the node will be update each frame change. This can serve two purposes.
- Firstly this can be used for generating animations. In this case - Firstly this can be used for generating animations. In this case
:doc:`Frame info node <nodes/scene/frame_info_mk2>` will be most useful. :doc:`Frame info node <nodes/scene/frame_info_mk2>` will be most useful.
- Secondly updating nodes upon frame change can be used for refreshing nodes which take data from Blender data blocks. - **(Deprecated, the Scene trigger is used instead now)** Secondly updating
For frame change the left/right arrow buttons can be used. Alternative way is to use nodes upon frame change can be used for refreshing nodes which take data from
:ref:`Live update operator <live_update_operator>` Blender data blocks. For frame change the left/right arrow buttons can be
used.
.. warning:: .. warning::
......
...@@ -37,6 +37,8 @@ Tree item buttons: ...@@ -37,6 +37,8 @@ Tree item buttons:
Controls all OpenGL viewer of this layout. Viewer, Stethoscope and Viewer Indices Controls all OpenGL viewer of this layout. Viewer, Stethoscope and Viewer Indices
Animate layout Animate layout
to animate the layout (or not) - may preserve you time. to animate the layout (or not) - may preserve you time.
Scene Update
Update upon changes in the scene
Process layout Process layout
Automatically evaluate layout while editing, disable for large or complex layouts (F6) Automatically evaluate layout while editing, disable for large or complex layouts (F6)
Draft Mode Draft Mode
...@@ -70,10 +72,19 @@ Animate ...@@ -70,10 +72,19 @@ Animate
If enabled the tree will be reevaluated upon frame change. The update can effect not all nodes but only those If enabled the tree will be reevaluated upon frame change. The update can effect not all nodes but only those
which have property to_animate enabled. which have property to_animate enabled.
Scene update
If enabled togather with Live Update the tree will be reevaluated upon
changes in the scene. It will effect only nodes with `interactive`
property enabled.
Live update Live update
If enabled it means that the tree will be evaluated upon changes in topology or changes in properties of a node If enabled it means that the tree will be evaluated upon changes in its
made by user. This property does not effect evaluation upon frame changes or by **Re-update all nodes** operator. topology, changes in node properties or scene changes made by user.
Enabling the property will call the tree topology changes :ref:`trigger <sv_triggers>`. This property does not effect evaluation upon frame changes or by
`re-update all nodes` operator.
Enabling the property will call the tree topology changes
:ref:`trigger <sv_triggers>`.
Draft mode Draft mode
It switches to draft property in :doc:`A number node <../nodes/number/numbers>` and some others. It switches to draft property in :doc:`A number node <../nodes/number/numbers>` and some others.
...@@ -397,9 +408,6 @@ With this panel your layout becomes addon itself. So, you making your life easy. ...@@ -397,9 +408,6 @@ With this panel your layout becomes addon itself. So, you making your life easy.
Since Blender 2.8 this panel has two instances. One instance located on `N` panel in `Tool` category of `3D` editor. Since Blender 2.8 this panel has two instances. One instance located on `N` panel in `Tool` category of `3D` editor.
Another located in `Active tool and workspace settings` shelf of `Properties` editor. Another located in `Active tool and workspace settings` shelf of `Properties` editor.
**Start live update** - will start update layouts by a timer (several times in second)
**Update all trees** - manual update of all layouts **Update all trees** - manual update of all layouts
Node properties list Node properties list
......
...@@ -53,8 +53,6 @@ This is a collection of shortcuts useful in the Sverchok node tree, some are Ble ...@@ -53,8 +53,6 @@ This is a collection of shortcuts useful in the Sverchok node tree, some are Ble
.. image:: https://user-images.githubusercontent.com/10011941/78453090-d4c06180-768f-11ea-8631-422fe63f994e.gif .. image:: https://user-images.githubusercontent.com/10011941/78453090-d4c06180-768f-11ea-8631-422fe63f994e.gif
**Ctrl + Shift + F5** in 3D View window - Enables/Disables "Live Update" mode
**F6** - Enables/Disables the processing of the current node-tree **F6** - Enables/Disables the processing of the current node-tree
**F7** - Enables/Disables the Draft mode of the current node-tree **F7** - Enables/Disables the Draft mode of the current node-tree
......
...@@ -141,6 +141,8 @@ class SverchCustomTree(NodeTree, SvNodeTreeCommon): ...@@ -141,6 +141,8 @@ class SverchCustomTree(NodeTree, SvNodeTreeCommon):
update=on_draft_mode_changed, update=on_draft_mode_changed,
options=set(), options=set(),
) )
sv_scene_update: BoolProperty(name="Scene update", description="Update upon changes in the scene", options=set(),
default=True)
def update(self): def update(self):
"""This method is called if collection of nodes or links of the tree was changed""" """This method is called if collection of nodes or links of the tree was changed"""
...@@ -155,14 +157,34 @@ class SverchCustomTree(NodeTree, SvNodeTreeCommon): ...@@ -155,14 +157,34 @@ class SverchCustomTree(NodeTree, SvNodeTreeCommon):
"""This method expects to get list of its nodes which should be updated""" """This method expects to get list of its nodes which should be updated"""
return TreeHandler.send(TreeEvent(TreeEvent.NODES_UPDATE, self, nodes, cancel)) return TreeHandler.send(TreeEvent(TreeEvent.NODES_UPDATE, self, nodes, cancel))
def scene_update(self):
"""This method should be called by scene changes handler
it ignores events related with S
sverchok trees in other cases it updates nodes which read data from Blender"""
def nodes_to_update():
for node in self.nodes:
try:
if node.is_scene_dependent and node.is_interactive:
yield node
except AttributeError:
pass
if self.sv_scene_update:
TreeHandler.send(TreeEvent(TreeEvent.SCENE_UPDATE, self, nodes_to_update(), cancel=False))
def process_ani(self): def process_ani(self):
""" """
Process the Sverchok node tree if animation layers show true. Process the Sverchok node tree if animation layers show true.
For animation callback/handler For animation callback/handler
""" """
def animated_nodes():
for node in self.nodes:
try:
if node.is_animation_dependent and node.is_animatable:
yield node
except AttributeError:
pass
if self.sv_animate: if self.sv_animate:
animated_nodes = (n for n in self.nodes if hasattr(n, 'is_animatable') and n.is_animatable) TreeHandler.send(TreeEvent(TreeEvent.FRAME_CHANGE, self, animated_nodes()))
TreeHandler.send(TreeEvent(TreeEvent.FRAME_CHANGE, self, animated_nodes))
def update_ui(self): def update_ui(self):
""" The method get information about node statistic of last update from the handler to show in view space """ The method get information about node statistic of last update from the handler to show in view space
...@@ -193,6 +215,23 @@ class UpdateNodes: ...@@ -193,6 +215,23 @@ class UpdateNodes:
self.n_id = str(hash(self) ^ hash(time.monotonic())) self.n_id = str(hash(self) ^ hash(time.monotonic()))
return self.n_id return self.n_id
def update_interactive_mode(self, context):
if self.is_interactive:
self.process_node(context)
is_interactive: BoolProperty(default=True, description="Update node upon changes in the scene",
update=update_interactive_mode, name="Interactive")
is_scene_dependent = False # if True and is_interactive then the node will be updated upon scene changes
def refresh_node(self, context):
if self.refresh:
self.refresh = False
self.process_node(context)
refresh: BoolProperty(name="Update Node", description="Update Node", update=refresh_node)
is_animatable: BoolProperty(name="Animate Node", description="Update Node on frame change", default=True)
is_animation_dependent = False # if True and is_animatable the the node will be updated on frame change
def sv_init(self, context): def sv_init(self, context):
""" """
This method will be called during node creation This method will be called during node creation
...@@ -417,6 +456,34 @@ class SverchCustomTreeNode(UpdateNodes, NodeUtils): ...@@ -417,6 +456,34 @@ class SverchCustomTreeNode(UpdateNodes, NodeUtils):
"""Base class for all nodes""" """Base class for all nodes"""
_docstring = None # A cache for docstring property _docstring = None # A cache for docstring property
def draw_buttons(self, context, layout):
if self.id_data.bl_idname == SverchCustomTree.bl_idname:
row = layout.row(align=True)
if self.is_animation_dependent:
row.prop(self, 'is_animatable', icon='ANIM', icon_only=True)
if self.is_scene_dependent:
row.prop(self, 'is_interactive', icon='SCENE_DATA', icon_only=True)
if self.is_animation_dependent or self.is_scene_dependent:
row.prop(self, 'refresh', icon='FILE_REFRESH')
self.sv_draw_buttons(context, layout)
def sv_draw_buttons(self, context, layout):
pass
def draw_buttons_ext(self, context, layout):
if self.id_data.bl_idname == SverchCustomTree.bl_idname:
row = layout.row(align=True)
if self.is_animation_dependent:
row.prop(self, 'is_animatable', icon='ANIM')
if self.is_scene_dependent:
row.prop(self, 'is_interactive', icon='SCENE_DATA')
if self.is_animation_dependent or self.is_scene_dependent:
row.prop(self, 'refresh', icon='FILE_REFRESH')
self.sv_draw_buttons_ext(context, layout)
def sv_draw_buttons_ext(self, context, layout):
self.sv_draw_buttons(context, layout)
@classproperty @classproperty
def docstring(cls): def docstring(cls):
""" """
......
...@@ -17,16 +17,14 @@ ...@@ -17,16 +17,14 @@
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
import bpy import bpy
import mathutils
import numpy as np import numpy as np
from mathutils import Vector from mathutils import Vector
from mathutils.bvhtree import BVHTree from mathutils.bvhtree import BVHTree
from bpy.props import BoolProperty, IntProperty from bpy.props import BoolProperty, IntProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.data_structure import (updateNode, match_long_repeat, match_cross) from sverchok.data_structure import (updateNode, match_long_repeat, match_cross)
from sverchok.utils.logging import debug, info, error
class FakeObj(object): class FakeObj(object):
...@@ -56,14 +54,23 @@ class FakeObj(object): ...@@ -56,14 +54,23 @@ class FakeObj(object):
return [True, tv[0], tv[1], tv[2]] return [True, tv[0], tv[1], tv[2]]
class SvOBJInsolationNode(bpy.types.Node, SverchCustomTreeNode):
class SvOBJInsolationNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
''' Insolation by RayCast Object ''' ''' Insolation by RayCast Object '''
bl_idname = 'SvOBJInsolationNode' bl_idname = 'SvOBJInsolationNode'
bl_label = 'Object ID Insolation' bl_label = 'Object ID Insolation'
bl_icon = 'OUTLINER_OB_EMPTY' bl_icon = 'OUTLINER_OB_EMPTY'
sv_icon = 'SV_INSOLATION' sv_icon = 'SV_INSOLATION'
@property
def is_scene_dependent(self):
return ((not self.inputs['Predator'].is_linked and self.inputs['Predator'].object_ref_pointer)
or (not self.inputs['Victim'].is_linked and self.inputs['Victim'].object_ref_pointer))
@property
def is_animation_dependent(self):
return ((not self.inputs['Predator'].is_linked and self.inputs['Predator'].object_ref_pointer)
or (not self.inputs['Victim'].is_linked and self.inputs['Victim'].object_ref_pointer))
mode: BoolProperty(name='input mode', default=False, update=updateNode) mode: BoolProperty(name='input mode', default=False, update=updateNode)
#mode2 = BoolProperty(name='output mode', default=False, update=updateNode) #mode2 = BoolProperty(name='output mode', default=False, update=updateNode)
sort_critical: IntProperty(name='sort_critical', default=12, min=1,max=24, update=updateNode) sort_critical: IntProperty(name='sort_critical', default=12, min=1,max=24, update=updateNode)
...@@ -81,11 +88,7 @@ class SvOBJInsolationNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode ...@@ -81,11 +88,7 @@ class SvOBJInsolationNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode
so('SvStringsSocket', "Hours") so('SvStringsSocket', "Hours")
# self.inputs[2].prop[2] = -1 # z down # <--- mayybe? # self.inputs[2].prop[2] = -1 # z down # <--- mayybe?
def draw_buttons(self, context, layout): def sv_draw_buttons_ext(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
def draw_buttons_ext(self, context, layout):
self.draw_animatable_buttons(layout)
row = layout.row(align=True) row = layout.row(align=True)
row.prop(self, "mode", text="In Mode") row.prop(self, "mode", text="In Mode")
row.prop(self, "sort_critical",text="Limit") row.prop(self, "sort_critical",text="Limit")
...@@ -137,7 +140,6 @@ class SvOBJInsolationNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode ...@@ -137,7 +140,6 @@ class SvOBJInsolationNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode
rec.data.vertex_colors.new(name='SvInsol') rec.data.vertex_colors.new(name='SvInsol')
colors = rec.data.vertex_colors['SvInsol'].data colors = rec.data.vertex_colors['SvInsol'].data
for i, pol in enumerate(rec.data.polygons): for i, pol in enumerate(rec.data.polygons):
self.debug(pol.loop_indices,OutS[0][i])
for co in pol.loop_indices: for co in pol.loop_indices:
colors[co].color = OutS[0][i] colors[co].color = OutS[0][i]
......
...@@ -21,7 +21,6 @@ import bpy ...@@ -21,7 +21,6 @@ import bpy
from bpy.props import BoolProperty, FloatProperty, EnumProperty, StringProperty from bpy.props import BoolProperty, FloatProperty, EnumProperty, StringProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.data_structure import updateNode from sverchok.data_structure import updateNode
from sverchok.utils.sv_itertools import recurse_f_level_control from sverchok.utils.sv_itertools import recurse_f_level_control
...@@ -30,9 +29,7 @@ from sverchok.utils.sv_color_ramp_utils import ( ...@@ -30,9 +29,7 @@ from sverchok.utils.sv_color_ramp_utils import (
set_color_ramp, set_color_ramp,
get_color_ramp) get_color_ramp)
from sverchok.utils.curve import SvScalarFunctionCurve
import numpy as np
node_group_name = 'sverchok_helper_group' node_group_name = 'sverchok_helper_group'
def color_ramp_mapper(params, constant, matching_f): def color_ramp_mapper(params, constant, matching_f):
...@@ -46,7 +43,7 @@ def color_ramp_mapper(params, constant, matching_f): ...@@ -46,7 +43,7 @@ def color_ramp_mapper(params, constant, matching_f):
result.append([evaluate(v)[:-1] for v in flist]) result.append([evaluate(v)[:-1] for v in flist])
return result return result
class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode):
""" """
Triggers: Color Gradient Triggers: Color Gradient
Tooltip: Map input list to a defined color Tooltip: Map input list to a defined color
...@@ -56,6 +53,7 @@ class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): ...@@ -56,6 +53,7 @@ class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
bl_label = 'Color Ramp' bl_label = 'Color Ramp'
bl_icon = 'COLOR' bl_icon = 'COLOR'
sv_icon = 'SV_COLOR_RAMP' sv_icon = 'SV_COLOR_RAMP'
is_scene_dependent = True
value: FloatProperty( value: FloatProperty(
name='Value', description='Input value(s)', name='Value', description='Input value(s)',
...@@ -71,14 +69,12 @@ class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): ...@@ -71,14 +69,12 @@ class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
self.outputs.new('SvColorSocket', "Color") self.outputs.new('SvColorSocket', "Color")
_ = get_evaluator(node_group_name, self._get_color_ramp_node_name()) _ = get_evaluator(node_group_name, self._get_color_ramp_node_name())
def sv_draw_buttons(self, context, layout):
def draw_buttons(self, context, layout):
m = bpy.data.node_groups.get(node_group_name) m = bpy.data.node_groups.get(node_group_name)
if not m: if not m:
layout.label(text="Connect input to activate") layout.label(text="Connect input to activate")
return return
try: try:
self.draw_animatable_buttons(layout, icon_only=True, update_big=True)
layout.prop(self, 'use_alpha') layout.prop(self, 'use_alpha')
tnode = m.nodes[self._get_color_ramp_node_name()] tnode = m.nodes[self._get_color_ramp_node_name()]
if not tnode: if not tnode:
......
...@@ -21,7 +21,6 @@ from bpy.props import EnumProperty, BoolProperty ...@@ -21,7 +21,6 @@ from bpy.props import EnumProperty, BoolProperty
from mathutils import Vector from mathutils import Vector
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.core.socket_data import SvGetSocketInfo from sverchok.core.socket_data import SvGetSocketInfo
from sverchok.utils.sv_IO_pointer_helpers import unpack_pointer_property_name from sverchok.utils.sv_IO_pointer_helpers import unpack_pointer_property_name
from sverchok.data_structure import (updateNode, list_match_func, numpy_list_match_modes, from sverchok.data_structure import (updateNode, list_match_func, numpy_list_match_modes,
...@@ -75,7 +74,8 @@ mapper_funcs = { ...@@ -75,7 +74,8 @@ mapper_funcs = {
'Object': lambda v: Vector(v), 'Object': lambda v: Vector(v),
} }
class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode):
""" """
Triggers: Scene Texture In Triggers: Scene Texture In
Tooltip: Evaluate Scene texture at input coordinates Tooltip: Evaluate Scene texture at input coordinates
...@@ -86,6 +86,10 @@ class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl ...@@ -86,6 +86,10 @@ class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl
bl_label = 'Texture Evaluate' bl_label = 'Texture Evaluate'
bl_icon = 'FORCE_TEXTURE' bl_icon = 'FORCE_TEXTURE'
@property
def is_scene_dependent(self):
return not self.inputs['Texture'].is_linked and self.texture_pointer
texture_coord_modes = [ texture_coord_modes = [
('UV', 'UV coordinates', 'Input UV coordinates to evaluate texture. (0 to 1 as domain)', '', 1), ('UV', 'UV coordinates', 'Input UV coordinates to evaluate texture. (0 to 1 as domain)', '', 1),
('Object', 'Object', 'Input Object coordinates to evaluate texture. (-1 to 1 as domain)', '', 2), ('Object', 'Object', 'Input Object coordinates to evaluate texture. (-1 to 1 as domain)', '', 2),
...@@ -144,8 +148,8 @@ class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl ...@@ -144,8 +148,8 @@ class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl
c.prop_search(self, "texture_pointer", bpy.data, 'textures', text="") c.prop_search(self, "texture_pointer", bpy.data, 'textures', text="")
else: else:
layout.label(text=socket.name+ '. ' + SvGetSocketInfo(socket)) layout.label(text=socket.name+ '. ' + SvGetSocketInfo(socket))
def draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True) def sv_draw_buttons(self, context, layout):
b = layout.split(factor=0.33, align=True) b = layout.split(factor=0.33, align=True)
b.label(text='Mapping:') b.label(text='Mapping:')
b.prop(self, 'tex_coord_type', expand=False, text='') b.prop(self, 'tex_coord_type', expand=False, text='')
...@@ -155,9 +159,8 @@ class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl ...@@ -155,9 +159,8 @@ class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl
if self.color_channel == 'Color': if self.color_channel == 'Color':
layout.prop(self, 'use_alpha', text="Use Alpha") layout.prop(self, 'use_alpha', text="Use Alpha")
def draw_buttons_ext(self, context, layout): def sv_draw_buttons_ext(self, context, layout):
'''draw buttons on the N-panel''' '''draw buttons on the N-panel'''
self.draw_buttons(context, layout)
layout.prop(self, 'list_match', expand=False) layout.prop(self, 'list_match', expand=False)
def rclick_menu(self, context, layout): def rclick_menu(self, context, layout):
......
...@@ -7,10 +7,8 @@ ...@@ -7,10 +7,8 @@
import bpy import bpy
from bpy.props import FloatProperty, EnumProperty, BoolProperty, StringProperty from bpy.props import FloatProperty, EnumProperty, BoolProperty, StringProperty
from mathutils import Vector
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.utils.nodes_mixins.show_3d_properties import Show3DProperties from sverchok.utils.nodes_mixins.show_3d_properties import Show3DProperties
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
from sverchok.data_structure import updateNode, zip_long_repeat, split_by_count from sverchok.data_structure import updateNode, zip_long_repeat, split_by_count
...@@ -31,7 +29,7 @@ class SvBezierInCallbackOp(bpy.types.Operator, SvGenericNodeLocator): ...@@ -31,7 +29,7 @@ class SvBezierInCallbackOp(bpy.types.Operator, SvGenericNodeLocator):
node.get_objects_from_scene(self) node.get_objects_from_scene(self)
class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode):
""" """
Triggers: Input Bezier Triggers: Input Bezier
Tooltip: Get Bezier Curve objects from scene Tooltip: Get Bezier Curve objects from scene
...@@ -41,6 +39,14 @@ class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvA ...@@ -41,6 +39,14 @@ class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvA
bl_icon = 'OUTLINER_OB_EMPTY' bl_icon = 'OUTLINER_OB_EMPTY'
sv_icon = 'SV_OBJECTS_IN' sv_icon = 'SV_OBJECTS_IN'
@property
def is_scene_dependent(self):
return self.object_names
@property
def is_animation_dependent(self):
return self.object_names
object_names: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup) object_names: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
sort: BoolProperty( sort: BoolProperty(
...@@ -100,17 +106,13 @@ class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvA ...@@ -100,17 +106,13 @@ class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvA
else: else:
layout.label(text='--None--') layout.label(text='--None--')
def draw_buttons_ext(self, context, layout):
layout.prop(self, "draw_3dpanel")
def draw_buttons_3dpanel(self, layout): def draw_buttons_3dpanel(self, layout):
row = layout.row(align=True) row = layout.row(align=True)
row.label(text=self.label if self.label else self.name) row.label(text=self.label if self.label else self.name)
self.wrapper_tracked_ui_draw_op(row, SvBezierInCallbackOp.bl_idname, text='GET') self.wrapper_tracked_ui_draw_op(row, SvBezierInCallbackOp.bl_idname, text='GET')
self.wrapper_tracked_ui_draw_op(row, "node.sv_nodeview_zoom_border", text="", icon="TRACKER_DATA") self.wrapper_tracked_ui_draw_op(row, "node.sv_nodeview_zoom_border", text="", icon="TRACKER_DATA")
def draw_buttons(self, context, layout): def sv_draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
col = layout.column(align=True) col = layout.column(align=True)
row = col.row(align=True) row = col.row(align=True)
......
...@@ -10,14 +10,12 @@ from bpy.props import FloatProperty, EnumProperty, BoolProperty, StringProperty ...@@ -10,14 +10,12 @@ from bpy.props import FloatProperty, EnumProperty, BoolProperty, StringProperty
from mathutils import Vector from mathutils import Vector
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.utils.nodes_mixins.show_3d_properties import Show3DProperties from sverchok.utils.nodes_mixins.show_3d_properties import Show3DProperties
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
from sverchok.data_structure import updateNode, zip_long_repeat, split_by_count from sverchok.data_structure import updateNode, zip_long_repeat, split_by_count
from sverchok.utils.curve import knotvector as sv_knotvector from sverchok.utils.curve import knotvector as sv_knotvector
from sverchok.utils.curve.nurbs import SvNurbsCurve from sverchok.utils.curve.nurbs import SvNurbsCurve
from sverchok.utils.surface.nurbs import SvNurbsSurface from sverchok.utils.surface.nurbs import SvNurbsSurface
from sverchok.utils.dummy_nodes import add_dummy
from sverchok.dependencies import geomdl from sverchok.dependencies import geomdl
if geomdl is not None: if geomdl is not None:
...@@ -39,7 +37,7 @@ class SvExNurbsInCallbackOp(bpy.types.Operator, SvGenericNodeLocator): ...@@ -39,7 +37,7 @@ class SvExNurbsInCallbackOp(bpy.types.Operator, SvGenericNodeLocator):
getattr(node, self.fn_name)(self) getattr(node, self.fn_name)(self)
class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode):
""" """
Triggers: Input NURBS Triggers: Input NURBS
Tooltip: Get NURBS curve or surface objects from scene Tooltip: Get NURBS curve or surface objects from scene
...@@ -48,6 +46,8 @@ class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, Sv ...@@ -48,6 +46,8 @@ class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, Sv
bl_label = 'NURBS In' bl_label = 'NURBS In'
bl_icon = 'OUTLINER_OB_EMPTY' bl_icon = 'OUTLINER_OB_EMPTY'
sv_icon = 'SV_OBJECTS_IN' sv_icon = 'SV_OBJECTS_IN'
is_scene_dependent = True
is_animation_dependent = True
object_names: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup) object_names: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
...@@ -118,12 +118,7 @@ class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, Sv ...@@ -118,12 +118,7 @@ class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, Sv
items = get_implementations, items = get_implementations,
update = updateNode) update = updateNode)
def draw_buttons_ext(self, context, layout): def sv_draw_buttons(self, context, layout):
layout.prop(self, "draw_3dpanel")
def draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
layout.prop(self, 'implementation', text='') layout.prop(self, 'implementation', text='')
col = layout.column(align=True) col = layout.column(align=True)
row = col.row(align=True) row = col.row(align=True)
......
...@@ -22,7 +22,6 @@ import bpy ...@@ -22,7 +22,6 @@ import bpy
from bpy.props import BoolProperty, IntProperty, StringProperty, FloatProperty from bpy.props import BoolProperty, IntProperty, StringProperty, FloatProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.data_structure import updateNode from sverchok.data_structure import updateNode
from sverchok.data_structure import handle_read, handle_write from sverchok.data_structure import handle_read, handle_write
...@@ -164,7 +163,7 @@ class SvNeuroElman: ...@@ -164,7 +163,7 @@ class SvNeuroElman:
prop['wB'] = weights_b prop['wB'] = weights_b
class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode):
''' '''
Triggers: Neuro Elman 1 Layer Triggers: Neuro Elman 1 Layer
Tooltip: Join ETALON data - after animation learning - disconnect ETALON Tooltip: Join ETALON data - after animation learning - disconnect ETALON
...@@ -174,7 +173,7 @@ class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode) ...@@ -174,7 +173,7 @@ class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode)
bl_label = '*Neuro Elman 1 Layer' bl_label = '*Neuro Elman 1 Layer'
bl_icon = 'OUTLINER_OB_EMPTY' bl_icon = 'OUTLINER_OB_EMPTY'
sv_icon = 'SV_NEURO' sv_icon = 'SV_NEURO'
is_animation_dependent = True
elman = None elman = None
k_learning: FloatProperty(name='k_learning', default=0.1, update=updateNode, description="Learning rate") k_learning: FloatProperty(name='k_learning', default=0.1, update=updateNode, description="Learning rate")
...@@ -202,8 +201,7 @@ class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode) ...@@ -202,8 +201,7 @@ class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode)
self.inputs.new('SvStringsSocket', "etalon") self.inputs.new('SvStringsSocket', "etalon")
self.outputs.new('SvStringsSocket', "result") self.outputs.new('SvStringsSocket', "result")
def draw_buttons(self, context, layout): def sv_draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
handle_name = self.name + self.id_data.name handle_name = self.name + self.id_data.name
col_top = layout.column(align=True) col_top = layout.column(align=True)
......
...@@ -9,7 +9,6 @@ import numpy as np ...@@ -9,7 +9,6 @@ import numpy as np
import bpy import bpy
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.data_structure import updateNode from sverchok.data_structure import updateNode
from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need
...@@ -21,7 +20,7 @@ def interp_v3l_v3v3(a, b, t): ...@@ -21,7 +20,7 @@ def interp_v3l_v3v3(a, b, t):
else: return ((1.0 - t) * a) + (t * b) else: return ((1.0 - t) * a) + (t * b)
class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode):
""" """
Triggers: SvSweepModulator Triggers: SvSweepModulator
...@@ -31,6 +30,8 @@ class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): ...@@ -31,6 +30,8 @@ class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
bl_idname = 'SvSweepModulator' bl_idname = 'SvSweepModulator'
bl_label = 'Sweep Modulator' bl_label = 'Sweep Modulator'
bl_icon = 'GP_MULTIFRAME_EDITING' bl_icon = 'GP_MULTIFRAME_EDITING'
is_scene_dependent = True
is_animation_dependent = True
construct_name: bpy.props.StringProperty(name="construct_name", update=updateNode) construct_name: bpy.props.StringProperty(name="construct_name", update=updateNode)
active: bpy.props.BoolProperty(name="active", update=updateNode) active: bpy.props.BoolProperty(name="active", update=updateNode)
...@@ -49,8 +50,7 @@ class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): ...@@ -49,8 +50,7 @@ class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
onew("SvStringsSocket", "Edges") onew("SvStringsSocket", "Edges")
onew("SvStringsSocket", "Faces") onew("SvStringsSocket", "Faces")
def draw_buttons(self, context, layout): def sv_draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
row = layout.row(align=True) row = layout.row(align=True)
row.prop(self, "active", text="ACTIVATE") row.prop(self, "active", text="ACTIVATE")
row = layout.row(align=True) row = layout.row(align=True)
......
...@@ -21,17 +21,17 @@ import socket ...@@ -21,17 +21,17 @@ import socket
import bpy import bpy
from bpy.props import IntProperty, FloatProperty, EnumProperty, StringProperty, BoolProperty from bpy.props import IntProperty, FloatProperty, EnumProperty, StringProperty, BoolProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.utils.profile import profile from sverchok.utils.profile import profile
from sverchok.data_structure import updateNode from sverchok.data_structure import updateNode
class UdpClientNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class UdpClientNode(bpy.types.Node, SverchCustomTreeNode):
bl_idname = 'UdpClientNode' bl_idname = 'UdpClientNode'
bl_label = 'UDP Client' bl_label = 'UDP Client'
sv_icon = 'SV_UDP_CLIENT' sv_icon = 'SV_UDP_CLIENT'
is_scene_dependent = True
is_animation_dependent = True
def send_msg(self, context): def send_msg(self, context):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
...@@ -63,8 +63,7 @@ class UdpClientNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): ...@@ -63,8 +63,7 @@ class UdpClientNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
timeout: FloatProperty(name='timeout', description='Timeout (sec)', default=0.5) timeout: FloatProperty(name='timeout', description='Timeout (sec)', default=0.5)
active: BoolProperty(default=False, name='Active') active: BoolProperty(default=False, name='Active')
def draw_buttons(self, context, layout): def sv_draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
layout.prop(self, 'active', text='Active') layout.prop(self, 'active', text='Active')
layout.prop(self, 'ip', text='IP') layout.prop(self, 'ip', text='IP')
layout.prop(self, 'port', text='Port') layout.prop(self, 'port', text='Port')
......
...@@ -21,7 +21,6 @@ import bpy ...@@ -21,7 +21,6 @@ import bpy
from bpy.props import BoolProperty, FloatProperty, EnumProperty, StringProperty from bpy.props import BoolProperty, FloatProperty, EnumProperty, StringProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.data_structure import updateNode, list_match_func, numpy_list_match_modes, numpy_list_match_func from sverchok.data_structure import updateNode, list_match_func, numpy_list_match_modes, numpy_list_match_func
from sverchok.utils.sv_itertools import recurse_f_level_control from sverchok.utils.sv_itertools import recurse_f_level_control
...@@ -36,7 +35,7 @@ from sverchok.utils.sv_manual_curves_utils import ( ...@@ -36,7 +35,7 @@ from sverchok.utils.sv_manual_curves_utils import (
from sverchok.utils.curve import SvScalarFunctionCurve from sverchok.utils.curve import SvScalarFunctionCurve
import numpy as np
node_group_name = 'sverchok_helper_group' node_group_name = 'sverchok_helper_group'
if (2, 82, 0) > bpy.app.version: if (2, 82, 0) > bpy.app.version:
...@@ -52,7 +51,7 @@ def curve_mapper(params, constant, matching_f): ...@@ -52,7 +51,7 @@ def curve_mapper(params, constant, matching_f):
return result return result
class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode):
""" """
Triggers: Manual Curve remap Triggers: Manual Curve remap
Tooltip: Map input list using a manually defined curve Tooltip: Map input list using a manually defined curve
...@@ -61,6 +60,7 @@ class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): ...@@ -61,6 +60,7 @@ class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
bl_idname = 'SvCurveMapperNode' bl_idname = 'SvCurveMapperNode'
bl_label = 'Curve Mapper' bl_label = 'Curve Mapper'
bl_icon = 'NORMALIZE_FCURVES' bl_icon = 'NORMALIZE_FCURVES'
is_scene_dependent = True
value: FloatProperty( value: FloatProperty(
name='Value', description='New Max', name='Value', description='New Max',
...@@ -75,14 +75,12 @@ class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): ...@@ -75,14 +75,12 @@ class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
self.outputs.new('SvVerticesSocket', "Control Points") self.outputs.new('SvVerticesSocket', "Control Points")
_ = get_evaluator(node_group_name, self._get_curve_node_name()) _ = get_evaluator(node_group_name, self._get_curve_node_name())
def sv_draw_buttons(self, context, layout):
def draw_buttons(self, context, layout):
m = bpy.data.node_groups.get(node_group_name) m = bpy.data.node_groups.get(node_group_name)
if not m: if not m:
layout.label(text="Connect input to activate") layout.label(text="Connect input to activate")
return return
try: try:
self.draw_animatable_buttons(layout, icon_only=True, update_big=True)
tnode = m.nodes[self._get_curve_node_name()] tnode = m.nodes[self._get_curve_node_name()]
if not tnode: if not tnode:
layout.label(text="Connect input to activate") layout.label(text="Connect input to activate")
......
...@@ -18,16 +18,15 @@ ...@@ -18,16 +18,15 @@
import bpy import bpy
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.data_structure import match_long_cycle as mlc, updateNode
class SvArmaturePropsNode(bpy.types.Node, SverchCustomTreeNode):
class SvArmaturePropsNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
'''Armature object props''' '''Armature object props'''
bl_idname = 'SvArmaturePropsNode' bl_idname = 'SvArmaturePropsNode'
bl_label = 'Armature Props' bl_label = 'Armature Props'
bl_icon = 'MOD_ARMATURE' bl_icon = 'MOD_ARMATURE'
is_scene_dependent = True
is_animation_dependent = True
def sv_init(self, context): def sv_init(self, context):
self.inputs.new('SvObjectSocket', 'Armature Object') self.inputs.new('SvObjectSocket', 'Armature Object')
...@@ -39,9 +38,6 @@ class SvArmaturePropsNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode ...@@ -39,9 +38,6 @@ class SvArmaturePropsNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode
self.outputs.new('SvStringsSocket', 'Length of bone') self.outputs.new('SvStringsSocket', 'Length of bone')
self.outputs.new('SvMatrixSocket', "local bone matrix") self.outputs.new('SvMatrixSocket', "local bone matrix")
self.outputs.new('SvObjectSocket', "Armature Object") self.outputs.new('SvObjectSocket', "Armature Object")
def draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
def process(self): def process(self):
armobj, selm = self.inputs armobj, selm = self.inputs
......
...@@ -22,7 +22,6 @@ import bpy ...@@ -22,7 +22,6 @@ import bpy
from bpy.props import StringProperty, IntProperty, CollectionProperty, PointerProperty from bpy.props import StringProperty, IntProperty, CollectionProperty, PointerProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.data_structure import updateNode, match_long_repeat from sverchok.data_structure import updateNode, match_long_repeat
from sverchok.utils.logging import info, debug from sverchok.utils.logging import info, debug
...@@ -120,7 +119,8 @@ class SvMoveMaterial(bpy.types.Operator): ...@@ -120,7 +119,8 @@ class SvMoveMaterial(bpy.types.Operator):
updateNode(node, context) updateNode(node, context)
return {'FINISHED'} return {'FINISHED'}
class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode):
class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode):
""" """
Triggers: material list Triggers: material list
Tooltip: Assign the list of materials to the object Tooltip: Assign the list of materials to the object
...@@ -130,6 +130,14 @@ class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl ...@@ -130,6 +130,14 @@ class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl
bl_label = "Assign Materials List" bl_label = "Assign Materials List"
bl_icon = 'MATERIAL' bl_icon = 'MATERIAL'
@property
def is_scene_dependent(self):
return (not self.inputs['Object'].is_linked) and self.inputs['Object'].object_ref_pointer
@property
def is_animation_dependent(self):
return (not self.inputs['Object'].is_linked) and self.inputs['Object'].object_ref_pointer
materials : CollectionProperty(type=SvMaterialEntry) materials : CollectionProperty(type=SvMaterialEntry)
selected : IntProperty() selected : IntProperty()
...@@ -138,8 +146,7 @@ class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl ...@@ -138,8 +146,7 @@ class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl
self.inputs.new('SvObjectSocket', 'Object') self.inputs.new('SvObjectSocket', 'Object')
self.outputs.new('SvObjectSocket', 'Object') self.outputs.new('SvObjectSocket', 'Object')
def draw_buttons(self, context, layout): def sv_draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
layout.template_list("UI_UL_SvMaterialUiList", "materials", self, "materials", self, "selected") layout.template_list("UI_UL_SvMaterialUiList", "materials", self, "materials", self, "selected")
row = layout.row(align=True) row = layout.row(align=True)
......
...@@ -17,21 +17,21 @@ ...@@ -17,21 +17,21 @@
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
import bpy import bpy
import mathutils
from mathutils import Vector from mathutils import Vector
from bpy.props import FloatProperty, BoolProperty from bpy.props import FloatProperty, BoolProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.data_structure import (updateNode, second_as_first_cycle) from sverchok.data_structure import (updateNode, second_as_first_cycle)
class SvPointOnMeshNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class SvPointOnMeshNodeMK2(bpy.types.Node, SverchCustomTreeNode):
''' Point on Mesh ''' ''' Point on Mesh '''
bl_idname = 'SvPointOnMeshNodeMK2' bl_idname = 'SvPointOnMeshNodeMK2'
bl_label = 'Object ID Point on Mesh MK2' #new is pointless name bl_label = 'Object ID Point on Mesh MK2' #new is pointless name
bl_icon = 'OUTLINER_OB_EMPTY' bl_icon = 'OUTLINER_OB_EMPTY'
sv_icon = 'SV_POINT_ON_MESH' sv_icon = 'SV_POINT_ON_MESH'
is_animation_dependent = True
is_scene_dependent = True
Mdist: FloatProperty(name='Max_Distance', default=10, update=updateNode) Mdist: FloatProperty(name='Max_Distance', default=10, update=updateNode)
mode: BoolProperty(name='for in points', default=False, update=updateNode) mode: BoolProperty(name='for in points', default=False, update=updateNode)
...@@ -48,10 +48,7 @@ class SvPointOnMeshNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNod ...@@ -48,10 +48,7 @@ class SvPointOnMeshNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNod
so('SvVerticesSocket', "Normal_on_mesh") so('SvVerticesSocket', "Normal_on_mesh")
so('SvStringsSocket', "FaceINDEX") so('SvStringsSocket', "FaceINDEX")
def draw_buttons(self, context, layout): def sv_draw_buttons_ext(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
def draw_buttons_ext(self, context, layout):
self.draw_animatable_buttons(layout)
row = layout.row(align=True) row = layout.row(align=True)
row.prop(self, "mode", text="In Mode") row.prop(self, "mode", text="In Mode")
row.prop(self, "mode2", text="Out Mode") row.prop(self, "mode2", text="Out Mode")
......
...@@ -22,23 +22,23 @@ from mathutils.geometry import barycentric_transform ...@@ -22,23 +22,23 @@ from mathutils.geometry import barycentric_transform
import numpy as np import numpy as np
from bpy.props import BoolProperty, StringProperty, FloatVectorProperty from bpy.props import BoolProperty, StringProperty, FloatVectorProperty
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need
from sverchok.data_structure import (updateNode, second_as_first_cycle as safc) from sverchok.data_structure import (updateNode, second_as_first_cycle as safc)
class SvMeshUVColorNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): class SvMeshUVColorNode(bpy.types.Node, SverchCustomTreeNode):
''' Find pixel on UV texture from mesh object and change its color''' ''' Find pixel on UV texture from mesh object and change its color'''
bl_idname = 'SvMeshUVColorNode' bl_idname = 'SvMeshUVColorNode'
bl_label = 'Set UV Color' bl_label = 'Set UV Color'
bl_icon = 'UV_DATA' bl_icon = 'UV_DATA'
is_scene_dependent = True
is_animation_dependent = True
image: StringProperty(default='', update=updateNode) image: StringProperty(default='', update=updateNode)
unit_color: FloatVectorProperty(name='', default=(1.0, 1.0, 1.0, 1.0), unit_color: FloatVectorProperty(name='', default=(1.0, 1.0, 1.0, 1.0),
size=4, min=0.0, max=1.0, subtype='COLOR', update=updateNode) size=4, min=0.0, max=1.0, subtype='COLOR', update=updateNode)
def draw_buttons(self, context, layout): def sv_draw_buttons(self, context, layout):
self.draw_animatable_buttons(layout, icon_only=True)
ob = self.inputs[0].sv_get(default=[[]])[0] ob = self.inputs[0].sv_get(default=[[]])[0]
if ob and ob.type == 'MESH': if ob and ob.type == 'MESH':
layout.prop_search(self, 'image', bpy.data, "images", text="") layout.prop_search(self, 'image', bpy.data, "images", text="")
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать