Merged changes in the trunk up to revision 55546.
[blender.git] / release / scripts / startup / bl_ui / properties_physics_rigidbody_constraint.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 from bpy.types import Panel
22
23
24 class PHYSICS_PT_rigidbody_constraint_panel():
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "physics"
28
29
30 class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Panel):
31     bl_label = "Rigid Body Constraint"
32
33     @classmethod
34     def poll(cls, context):
35         ob = context.object
36         rd = context.scene.render
37         return (ob and ob.rigid_body_constraint and (not rd.use_game_engine))
38
39     def draw(self, context):
40         layout = self.layout
41
42         ob = context.object
43         rbc = ob.rigid_body_constraint
44
45         layout.prop(rbc, "type")
46
47         row = layout.row()
48         row.prop(rbc, "enabled")
49         row.prop(rbc, "disable_collisions")
50
51         layout.prop(rbc, "object1")
52         layout.prop(rbc, "object2")
53
54         if rbc.type != 'MOTOR':
55             row = layout.row()
56             row.prop(rbc, "use_breaking")
57             sub = row.row()
58             sub.active = rbc.use_breaking
59             sub.prop(rbc, "breaking_threshold", text="Threshold")
60
61         row = layout.row()
62         row.prop(rbc, "override_solver_iterations", text="Override Iterations")
63         sub = row.row()
64         sub.active = rbc.override_solver_iterations
65         sub.prop(rbc, "num_solver_iterations", text="Iterations")
66
67         if rbc.type == 'HINGE':
68             col = layout.column(align=True)
69             col.label("Limits:")
70
71             row = col.row()
72             sub = row.row()
73             sub.scale_x = 0.5
74             sub.prop(rbc, "use_limit_ang_z", toggle=True)
75             sub = row.row()
76             sub.active = rbc.use_limit_ang_z
77             sub.prop(rbc, "limit_ang_z_lower", text="Lower")
78             sub.prop(rbc, "limit_ang_z_upper", text="Upper")
79
80         elif rbc.type == 'SLIDER':
81             col = layout.column(align=True)
82             col.label("Limits:")
83
84             row = col.row()
85             sub = row.row()
86             sub.scale_x = 0.5
87             sub.prop(rbc, "use_limit_lin_x", toggle=True)
88             sub = row.row()
89             sub.active = rbc.use_limit_lin_x
90             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
91             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
92
93         elif rbc.type == 'PISTON':
94             col = layout.column(align=True)
95             col.label("Limits:")
96
97             row = col.row()
98             sub = row.row()
99             sub.scale_x = 0.5
100             sub.prop(rbc, "use_limit_lin_x", toggle=True)
101             sub = row.row()
102             sub.active = rbc.use_limit_lin_x
103             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
104             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
105
106             col = layout.column(align=True)
107
108             row = col.row()
109             sub = row.row()
110             sub.scale_x = 0.5
111             sub.prop(rbc, "use_limit_ang_x", toggle=True)
112             sub = row.row()
113             sub.active = rbc.use_limit_ang_x
114             sub.prop(rbc, "limit_ang_x_lower", text="Lower")
115             sub.prop(rbc, "limit_ang_x_upper", text="Upper")
116
117         elif rbc.type == 'MOTOR':
118             col = layout.column(align=True)
119             col.label("Linear motor:")
120
121             row = col.row()
122             sub = row.row()
123             sub.scale_x = 0.5
124             sub.prop(rbc, "use_motor_lin", toggle=True, text="Enable")
125             sub = row.row()
126             sub.active = rbc.use_motor_lin
127             sub.prop(rbc, "motor_lin_target_velocity", text="Target Velocity")
128             sub.prop(rbc, "motor_lin_max_impulse", text="Max Impulse")
129
130             col.label("Angular motor:")
131
132             row = col.row()
133             sub = row.row()
134             sub.scale_x = 0.5
135             sub.prop(rbc, "use_motor_ang", toggle=True, text="Enable")
136             sub = row.row()
137             sub.active = rbc.use_motor_ang
138             sub.prop(rbc, "motor_ang_target_velocity", text="Target Velocity")
139             sub.prop(rbc, "motor_ang_max_impulse", text="Max Impulse")
140
141         elif rbc.type in {'GENERIC', 'GENERIC_SPRING'}:
142             col = layout.column(align=True)
143             col.label("Limits:")
144
145             row = col.row()
146             sub = row.row()
147             sub.scale_x = 0.5
148             sub.prop(rbc, "use_limit_lin_x", toggle=True)
149             sub = row.row()
150             sub.active = rbc.use_limit_lin_x
151             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
152             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
153
154             row = col.row()
155             sub = row.row()
156             sub.scale_x = 0.5
157             sub.prop(rbc, "use_limit_lin_y", toggle=True)
158             sub = row.row()
159             sub.active = rbc.use_limit_lin_y
160             sub.prop(rbc, "limit_lin_y_lower", text="Lower")
161             sub.prop(rbc, "limit_lin_y_upper", text="Upper")
162
163             row = col.row()
164             sub = row.row()
165             sub.scale_x = 0.5
166             sub.prop(rbc, "use_limit_lin_z", toggle=True)
167             sub = row.row()
168             sub.active = rbc.use_limit_lin_z
169             sub.prop(rbc, "limit_lin_z_lower", text="Lower")
170             sub.prop(rbc, "limit_lin_z_upper", text="Upper")
171
172             col = layout.column(align=True)
173
174             row = col.row()
175             sub = row.row()
176             sub.scale_x = 0.5
177             sub.prop(rbc, "use_limit_ang_x", toggle=True)
178             sub = row.row()
179             sub.active = rbc.use_limit_ang_x
180             sub.prop(rbc, "limit_ang_x_lower", text="Lower")
181             sub.prop(rbc, "limit_ang_x_upper", text="Upper")
182
183             row = col.row()
184             sub = row.row()
185             sub.scale_x = 0.5
186             sub.prop(rbc, "use_limit_ang_y", toggle=True)
187             sub = row.row()
188             sub.active = rbc.use_limit_ang_y
189             sub.prop(rbc, "limit_ang_y_lower", text="Lower")
190             sub.prop(rbc, "limit_ang_y_upper", text="Upper")
191
192             row = col.row()
193             sub = row.row()
194             sub.scale_x = 0.5
195             sub.prop(rbc, "use_limit_ang_z", toggle=True)
196             sub = row.row()
197             sub.active = rbc.use_limit_ang_z
198             sub.prop(rbc, "limit_ang_z_lower", text="Lower")
199             sub.prop(rbc, "limit_ang_z_upper", text="Upper")
200
201             if rbc.type == 'GENERIC_SPRING':
202                 col = layout.column(align=True)
203                 col.label("Springs:")
204
205                 row = col.row()
206                 sub = row.row()
207                 sub.scale_x = 0.1
208                 sub.prop(rbc, "use_spring_x", toggle=True, text="X")
209                 sub = row.row()
210                 sub.active = rbc.use_spring_x
211                 sub.prop(rbc, "spring_stiffness_x", text="Stiffness")
212                 sub.prop(rbc, "spring_damping_x")
213
214                 row = col.row()
215                 sub = row.row()
216                 sub.scale_x = 0.1
217                 sub.prop(rbc, "use_spring_y", toggle=True, text="Y")
218                 sub = row.row()
219                 sub.active = rbc.use_spring_y
220                 sub.prop(rbc, "spring_stiffness_y", text="Stiffness")
221                 sub.prop(rbc, "spring_damping_y")
222
223                 row = col.row()
224                 sub = row.row()
225                 sub.scale_x = 0.1
226                 sub.prop(rbc, "use_spring_z", toggle=True, text="Z")
227                 sub = row.row()
228                 sub.active = rbc.use_spring_z
229                 sub.prop(rbc, "spring_stiffness_z", text="Stiffness")
230                 sub.prop(rbc, "spring_damping_z")
231
232 if __name__ == "__main__":  # only for live edit.
233     bpy.utils.register_module(__name__)