1 # This program is free software; you can redistribute it and/or
2 # modify it under the terms of the GNU General Public License
3 # as published by the Free Software Foundation; either version 2
4 # of the License, or (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software Foundation,
13 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # FUNCTION: Checks if cycles is available
20 return hasattr(bpy
.types
.Scene
, "cycles")
23 # FUNCTION: Checks if cycles is the active renderer
24 def cycles_active(context
):
25 return context
.scene
.render
.engine
== "CYCLES"
28 # FUNCTION: Check if material has Emission (for select and stats)
29 def cycles_is_emission(context
, ob
):
32 if not ob
.material_slots
:
35 for ma
in ob
.material_slots
:
38 if ma
.material
.node_tree
and ma
.material
.node_tree
.nodes
:
39 for no
in ma
.material
.node_tree
.nodes
:
40 if not no
.type in ("EMISSION", "GROUP"):
45 if no
.type == "GROUP" and no
.node_tree
and no
.node_tree
.nodes
:
46 for gno
in no
.node_tree
.nodes
:
47 if gno
.type != "EMISSION":
49 for gou
in gno
.outputs
:
50 if ou
.links
and gou
.links
:
52 elif no
.type == "EMISSION":
58 # FUNCTION: Check if object has keyframes for a specific frame
59 def is_keyframe(ob
, frame
):
60 if ob
is not None and ob
.animation_data
is not None and ob
.animation_data
.action
is not None:
61 for fcu
in ob
.animation_data
.action
.fcurves
:
62 if frame
in (p
.co
.x
for p
in fcu
.keyframe_points
):