blender/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
Sergey Sharybin 03806d0b67 Re-design of submodules used in blender.git
This commit implements described in the #104573.

The goal is to fix the confusion of the submodule hashes change, which are not
ideal for any of the supported git-module configuration (they are either always
visible causing confusion, or silently staged and committed, also causing
confusion).

This commit replaces submodules with a checkout of addons and addons_contrib,
covered by the .gitignore, and locale and developer tools are moved to the
main repository.

This also changes the paths:
- /release/scripts are moved to the /scripts
- /source/tools are moved to the /tools
- /release/datafiles/locale is moved to /locale

This is done to avoid conflicts when using bisect, and also allow buildbot to
automatically "recover" wgen building older or newer branches/patches.

Running `make update` will initialize the local checkout to the changed
repository configuration.

Another aspect of the change is that the make update will support Github style
of remote organization (origin remote pointing to thy fork, upstream remote
pointing to the upstream blender/blender.git).

Pull Request #104755
2023-02-21 16:39:58 +01:00

546 lines
17 KiB
Python

# SPDX-License-Identifier: GPL-2.0-or-later
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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
@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)