rna data path names which are more likely to break animations.
[blender-staging.git] / release / scripts / ui / properties_physics_field.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 from properties_physics_common import basic_force_field_settings_ui
24 from properties_physics_common import basic_force_field_falloff_ui
25
26
27 class PhysicButtonsPanel():
28     bl_space_type = 'PROPERTIES'
29     bl_region_type = 'WINDOW'
30     bl_context = "physics"
31
32     @classmethod
33     def poll(cls, context):
34         rd = context.scene.render
35         return (context.object) and (not rd.use_game_engine)
36
37
38 class PHYSICS_PT_field(PhysicButtonsPanel, bpy.types.Panel):
39     bl_label = "Force Fields"
40
41     def draw(self, context):
42         layout = self.layout
43
44         ob = context.object
45         field = ob.field
46
47         split = layout.split(percentage=0.2)
48         split.label(text="Type:")
49
50         split.prop(field, "type", text="")
51
52         if field.type not in ('NONE', 'GUIDE', 'TEXTURE'):
53             split = layout.split(percentage=0.2)
54             split.label(text="Shape:")
55             split.prop(field, "shape", text="")
56
57         split = layout.split()
58
59         if field.type == 'NONE':
60             return # nothing to draw
61         elif field.type == 'GUIDE':
62             col = split.column()
63             col.prop(field, "guide_minimum")
64             col.prop(field, "guide_free")
65             col.prop(field, "falloff_power")
66             col.prop(field, "use_guide_path_add")
67             col.prop(field, "use_guide_path_weight")
68
69             col = split.column()
70             col.label(text="Clumping:")
71             col.prop(field, "guide_clump_amount")
72             col.prop(field, "guide_clump_shape")
73
74             row = layout.row()
75             row.prop(field, "use_max_distance")
76             sub = row.row()
77             sub.active = field.use_max_distance
78             sub.prop(field, "distance_max")
79
80             layout.separator()
81
82             layout.prop(field, "guide_kink_type")
83             if (field.guide_kink_type != 'NONE'):
84                 layout.prop(field, "guide_kink_axis")
85
86                 split = layout.split()
87
88                 col = split.column()
89                 col.prop(field, "guide_kink_frequency")
90                 col.prop(field, "guide_kink_shape")
91
92                 col = split.column()
93                 col.prop(field, "guide_kink_amplitude")
94
95         elif field.type == 'TEXTURE':
96             col = split.column()
97             col.prop(field, "strength")
98             col.prop(field, "texture", text="")
99             col.prop(field, "texture_mode", text="")
100             col.prop(field, "texture_nabla")
101
102             col = split.column()
103             col.prop(field, "use_object_coords")
104             col.prop(field, "use_root_coords")
105             col.prop(field, "use_2d_force")
106         else:
107             basic_force_field_settings_ui(self, context, field)
108
109         if field.type not in ('NONE', 'GUIDE'):
110
111             layout.label(text="Falloff:")
112             layout.prop(field, "falloff_type", expand=True)
113
114             basic_force_field_falloff_ui(self, context, field)
115
116             if field.falloff_type == 'CONE':
117                 layout.separator()
118
119                 split = layout.split(percentage=0.35)
120
121                 col = split.column()
122                 col.label(text="Angular:")
123                 col.prop(field, "use_radial_min", text="Use Minimum")
124                 col.prop(field, "use_radial_max", text="Use Maximum")
125
126                 col = split.column()
127                 col.prop(field, "radial_falloff", text="Power")
128
129                 sub = col.column()
130                 sub.active = field.use_radial_min
131                 sub.prop(field, "radial_min", text="Angle")
132
133                 sub = col.column()
134                 sub.active = field.use_radial_max
135                 sub.prop(field, "radial_max", text="Angle")
136
137             elif field.falloff_type == 'TUBE':
138                 layout.separator()
139
140                 split = layout.split(percentage=0.35)
141
142                 col = split.column()
143                 col.label(text="Radial:")
144                 col.prop(field, "use_radial_min", text="Use Minimum")
145                 col.prop(field, "use_radial_max", text="Use Maximum")
146
147                 col = split.column()
148                 col.prop(field, "radial_falloff", text="Power")
149
150                 sub = col.column()
151                 sub.active = field.use_radial_min
152                 sub.prop(field, "radial_min", text="Distance")
153
154                 sub = col.column()
155                 sub.active = field.use_radial_max
156                 sub.prop(field, "radial_max", text="Distance")
157
158
159 class PHYSICS_PT_collision(PhysicButtonsPanel, bpy.types.Panel):
160     bl_label = "Collision"
161     #bl_default_closed = True
162
163     @classmethod
164     def poll(cls, context):
165         ob = context.object
166         rd = context.scene.render
167         return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
168
169     def draw(self, context):
170         layout = self.layout
171
172         md = context.collision
173
174         split = layout.split()
175
176         if md:
177             # remove modifier + settings
178             split.set_context_pointer("modifier", md)
179             split.operator("object.modifier_remove", text="Remove")
180             col = split.column()
181
182             #row = split.row(align=True)
183             #row.prop(md, "show_render", text="")
184             #row.prop(md, "show_viewport", text="")
185
186             coll = md.settings
187
188         else:
189             # add modifier
190             split.operator("object.modifier_add", text="Add").type = 'COLLISION'
191             split.label()
192
193             coll = None
194
195         if coll:
196             settings = context.object.collision
197
198             layout.active = settings.use
199
200             split = layout.split()
201
202             col = split.column()
203             col.label(text="Particle:")
204             col.prop(settings, "permeability", slider=True)
205             col.prop(settings, "stickness")
206             col.prop(settings, "use_particle_kill")
207             col.label(text="Particle Damping:")
208             sub = col.column(align=True)
209             sub.prop(settings, "damping_factor", text="Factor", slider=True)
210             sub.prop(settings, "damping_random", text="Random", slider=True)
211
212             col.label(text="Particle Friction:")
213             sub = col.column(align=True)
214             sub.prop(settings, "friction_factor", text="Factor", slider=True)
215             sub.prop(settings, "friction_random", text="Random", slider=True)
216
217             col = split.column()
218             col.label(text="Soft Body and Cloth:")
219             sub = col.column(align=True)
220             sub.prop(settings, "thickness_outer", text="Outer", slider=True)
221             sub.prop(settings, "thickness_inner", text="Inner", slider=True)
222
223             col.label(text="Soft Body Damping:")
224             col.prop(settings, "damping", text="Factor", slider=True)
225
226             col.label(text="Force Fields:")
227             col.prop(settings, "absorption", text="Absorption")
228
229
230 def register():
231     pass
232
233
234 def unregister():
235     pass
236
237 if __name__ == "__main__":
238     register()