glTF exporter: Export DEF bones only, without animation, is now possible
[blender-addons.git] / amaranth / utils.py
blobb7301d43845bfb134f66c5afd78e078181951916
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 import bpy
6 # FUNCTION: Checks if cycles is available
7 def cycles_exists():
8 return hasattr(bpy.types.Scene, "cycles")
11 # FUNCTION: Checks if cycles is the active renderer
12 def cycles_active(context):
13 return context.scene.render.engine == "CYCLES"
16 # FUNCTION: Check if material has Emission (for select and stats)
17 def cycles_is_emission(context, ob):
18 is_emission = False
20 if not ob.material_slots:
21 return is_emission
23 for ma in ob.material_slots:
24 if not ma.material:
25 continue
26 if ma.material.node_tree and ma.material.node_tree.nodes:
27 for no in ma.material.node_tree.nodes:
28 if not no.type in ("EMISSION", "GROUP"):
29 continue
30 for ou in no.outputs:
31 if not ou.links:
32 continue
33 if no.type == "GROUP" and no.node_tree and no.node_tree.nodes:
34 for gno in no.node_tree.nodes:
35 if gno.type != "EMISSION":
36 continue
37 for gou in gno.outputs:
38 if ou.links and gou.links:
39 is_emission = True
40 elif no.type == "EMISSION":
41 if ou.links:
42 is_emission = True
43 return is_emission
46 # FUNCTION: Check if object has keyframes for a specific frame
47 def is_keyframe(ob, frame):
48 if ob is not None and ob.animation_data is not None and ob.animation_data.action is not None:
49 for fcu in ob.animation_data.action.fcurves:
50 if frame in (p.co.x for p in fcu.keyframe_points):
51 return True
52 return False