-
Notifications
You must be signed in to change notification settings - Fork 0
/
props.py
43 lines (32 loc) · 1.25 KB
/
props.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import bpy
from bpy.app.handlers import persistent
def update_lightlinking_state(self, context):
if not context.scene.force_light_linking_state: return
coll = self.light_linking.receiver_collection
for obj in coll.collection_objects:
obj.light_linking.link_state = self.light_linking_state
@persistent
def handle_all_lights(null):
for obj in bpy.context.scene.objects:
if obj.light_linking.receiver_collection:
update_lightlinking_state(obj, bpy.context)
def register():
# noinspection PyTypeChecker
bpy.types.Object.light_linking_state = bpy.props.EnumProperty(
items=[
("EXCLUDE", "Exclude", ""),
("INCLUDE", "Include", "")
],
update=update_lightlinking_state,
default="EXCLUDE"
)
bpy.types.Scene.force_light_linking_state = bpy.props.BoolProperty(
name='Update',
default=False)
bpy.types.Object.show_light_linking_collection = bpy.props.BoolProperty(
default=True)
bpy.app.handlers.depsgraph_update_pre.append(handle_all_lights)
def unregister():
del bpy.types.Object.light_linking_state
del bpy.types.Object.show_light_linking_collection
bpy.app.handlers.depsgraph_update_pre.remove(handle_all_lights)