Workspace: Move engines to workspace and Properties Editor cleanup
[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     COMPAT_ENGINES = {'BLENDER_RENDER'}
33
34     @classmethod
35     def poll(cls, context):
36         ob = context.object
37         view_render = context.scene.view_render
38         return (ob and ob.rigid_body_constraint and view_render.engine in cls.COMPAT_ENGINES)
39
40     def draw(self, context):
41         layout = self.layout
42
43         ob = context.object
44         rbc = ob.rigid_body_constraint
45
46         layout.prop(rbc, "type")
47
48         row = layout.row()
49         row.prop(rbc, "enabled")
50         row.prop(rbc, "disable_collisions")
51
52         layout.prop(rbc, "object1")
53         layout.prop(rbc, "object2")
54
55         if rbc.type != 'MOTOR':
56             row = layout.row()
57             row.prop(rbc, "use_breaking")
58             sub = row.row()
59             sub.active = rbc.use_breaking
60             sub.prop(rbc, "breaking_threshold", text="Threshold")
61
62         row = layout.row()
63         row.prop(rbc, "use_override_solver_iterations", text="Override Iterations")
64         sub = row.row()
65         sub.active = rbc.use_override_solver_iterations
66         sub.prop(rbc, "solver_iterations", text="Iterations")
67
68         if rbc.type == 'HINGE':
69             col = layout.column(align=True)
70             col.label("Limits:")
71
72             row = col.row(align=True)
73             sub = row.row(align=True)
74             sub.scale_x = 0.5
75             sub.prop(rbc, "use_limit_ang_z", toggle=True)
76             sub = row.row(align=True)
77             sub.active = rbc.use_limit_ang_z
78             sub.prop(rbc, "limit_ang_z_lower", text="Lower")
79             sub.prop(rbc, "limit_ang_z_upper", text="Upper")
80
81         elif rbc.type == 'SLIDER':
82             col = layout.column(align=True)
83             col.label("Limits:")
84
85             row = col.row(align=True)
86             sub = row.row(align=True)
87             sub.scale_x = 0.5
88             sub.prop(rbc, "use_limit_lin_x", toggle=True)
89             sub = row.row(align=True)
90             sub.active = rbc.use_limit_lin_x
91             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
92             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
93
94         elif rbc.type == 'PISTON':
95             col = layout.column(align=True)
96             col.label("Limits:")
97
98             row = col.row(align=True)
99             sub = row.row(align=True)
100             sub.scale_x = 0.5
101             sub.prop(rbc, "use_limit_lin_x", toggle=True)
102             sub = row.row(align=True)
103             sub.active = rbc.use_limit_lin_x
104             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
105             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
106
107             col = layout.column(align=True)
108
109             row = col.row(align=True)
110             sub = row.row(align=True)
111             sub.scale_x = 0.5
112             sub.prop(rbc, "use_limit_ang_x", toggle=True)
113             sub = row.row(align=True)
114             sub.active = rbc.use_limit_ang_x
115             sub.prop(rbc, "limit_ang_x_lower", text="Lower")
116             sub.prop(rbc, "limit_ang_x_upper", text="Upper")
117
118         elif rbc.type == 'MOTOR':
119             col = layout.column(align=True)
120             col.label("Linear motor:")
121
122             row = col.row(align=True)
123             sub = row.row(align=True)
124             sub.scale_x = 0.5
125             sub.prop(rbc, "use_motor_lin", toggle=True, text="Enable")
126             sub = row.row(align=True)
127             sub.active = rbc.use_motor_lin
128             sub.prop(rbc, "motor_lin_target_velocity", text="Target Velocity")
129             sub.prop(rbc, "motor_lin_max_impulse", text="Max Impulse")
130
131             col.label("Angular motor:")
132
133             row = col.row(align=True)
134             sub = row.row(align=True)
135             sub.scale_x = 0.5
136             sub.prop(rbc, "use_motor_ang", toggle=True, text="Enable")
137             sub = row.row(align=True)
138             sub.active = rbc.use_motor_ang
139             sub.prop(rbc, "motor_ang_target_velocity", text="Target Velocity")
140             sub.prop(rbc, "motor_ang_max_impulse", text="Max Impulse")
141
142         elif rbc.type in {'GENERIC', 'GENERIC_SPRING'}:
143             col = layout.column(align=True)
144             col.label("Limits:")
145
146             row = col.row(align=True)
147             sub = row.row(align=True)
148             sub.scale_x = 0.5
149             sub.prop(rbc, "use_limit_lin_x", toggle=True)
150             sub = row.row(align=True)
151             sub.active = rbc.use_limit_lin_x
152             sub.prop(rbc, "limit_lin_x_lower", text="Lower")
153             sub.prop(rbc, "limit_lin_x_upper", text="Upper")
154
155             row = col.row(align=True)
156             sub = row.row(align=True)
157             sub.scale_x = 0.5
158             sub.prop(rbc, "use_limit_lin_y", toggle=True)
159             sub = row.row(align=True)
160             sub.active = rbc.use_limit_lin_y
161             sub.prop(rbc, "limit_lin_y_lower", text="Lower")
162             sub.prop(rbc, "limit_lin_y_upper", text="Upper")
163
164             row = col.row(align=True)
165             sub = row.row(align=True)
166             sub.scale_x = 0.5
167             sub.prop(rbc, "use_limit_lin_z", toggle=True)
168             sub = row.row(align=True)
169             sub.active = rbc.use_limit_lin_z
170             sub.prop(rbc, "limit_lin_z_lower", text="Lower")
171             sub.prop(rbc, "limit_lin_z_upper", text="Upper")
172
173             col = layout.column(align=True)
174
175             row = col.row(align=True)
176             sub = row.row(align=True)
177             sub.scale_x = 0.5
178             sub.prop(rbc, "use_limit_ang_x", toggle=True)
179             sub = row.row(align=True)
180             sub.active = rbc.use_limit_ang_x
181             sub.prop(rbc, "limit_ang_x_lower", text="Lower")
182             sub.prop(rbc, "limit_ang_x_upper", text="Upper")
183
184             row = col.row(align=True)
185             sub = row.row(align=True)
186             sub.scale_x = 0.5
187             sub.prop(rbc, "use_limit_ang_y", toggle=True)
188             sub = row.row(align=True)
189             sub.active = rbc.use_limit_ang_y
190             sub.prop(rbc, "limit_ang_y_lower", text="Lower")
191             sub.prop(rbc, "limit_ang_y_upper", text="Upper")
192
193             row = col.row(align=True)
194             sub = row.row(align=True)
195             sub.scale_x = 0.5
196             sub.prop(rbc, "use_limit_ang_z", toggle=True)
197             sub = row.row(align=True)
198             sub.active = rbc.use_limit_ang_z
199             sub.prop(rbc, "limit_ang_z_lower", text="Lower")
200             sub.prop(rbc, "limit_ang_z_upper", text="Upper")
201
202             if rbc.type == 'GENERIC_SPRING':
203                 col = layout.column(align=True)
204                 col.label("Springs:")
205
206                 row = col.row(align=True)
207                 sub = row.row(align=True)
208                 sub.scale_x = 0.5
209                 sub.prop(rbc, "use_spring_x", toggle=True, text="X Axis")
210                 sub = row.row(align=True)
211                 sub.active = rbc.use_spring_x
212                 sub.prop(rbc, "spring_stiffness_x", text="Stiffness")
213                 sub.prop(rbc, "spring_damping_x", text="Damping")
214
215                 row = col.row(align=True)
216                 sub = row.row(align=True)
217                 sub.scale_x = 0.5
218                 sub.prop(rbc, "use_spring_y", toggle=True, text="Y Axis")
219                 sub = row.row(align=True)
220                 sub.active = rbc.use_spring_y
221                 sub.prop(rbc, "spring_stiffness_y", text="Stiffness")
222                 sub.prop(rbc, "spring_damping_y", text="Damping")
223
224                 row = col.row(align=True)
225                 sub = row.row(align=True)
226                 sub.scale_x = 0.5
227                 sub.prop(rbc, "use_spring_z", toggle=True, text="Z Axis")
228                 sub = row.row(align=True)
229                 sub.active = rbc.use_spring_z
230                 sub.prop(rbc, "spring_stiffness_z", text="Stiffness")
231                 sub.prop(rbc, "spring_damping_z", text="Damping")
232
233                 col = layout.column(align=True)
234
235                 row = col.row(align=True)
236                 sub = row.row(align=True)
237                 sub.scale_x = 0.5
238                 sub.prop(rbc, "use_spring_ang_x", toggle=True, text="X Angle")
239                 sub = row.row(align=True)
240                 sub.active = rbc.use_spring_ang_x
241                 sub.prop(rbc, "spring_stiffness_ang_x", text="Stiffness")
242                 sub.prop(rbc, "spring_damping_ang_x", text="Damping")
243
244                 row = col.row(align=True)
245                 sub = row.row(align=True)
246                 sub.scale_x = 0.5
247                 sub.prop(rbc, "use_spring_ang_y", toggle=True, text="Y Angle")
248                 sub = row.row(align=True)
249                 sub.active = rbc.use_spring_ang_y
250                 sub.prop(rbc, "spring_stiffness_ang_y", text="Stiffness")
251                 sub.prop(rbc, "spring_damping_ang_y", text="Damping")
252
253                 row = col.row(align=True)
254                 sub = row.row(align=True)
255                 sub.scale_x = 0.5
256                 sub.prop(rbc, "use_spring_ang_z", toggle=True, text="Z Angle")
257                 sub = row.row(align=True)
258                 sub.active = rbc.use_spring_ang_z
259                 sub.prop(rbc, "spring_stiffness_ang_z", text="Stiffness")
260                 sub.prop(rbc, "spring_damping_ang_z", text="Damping")
261
262
263 classes = (
264     PHYSICS_PT_rigid_body_constraint,
265 )
266
267 if __name__ == "__main__":  # only for live edit.
268     from bpy.utils import register_class
269     for cls in classes:
270         register_class(cls)