GPL2 header from firebird (without disclaimer), notice theres no copyright attributed...
[blender-staging.git] / release / scripts / ui / properties_physics_common.py
1 # This software is distributable under the terms of the GNU
2 # General Public License (GPL) v2, the text of which can be found at
3 # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise
4 # using this module constitutes acceptance of the terms of this License.
5
6 import bpy
7
8 def point_cache_ui(self, cache, enabled, particles, smoke):
9     layout = self.layout
10     layout.set_context_pointer("PointCache", cache)
11
12     row = layout.row()
13     row.template_list(cache, "point_cache_list", cache, "active_point_cache_index", rows=2 )
14     col = row.column(align=True)
15     col.itemO("ptcache.add_new", icon='ICON_ZOOMIN', text="")
16     col.itemO("ptcache.remove", icon='ICON_ZOOMOUT', text="")
17
18     row = layout.row()
19     row.itemL(text="File Name:")
20     if particles:
21         row.itemR(cache, "external")
22
23     if cache.external:
24         split = layout.split(percentage=0.80)
25         split.itemR(cache, "name", text="")
26         split.itemR(cache, "index", text="")
27
28         layout.itemL(text="File Path:")
29         layout.itemR(cache, "filepath", text="")
30
31         layout.itemL(text=cache.info)
32     else:
33         layout.itemR(cache, "name", text="")
34
35         if not particles:
36             row = layout.row()
37             row.enabled = enabled
38             row.itemR(cache, "start_frame")
39             row.itemR(cache, "end_frame")
40
41         row = layout.row()
42
43         if cache.baked == True:
44             row.itemO("ptcache.free_bake", text="Free Bake")
45         else:
46             row.item_booleanO("ptcache.bake", "bake", True, text="Bake")
47
48         sub = row.row()
49         sub.enabled = (cache.frames_skipped or cache.outdated) and enabled
50         sub.itemO("ptcache.bake", "bake", False, text="Calculate to Current Frame")
51
52         row = layout.row()
53         row.enabled = enabled
54         row.itemO("ptcache.bake_from_cache", text="Current Cache to Bake")
55         if not smoke:
56             row.itemR(cache, "step");
57
58         if not smoke:
59             row = layout.row()
60             sub = row.row()
61             sub.enabled = enabled
62             sub.itemR(cache, "quick_cache")
63             row.itemR(cache, "disk_cache")
64
65         layout.itemL(text=cache.info)
66
67         layout.itemS()
68
69         row = layout.row()
70         row.item_booleanO("ptcache.bake_all", "bake", True, text="Bake All Dynamics")
71         row.itemO("ptcache.free_bake_all", text="Free All Bakes")
72         layout.itemO("ptcache.bake_all", "bake", False, text="Update All Dynamics to current frame")
73
74 def effector_weights_ui(self, weights):
75         layout = self.layout
76
77         layout.itemR(weights, "group")
78
79         split = layout.split()
80         split.itemR(weights, "gravity", slider=True)
81         split.itemR(weights, "all", slider=True)
82
83         layout.itemS()
84
85         flow = layout.column_flow()
86         flow.itemR(weights, "force", slider=True)
87         flow.itemR(weights, "vortex", slider=True)
88         flow.itemR(weights, "magnetic", slider=True)
89         flow.itemR(weights, "wind", slider=True)
90         flow.itemR(weights, "curveguide", slider=True)
91         flow.itemR(weights, "texture", slider=True)
92         flow.itemR(weights, "harmonic", slider=True)
93         flow.itemR(weights, "charge", slider=True)
94         flow.itemR(weights, "lennardjones", slider=True)
95         flow.itemR(weights, "turbulence", slider=True)
96         flow.itemR(weights, "drag", slider=True)
97         flow.itemR(weights, "boid", slider=True)
98
99 def basic_force_field_settings_ui(self, field):
100     layout = self.layout
101     split = layout.split()
102
103     if not field or field.type == 'NONE':
104         return
105
106     col = split.column()
107
108     if field.type == 'DRAG':
109         col.itemR(field, "linear_drag", text="Linear")
110     else:
111         col.itemR(field, "strength")
112
113     if field.type == 'TURBULENCE':
114         col.itemR(field, "size")
115         col.itemR(field, "flow")
116     elif field.type == 'HARMONIC':
117         col.itemR(field, "harmonic_damping", text="Damping")
118     elif field.type == 'VORTEX' and field.shape != 'POINT':
119         col.itemR(field, "inflow")
120     elif field.type == 'DRAG':
121         col.itemR(field, "quadratic_drag", text="Quadratic")
122     else:
123         col.itemR(field, "flow")
124
125     col = split.column()
126     col.itemR(field, "noise")
127     col.itemR(field, "seed")
128     if field.type == 'TURBULENCE':
129         col.itemR(field, "global_coordinates", text="Global")
130
131     split = layout.split()
132
133     col = split.column()
134     col.itemL(text="Effect point:")
135     col.itemR(field, "do_location")
136     col.itemR(field, "do_rotation")
137
138     sub = split.column()
139     sub.itemL(text="Collision:")
140     sub.itemR(field, "do_absorption")
141
142
143 def basic_force_field_falloff_ui(self, field):
144     layout = self.layout
145     split = layout.split(percentage=0.35)
146
147     if not field or field.type == 'NONE':
148         return
149
150     col = split.column()
151     col.itemR(field, "z_direction", text="")
152     col.itemR(field, "use_min_distance", text="Use Minimum")
153     col.itemR(field, "use_max_distance", text="Use Maximum")
154
155     col = split.column()
156     col.itemR(field, "falloff_power", text="Power")
157
158     sub = col.column()
159     sub.active = field.use_min_distance
160     sub.itemR(field, "minimum_distance", text="Distance")
161
162     sub = col.column()
163     sub.active = field.use_max_distance
164     sub.itemR(field, "maximum_distance", text="Distance")