123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- # ##### BEGIN GPL LICENSE BLOCK #####
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License
- # as published by the Free Software Foundation; either version 2
- # of the License, or (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software Foundation,
- # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- #
- # ##### END GPL LICENSE BLOCK #####
- # <pep8 compliant>
- from bpy.types import (
- Panel,
- )
- class PHYSICS_PT_rigidbody_constraint_panel:
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "physics"
- class PHYSICS_PT_rigid_body_constraint(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Rigid Body Constraint"
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- return (ob and ob.rigid_body_constraint and context.engine in cls.COMPAT_ENGINES)
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- ob = context.object
- rbc = ob.rigid_body_constraint
- layout.prop(rbc, "type")
- class PHYSICS_PT_rigid_body_constraint_settings(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Settings"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- return (ob and ob.rigid_body_constraint and context.engine in cls.COMPAT_ENGINES)
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- ob = context.object
- rbc = ob.rigid_body_constraint
- col = flow.column()
- col.prop(rbc, "enabled")
- col.prop(rbc, "disable_collisions")
- if rbc.type != 'MOTOR':
- col = flow.column()
- col.prop(rbc, "use_breaking")
- sub = col.column()
- sub.active = rbc.use_breaking
- sub.prop(rbc, "breaking_threshold", text="Threshold")
- class PHYSICS_PT_rigid_body_constraint_objects(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Objects"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- return (ob and ob.rigid_body_constraint and context.engine in cls.COMPAT_ENGINES)
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- ob = context.object
- rbc = ob.rigid_body_constraint
- layout.prop(rbc, "object1", text="First")
- layout.prop(rbc, "object2", text="Second")
- class PHYSICS_PT_rigid_body_constraint_override_iterations(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Override Iterations"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- return (ob and ob.rigid_body_constraint and context.engine in cls.COMPAT_ENGINES)
- def draw_header(self, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- self.layout.row().prop(rbc, "use_override_solver_iterations", text="")
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- ob = context.object
- rbc = ob.rigid_body_constraint
- layout.active = rbc.use_override_solver_iterations
- layout.prop(rbc, "solver_iterations", text="Iterations")
- class PHYSICS_PT_rigid_body_constraint_limits(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Limits"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and rbc and (rbc.type in {'GENERIC', 'GENERIC_SPRING', 'HINGE', 'SLIDER', 'PISTON'})
- and context.engine in cls.COMPAT_ENGINES)
- def draw(self, _context):
- return # do nothing.
- class PHYSICS_PT_rigid_body_constraint_limits_linear(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Linear"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_limits'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and rbc
- and (rbc.type in {'GENERIC', 'GENERIC_SPRING', 'SLIDER', 'PISTON'})
- and context.engine in cls.COMPAT_ENGINES)
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- ob = context.object
- rbc = ob.rigid_body_constraint
- if rbc.type in {'PISTON', 'SLIDER'}:
- col = flow.column()
- col.prop(rbc, "use_limit_lin_x")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_lin_x
- sub.prop(rbc, "limit_lin_x_lower", text="X Lower")
- sub.prop(rbc, "limit_lin_x_upper", text="Upper")
- elif rbc.type in {'GENERIC', 'GENERIC_SPRING'}:
- col = flow.column()
- col.prop(rbc, "use_limit_lin_x")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_lin_x
- sub.prop(rbc, "limit_lin_x_lower", text="X Lower")
- sub.prop(rbc, "limit_lin_x_upper", text="Upper")
- col = flow.column()
- col.prop(rbc, "use_limit_lin_y")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_lin_y
- sub.prop(rbc, "limit_lin_y_lower", text="Y Lower")
- sub.prop(rbc, "limit_lin_y_upper", text="Upper")
- col = flow.column()
- col.prop(rbc, "use_limit_lin_z")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_lin_z
- sub.prop(rbc, "limit_lin_z_lower", text="Z Lower")
- sub.prop(rbc, "limit_lin_z_upper", text="Upper")
- class PHYSICS_PT_rigid_body_constraint_limits_angular(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Angular"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_limits'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and rbc
- and (rbc.type in {'GENERIC', 'GENERIC_SPRING', 'HINGE', 'PISTON'})
- and context.engine in cls.COMPAT_ENGINES)
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- ob = context.object
- rbc = ob.rigid_body_constraint
- if rbc.type == 'HINGE':
- col = flow.column()
- col.prop(rbc, "use_limit_ang_z")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_ang_z
- sub.prop(rbc, "limit_ang_z_lower", text="Z Lower")
- sub.prop(rbc, "limit_ang_z_upper", text="Upper")
- elif rbc.type == 'PISTON':
- col = flow.column()
- col.prop(rbc, "use_limit_ang_x")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_ang_x
- sub.prop(rbc, "limit_ang_x_lower", text="X Lower")
- sub.prop(rbc, "limit_ang_x_upper", text="Upper")
- elif rbc.type in {'GENERIC', 'GENERIC_SPRING'}:
- col = flow.column()
- col.prop(rbc, "use_limit_ang_x")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_ang_x
- sub.prop(rbc, "limit_ang_x_lower", text="X Lower")
- sub.prop(rbc, "limit_ang_x_upper", text="Upper")
- col = flow.column()
- col.prop(rbc, "use_limit_ang_y")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_ang_y
- sub.prop(rbc, "limit_ang_y_lower", text="Y Lower")
- sub.prop(rbc, "limit_ang_y_upper", text="Upper")
- col = flow.column()
- col.prop(rbc, "use_limit_ang_z")
- sub = col.column(align=True)
- sub.active = rbc.use_limit_ang_z
- sub.prop(rbc, "limit_ang_z_lower", text="Z Lower")
- sub.prop(rbc, "limit_ang_z_upper", text="Upper")
- class PHYSICS_PT_rigid_body_constraint_motor(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Motor"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and rbc and rbc.type == 'MOTOR'
- and context.engine in cls.COMPAT_ENGINES)
- def draw(self, _context):
- return # do nothing.
- class PHYSICS_PT_rigid_body_constraint_motor_angular(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Angular"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_motor'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and rbc and rbc.type == 'MOTOR'
- and context.engine in cls.COMPAT_ENGINES)
- def draw_header(self, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- self.layout.row().prop(rbc, "use_motor_ang", text="")
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- ob = context.object
- rbc = ob.rigid_body_constraint
- flow.active = rbc.use_motor_ang
- col = flow.column(align=True)
- col.prop(rbc, "motor_ang_target_velocity", text="Target Velocity")
- col = flow.column(align=True)
- col.prop(rbc, "motor_ang_max_impulse", text="Max Impulse")
- class PHYSICS_PT_rigid_body_constraint_motor_linear(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Linear"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_motor'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and rbc and rbc.type == 'MOTOR'
- and context.engine in cls.COMPAT_ENGINES)
- def draw_header(self, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- self.layout.row().prop(rbc, "use_motor_lin", text="")
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- ob = context.object
- rbc = ob.rigid_body_constraint
- flow.active = rbc.use_motor_lin
- col = flow.column(align=True)
- col.prop(rbc, "motor_lin_target_velocity", text="Target Velocity")
- col = flow.column(align=True)
- col.prop(rbc, "motor_lin_max_impulse", text="Max Impulse")
- class PHYSICS_PT_rigid_body_constraint_springs(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Springs"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and ob.rigid_body_constraint
- and rbc.type == 'GENERIC_SPRING'
- and context.engine in cls.COMPAT_ENGINES)
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- ob = context.object
- rbc = ob.rigid_body_constraint
- layout.prop(rbc, "spring_type", text="Type")
- class PHYSICS_PT_rigid_body_constraint_springs_angular(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Angular"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_springs'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and ob.rigid_body_constraint
- and rbc.type == 'GENERIC_SPRING'
- and context.engine in cls.COMPAT_ENGINES)
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- ob = context.object
- rbc = ob.rigid_body_constraint
- flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- col = flow.column()
- col.prop(rbc, "use_spring_ang_x", text="X Angle")
- sub = col.column(align=True)
- sub.active = rbc.use_spring_ang_x
- sub.prop(rbc, "spring_stiffness_ang_x", text="X Stiffness")
- sub.prop(rbc, "spring_damping_ang_x", text="Damping")
- col = flow.column()
- col.prop(rbc, "use_spring_ang_y", text="Y Angle")
- sub = col.column(align=True)
- sub.active = rbc.use_spring_ang_y
- sub.prop(rbc, "spring_stiffness_ang_y", text="Y Stiffness")
- sub.prop(rbc, "spring_damping_ang_y", text="Damping")
- col = flow.column()
- col.prop(rbc, "use_spring_ang_z", text="Z Angle")
- sub = col.column(align=True)
- sub.active = rbc.use_spring_ang_z
- sub.prop(rbc, "spring_stiffness_ang_z", text="Z Stiffness")
- sub.prop(rbc, "spring_damping_ang_z", text="Damping")
- class PHYSICS_PT_rigid_body_constraint_springs_linear(PHYSICS_PT_rigidbody_constraint_panel, Panel):
- bl_label = "Linear"
- bl_parent_id = 'PHYSICS_PT_rigid_body_constraint_springs'
- COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
- @classmethod
- def poll(cls, context):
- ob = context.object
- rbc = ob.rigid_body_constraint
- return (ob and ob.rigid_body_constraint
- and rbc.type == 'GENERIC_SPRING'
- and context.engine in cls.COMPAT_ENGINES)
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
- ob = context.object
- rbc = ob.rigid_body_constraint
- flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
- col = flow.column()
- col.prop(rbc, "use_spring_x", text="X Axis")
- sub = col.column(align=True)
- sub.active = rbc.use_spring_x
- sub.prop(rbc, "spring_stiffness_x", text="X Stiffness")
- sub.prop(rbc, "spring_damping_x", text="Damping")
- col = flow.column()
- col.prop(rbc, "use_spring_y", text="Y Axis")
- sub = col.column(align=True)
- sub.active = rbc.use_spring_y
- sub.prop(rbc, "spring_stiffness_y", text="Stiffness")
- sub.prop(rbc, "spring_damping_y", text="Damping")
- col = flow.column()
- col.prop(rbc, "use_spring_z", text="Z Axis")
- sub = col.column(align=True)
- sub.active = rbc.use_spring_z
- sub.prop(rbc, "spring_stiffness_z", text="Stiffness")
- sub.prop(rbc, "spring_damping_z", text="Damping")
- classes = (
- PHYSICS_PT_rigid_body_constraint,
- PHYSICS_PT_rigid_body_constraint_settings,
- PHYSICS_PT_rigid_body_constraint_limits,
- PHYSICS_PT_rigid_body_constraint_limits_angular,
- PHYSICS_PT_rigid_body_constraint_limits_linear,
- PHYSICS_PT_rigid_body_constraint_motor,
- PHYSICS_PT_rigid_body_constraint_motor_angular,
- PHYSICS_PT_rigid_body_constraint_motor_linear,
- PHYSICS_PT_rigid_body_constraint_objects,
- PHYSICS_PT_rigid_body_constraint_override_iterations,
- PHYSICS_PT_rigid_body_constraint_springs,
- PHYSICS_PT_rigid_body_constraint_springs_angular,
- PHYSICS_PT_rigid_body_constraint_springs_linear,
- )
- if __name__ == "__main__": # only for live edit.
- from bpy.utils import register_class
- for cls in classes:
- register_class(cls)
|