Merge from trunk -r 24247:24313, -r 24313:24390.
[blender-staging.git] / release / scripts / ui / properties_physics_common.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 def point_cache_ui(self, cache, enabled, particles, smoke):
24     layout = self.layout
25     layout.set_context_pointer("PointCache", cache)
26
27     row = layout.row()
28     row.template_list(cache, "point_cache_list", cache, "active_point_cache_index", rows=2)
29     col = row.column(align=True)
30     col.itemO("ptcache.add_new", icon='ICON_ZOOMIN', text="")
31     col.itemO("ptcache.remove", icon='ICON_ZOOMOUT', text="")
32
33     row = layout.row()
34     row.itemL(text="File Name:")
35     if particles:
36         row.itemR(cache, "external")
37
38     if cache.external:
39         split = layout.split(percentage=0.80)
40         split.itemR(cache, "name", text="")
41         split.itemR(cache, "index", text="")
42
43         layout.itemL(text="File Path:")
44         layout.itemR(cache, "filepath", text="")
45
46         layout.itemL(text=cache.info)
47     else:
48         layout.itemR(cache, "name", text="")
49
50         if not particles:
51             row = layout.row()
52             row.enabled = enabled
53             row.itemR(cache, "start_frame")
54             row.itemR(cache, "end_frame")
55
56         row = layout.row()
57
58         if cache.baked == True:
59             row.itemO("ptcache.free_bake", text="Free Bake")
60         else:
61             row.item_booleanO("ptcache.bake", "bake", True, text="Bake")
62
63         sub = row.row()
64         sub.enabled = (cache.frames_skipped or cache.outdated) and enabled
65         sub.itemO("ptcache.bake", "bake", False, text="Calculate to Current Frame")
66
67         row = layout.row()
68         row.enabled = enabled
69         row.itemO("ptcache.bake_from_cache", text="Current Cache to Bake")
70         if not smoke:
71             row.itemR(cache, "step")
72
73         if not smoke:
74             row = layout.row()
75             sub = row.row()
76             sub.enabled = enabled
77             sub.itemR(cache, "quick_cache")
78             row.itemR(cache, "disk_cache")
79
80         layout.itemL(text=cache.info)
81
82         layout.itemS()
83
84         row = layout.row()
85         row.item_booleanO("ptcache.bake_all", "bake", True, text="Bake All Dynamics")
86         row.itemO("ptcache.free_bake_all", text="Free All Bakes")
87         layout.itemO("ptcache.bake_all", "bake", False, text="Update All Dynamics to current frame")
88
89
90 def effector_weights_ui(self, weights):
91         layout = self.layout
92
93         layout.itemR(weights, "group")
94
95         split = layout.split()
96         split.itemR(weights, "gravity", slider=True)
97         split.itemR(weights, "all", slider=True)
98
99         layout.itemS()
100
101         flow = layout.column_flow()
102         flow.itemR(weights, "force", slider=True)
103         flow.itemR(weights, "vortex", slider=True)
104         flow.itemR(weights, "magnetic", slider=True)
105         flow.itemR(weights, "wind", slider=True)
106         flow.itemR(weights, "curveguide", slider=True)
107         flow.itemR(weights, "texture", slider=True)
108         flow.itemR(weights, "harmonic", slider=True)
109         flow.itemR(weights, "charge", slider=True)
110         flow.itemR(weights, "lennardjones", slider=True)
111         flow.itemR(weights, "turbulence", slider=True)
112         flow.itemR(weights, "drag", slider=True)
113         flow.itemR(weights, "boid", slider=True)
114
115
116 def basic_force_field_settings_ui(self, field):
117     layout = self.layout
118     split = layout.split()
119
120     if not field or field.type == 'NONE':
121         return
122
123     col = split.column()
124
125     if field.type == 'DRAG':
126         col.itemR(field, "linear_drag", text="Linear")
127     else:
128         col.itemR(field, "strength")
129
130     if field.type == 'TURBULENCE':
131         col.itemR(field, "size")
132         col.itemR(field, "flow")
133     elif field.type == 'HARMONIC':
134         col.itemR(field, "harmonic_damping", text="Damping")
135     elif field.type == 'VORTEX' and field.shape != 'POINT':
136         col.itemR(field, "inflow")
137     elif field.type == 'DRAG':
138         col.itemR(field, "quadratic_drag", text="Quadratic")
139     else:
140         col.itemR(field, "flow")
141
142     col = split.column()
143     col.itemR(field, "noise")
144     col.itemR(field, "seed")
145     if field.type == 'TURBULENCE':
146         col.itemR(field, "global_coordinates", text="Global")
147
148     split = layout.split()
149
150     col = split.column()
151     col.itemL(text="Effect point:")
152     col.itemR(field, "do_location")
153     col.itemR(field, "do_rotation")
154
155     sub = split.column()
156     sub.itemL(text="Collision:")
157     sub.itemR(field, "do_absorption")
158
159
160 def basic_force_field_falloff_ui(self, field):
161     layout = self.layout
162     split = layout.split(percentage=0.35)
163
164     if not field or field.type == 'NONE':
165         return
166
167     col = split.column()
168     col.itemR(field, "z_direction", text="")
169     col.itemR(field, "use_min_distance", text="Use Minimum")
170     col.itemR(field, "use_max_distance", text="Use Maximum")
171
172     col = split.column()
173     col.itemR(field, "falloff_power", text="Power")
174
175     sub = col.column()
176     sub.active = field.use_min_distance
177     sub.itemR(field, "minimum_distance", text="Distance")
178
179     sub = col.column()
180     sub.active = field.use_max_distance
181     sub.itemR(field, "maximum_distance", text="Distance")