Merged changes in the trunk up to revision 54110.
[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         row = layout.row()
55         row.prop(rbc, "use_breaking")
56         sub = row.row()
57         sub.active = rbc.use_breaking
58         sub.prop(rbc, "breaking_threshold", text="Threshold")
59
60         row = layout.row()
61         row.prop(rbc, "override_solver_iterations", text="Override Iterations")
62         sub = row.row()
63         sub.active = rbc.override_solver_iterations
64         sub.prop(rbc, "num_solver_iterations", text="Iterations")
65
66         if rbc.type == 'HINGE':
67             col = layout.column(align=True)
68             col.label("Limits:")
69
70             row = col.row()
71             sub = row.row()
72             sub.scale_x = 0.5
73             sub.prop(rbc, "use_limit_ang_z", toggle=True)
74             sub = row.row()
75             sub.active = rbc.use_limit_ang_z
76             sub.prop(rbc, "limit_ang_z_lower", text="Lower")
77             sub.prop(rbc, "limit_ang_z_upper", text="Upper")
78
79         elif rbc.type == 'SLIDER':
80             col = layout.column(align=True)
81             col.label("Limits:")
82
83             row = col.row()
84             sub = row.row()
85             sub.scale_x = 0.5
86             sub.prop(rbc, "use_limit_lin_x", toggle=True)
87             sub = row.row()
88             sub.active = rbc.use_limit_lin_x
89             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
90             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
91
92         elif rbc.type == 'PISTON':
93             col = layout.column(align=True)
94             col.label("Limits:")
95
96             row = col.row()
97             sub = row.row()
98             sub.scale_x = 0.5
99             sub.prop(rbc, "use_limit_lin_x", toggle=True)
100             sub = row.row()
101             sub.active = rbc.use_limit_lin_x
102             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
103             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
104
105             col = layout.column(align=True)
106
107             row = col.row()
108             sub = row.row()
109             sub.scale_x = 0.5
110             sub.prop(rbc, "use_limit_ang_x", toggle=True)
111             sub = row.row()
112             sub.active = rbc.use_limit_ang_x
113             sub.prop(rbc, "limit_ang_x_lower", text="Lower")
114             sub.prop(rbc, "limit_ang_x_upper", text="Upper")
115
116         elif rbc.type in {'GENERIC', 'GENERIC_SPRING'}:
117             col = layout.column(align=True)
118             col.label("Limits:")
119
120             row = col.row()
121             sub = row.row()
122             sub.scale_x = 0.5
123             sub.prop(rbc, "use_limit_lin_x", toggle=True)
124             sub = row.row()
125             sub.active = rbc.use_limit_lin_x
126             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
127             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
128
129             row = col.row()
130             sub = row.row()
131             sub.scale_x = 0.5
132             sub.prop(rbc, "use_limit_lin_y", toggle=True)
133             sub = row.row()
134             sub.active = rbc.use_limit_lin_y
135             sub.prop(rbc, "limit_lin_y_lower", text="Lower")
136             sub.prop(rbc, "limit_lin_y_upper", text="Upper")
137
138             row = col.row()
139             sub = row.row()
140             sub.scale_x = 0.5
141             sub.prop(rbc, "use_limit_lin_z", toggle=True)
142             sub = row.row()
143             sub.active = rbc.use_limit_lin_z
144             sub.prop(rbc, "limit_lin_z_lower", text="Lower")
145             sub.prop(rbc, "limit_lin_z_upper", text="Upper")
146
147             col = layout.column(align=True)
148
149             row = col.row()
150             sub = row.row()
151             sub.scale_x = 0.5
152             sub.prop(rbc, "use_limit_ang_x", toggle=True)
153             sub = row.row()
154             sub.active = rbc.use_limit_ang_x
155             sub.prop(rbc, "limit_ang_x_lower", text="Lower")
156             sub.prop(rbc, "limit_ang_x_upper", text="Upper")
157
158             row = col.row()
159             sub = row.row()
160             sub.scale_x = 0.5
161             sub.prop(rbc, "use_limit_ang_y", toggle=True)
162             sub = row.row()
163             sub.active = rbc.use_limit_ang_y
164             sub.prop(rbc, "limit_ang_y_lower", text="Lower")
165             sub.prop(rbc, "limit_ang_y_upper", text="Upper")
166
167             row = col.row()
168             sub = row.row()
169             sub.scale_x = 0.5
170             sub.prop(rbc, "use_limit_ang_z", toggle=True)
171             sub = row.row()
172             sub.active = rbc.use_limit_ang_z
173             sub.prop(rbc, "limit_ang_z_lower", text="Lower")
174             sub.prop(rbc, "limit_ang_z_upper", text="Upper")
175
176             if rbc.type == 'GENERIC_SPRING':                  
177                 col = layout.column(align=True)
178                 col.label("Springs:")
179
180                 row = col.row()
181                 sub = row.row()
182                 sub.scale_x = 0.1
183                 sub.prop(rbc, "use_spring_x", toggle=True, text="X")
184                 sub = row.row()
185                 sub.active = rbc.use_spring_x
186                 sub.prop(rbc, "spring_stiffness_x", text="Stiffness")
187                 sub.prop(rbc, "spring_damping_x")
188
189                 row = col.row()
190                 sub = row.row()
191                 sub.scale_x = 0.1
192                 sub.prop(rbc, "use_spring_y", toggle=True, text="Y")
193                 sub = row.row()
194                 sub.active = rbc.use_spring_y
195                 sub.prop(rbc, "spring_stiffness_y", text="Stiffness")
196                 sub.prop(rbc, "spring_damping_y")
197
198                 row = col.row()
199                 sub = row.row()
200                 sub.scale_x = 0.1
201                 sub.prop(rbc, "use_spring_z", toggle=True, text="Z")
202                 sub = row.row()
203                 sub.active = rbc.use_spring_z
204                 sub.prop(rbc, "spring_stiffness_z", text="Stiffness")
205                 sub.prop(rbc, "spring_damping_z")
206
207 if __name__ == "__main__":  # only for live edit.
208     bpy.utils.register_module(__name__)