This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathproperties.py
196 lines (139 loc) · 6.96 KB
/
properties.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import bpy
from bpy.props import StringProperty, IntProperty, BoolProperty, CollectionProperty, PointerProperty, EnumProperty, FloatProperty
import bmesh
from . items import eevee_preset_items, align_mode_items
# COLLECTIONS
class AppendMatsCollection(bpy.types.PropertyGroup):
name: StringProperty()
class HistoryObjectsCollection(bpy.types.PropertyGroup):
name: StringProperty()
obj: PointerProperty(name="History Object", type=bpy.types.Object)
class HistoryUnmirroredCollection(bpy.types.PropertyGroup):
name: StringProperty()
obj: PointerProperty(name="History Unmirror", type=bpy.types.Object)
class HistoryEpochCollection(bpy.types.PropertyGroup):
name: StringProperty()
objects: CollectionProperty(type=HistoryObjectsCollection)
unmirrored: CollectionProperty(type=HistoryUnmirroredCollection)
# SCENE PROPERTIES
selected = []
class M3SceneProperties(bpy.types.PropertyGroup):
def update_xray(self, context):
x = (self.pass_through, self.show_edit_mesh_wire)
shading = context.space_data.shading
shading.show_xray = True if any(x) else False
if self.show_edit_mesh_wire:
shading.xray_alpha = 0.1
elif self.pass_through:
shading.xray_alpha = 1 if context.active_object and context.active_object.type == "MESH" else 0.5
def update_uv_sync_select(self, context):
ts = context.scene.tool_settings
ts.use_uv_select_sync = self.uv_sync_select
global selected
active = context.active_object
# restore previous selection
if ts.use_uv_select_sync:
bpy.ops.mesh.select_all(action='DESELECT')
bm = bmesh.from_edit_mesh(active.data)
bm.normal_update()
bm.verts.ensure_lookup_table()
if selected:
for v in bm.verts:
if v.index in selected:
v.select_set(True)
bm.select_flush(True)
bmesh.update_edit_mesh(active.data)
# also sync the selection mode
# NOTE: disabled again, seems like it's beneficial to just go back to the previous mesh selection mode
# if ts.uv_select_mode in ["VERTEX", "EDGE", "FACE"]:
# bpy.ops.mesh.select_mode(type=ts.uv_select_mode.replace("VERTEX", "VERT"))
# store the active selection
else:
bm = bmesh.from_edit_mesh(active.data)
bm.normal_update()
bm.verts.ensure_lookup_table()
selected = [v.index for v in bm.verts if v.select]
bpy.ops.mesh.select_all(action="SELECT")
# also sync the selection mode
mode = tuple(ts.mesh_select_mode)
# EDGE mode in the mesh becomes, EDGE in uv as well
if mode == (False, True, False):
ts.uv_select_mode = "EDGE"
# everything else becomes VERTEX, including FACE
# that's because there's no reason to turn off sync for face selections in the first place, faces unlike verts and edges, are always only present once in uv space
else:
ts.uv_select_mode = "VERTEX"
def update_show_cavity(self, context):
t = (self.show_cavity, self.show_curvature)
shading = context.space_data.shading
shading.show_cavity = True if any(t) else False
if t == (True, True):
shading.cavity_type = "BOTH"
elif t == (True, False):
shading.cavity_type = "WORLD"
elif t == (False, True):
shading.cavity_type = "SCREEN"
def update_grouppro_dotnames(self, context):
gpcols = [col for col in bpy.data.collections if col.created_with_gp]
for col in gpcols:
# hide collections
if self.grouppro_dotnames:
if not col.name.startswith("."):
col.name = ".%s" % col.name
else:
if col.name.startswith("."):
col.name = col.name[1:]
pass_through: BoolProperty(name="Pass Through", default=False, update=update_xray)
show_edit_mesh_wire: BoolProperty(name="Show Edit Mesh Wireframe", default=False, update=update_xray)
uv_sync_select: BoolProperty(name="Synce Selection", default=False, update=update_uv_sync_select)
show_cavity: BoolProperty(name="Cavity", default=True, update=update_show_cavity)
show_curvature: BoolProperty(name="Curvature", default=False, update=update_show_cavity)
focus_history: CollectionProperty(type=HistoryEpochCollection)
grouppro_dotnames: BoolProperty(name=".dotname GroupPro collections", default=False, update=update_grouppro_dotnames)
def update_eevee_preset(self, context):
eevee = context.scene.eevee
shading = context.space_data.shading
if self.eevee_preset == 'NONE':
eevee.use_ssr = False
eevee.use_gtao = False
eevee.use_bloom = False
eevee.use_volumetric_lights = False
shading.use_scene_lights = False
shading.use_scene_world = False
elif self.eevee_preset == 'LOW':
eevee.use_ssr = True
eevee.use_ssr_halfres = True
eevee.use_ssr_refraction = False
eevee.use_gtao = True
eevee.use_bloom = False
eevee.use_volumetric_lights = False
shading.use_scene_lights = True
shading.use_scene_world = False
elif self.eevee_preset == 'HIGH':
eevee.use_ssr = True
eevee.use_ssr_halfres = False
eevee.use_ssr_refraction = True
eevee.use_gtao = True
eevee.use_bloom = True
eevee.use_volumetric_lights = False
shading.use_scene_lights = True
shading.use_scene_world = False
elif self.eevee_preset == 'ULTRA':
eevee.use_ssr = True
eevee.use_ssr_halfres = False
eevee.use_ssr_refraction = True
eevee.use_gtao = True
eevee.use_bloom = True
eevee.use_volumetric_lights = True
shading.use_scene_lights = True
shading.use_scene_world = True
def update_eevee_gtao_factor(self, context):
context.scene.eevee.gtao_factor = self.eevee_gtao_factor
def update_eevee_bloom_intensity(self, context):
context.scene.eevee.bloom_intensity = self.eevee_bloom_intensity
eevee_preset: EnumProperty(name="Eevee Preset", description="Eevee Quality Presets", items=eevee_preset_items, default='NONE', update=update_eevee_preset)
eevee_gtao_factor: FloatProperty(name="Factor", default=1, min=0, step=0.1, update=update_eevee_gtao_factor)
eevee_bloom_intensity: FloatProperty(name="Intensity", default=0.05, min=0, step=0.1, update=update_eevee_bloom_intensity)
object_axes_size: FloatProperty(name="Object Axes Size", default=0.3, min=0)
object_axes_alpha: FloatProperty(name="Object Axes Alpha", default=0.75, min=0, max=1)
align_mode: EnumProperty(name="Align Mode", items=align_mode_items, default="VIEW")