2013-01-23 05:56:44 +00:00
|
|
|
# ##### 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>
|
|
|
|
import bpy
|
|
|
|
from bpy.types import Panel
|
|
|
|
|
|
|
|
|
2015-01-29 15:35:06 +11:00
|
|
|
class PHYSICS_PT_rigidbody_panel:
|
2013-01-23 05:56:44 +00:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "physics"
|
|
|
|
|
|
|
|
|
|
|
|
class PHYSICS_PT_rigid_body(PHYSICS_PT_rigidbody_panel, Panel):
|
|
|
|
bl_label = "Rigid Body"
|
2018-07-11 11:43:56 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
2013-01-23 05:56:44 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2013-02-10 08:54:10 +00:00
|
|
|
obj = context.object
|
|
|
|
return (obj and obj.rigid_body and
|
2017-10-16 17:15:03 -02:00
|
|
|
(context.engine in cls.COMPAT_ENGINES))
|
2013-01-23 07:42:28 +00:00
|
|
|
|
2013-01-23 05:56:44 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2018-07-31 21:06:08 +10:00
|
|
|
layout.use_property_split = True
|
2013-01-23 05:56:44 +00:00
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
rbo = ob.rigid_body
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2013-01-23 08:07:39 +00:00
|
|
|
if rbo is not None:
|
2013-01-23 05:56:44 +00:00
|
|
|
layout.prop(rbo, "type", text="Type")
|
|
|
|
|
|
|
|
if rbo.type == 'ACTIVE':
|
2013-01-23 11:40:35 +00:00
|
|
|
layout.prop(rbo, "mass")
|
2013-01-23 05:56:44 +00:00
|
|
|
|
2018-07-31 21:06:08 +10:00
|
|
|
col = layout.column()
|
|
|
|
if rbo.type == 'ACTIVE':
|
|
|
|
col.prop(rbo, "enabled", text="Dynamic")
|
|
|
|
col.prop(rbo, "kinematic", text="Animated")
|
|
|
|
|
2013-01-23 05:56:44 +00:00
|
|
|
|
|
|
|
class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
|
2018-06-19 15:38:51 +02:00
|
|
|
bl_label = "Collisions"
|
|
|
|
bl_parent_id = 'PHYSICS_PT_rigid_body'
|
2018-07-11 11:43:56 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
2013-01-23 05:56:44 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2013-02-10 08:54:10 +00:00
|
|
|
obj = context.object
|
|
|
|
return (obj and obj.rigid_body and
|
2017-10-16 17:15:03 -02:00
|
|
|
(context.engine in cls.COMPAT_ENGINES))
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2013-01-23 05:56:44 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
rbo = ob.rigid_body
|
2018-07-31 21:06:08 +10:00
|
|
|
layout.use_property_split = True
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2013-01-23 05:56:44 +00:00
|
|
|
layout.prop(rbo, "collision_shape", text="Shape")
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2013-12-26 17:02:28 +01:00
|
|
|
if rbo.collision_shape in {'MESH', 'CONVEX_HULL'}:
|
|
|
|
layout.prop(rbo, "mesh_source", text="Source")
|
|
|
|
|
2013-12-26 18:15:56 +01:00
|
|
|
if rbo.collision_shape == 'MESH' and rbo.mesh_source == 'DEFORM':
|
|
|
|
layout.prop(rbo, "use_deform", text="Deforming")
|
|
|
|
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2018-07-31 21:06:08 +10:00
|
|
|
class PHYSICS_PT_rigid_body_collisions_surface(PHYSICS_PT_rigidbody_panel, Panel):
|
|
|
|
bl_label = "Surface Response"
|
|
|
|
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
obj = context.object
|
|
|
|
return (obj and obj.rigid_body and
|
|
|
|
(context.engine in cls.COMPAT_ENGINES))
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
rbo = ob.rigid_body
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
col = layout.column()
|
2013-01-23 05:56:44 +00:00
|
|
|
col.prop(rbo, "friction")
|
|
|
|
col.prop(rbo, "restitution", text="Bounciness")
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2018-07-31 21:06:08 +10:00
|
|
|
|
|
|
|
class PHYSICS_PT_rigid_body_collisions_sensitivity(PHYSICS_PT_rigidbody_panel, Panel):
|
|
|
|
bl_label = "Sensitivity"
|
|
|
|
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
obj = context.object
|
|
|
|
return (obj and obj.rigid_body and
|
|
|
|
(context.engine in cls.COMPAT_ENGINES))
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
rbo = ob.rigid_body
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
|
2013-01-23 05:56:44 +00:00
|
|
|
if rbo.collision_shape in {'MESH', 'CONE'}:
|
|
|
|
col.prop(rbo, "collision_margin", text="Margin")
|
|
|
|
else:
|
2013-02-10 08:54:10 +00:00
|
|
|
col.prop(rbo, "use_margin")
|
2013-01-23 05:56:44 +00:00
|
|
|
sub = col.column()
|
|
|
|
sub.active = rbo.use_margin
|
|
|
|
sub.prop(rbo, "collision_margin", text="Margin")
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2018-07-31 21:06:08 +10:00
|
|
|
|
|
|
|
class PHYSICS_PT_rigid_body_collisions_collections(PHYSICS_PT_rigidbody_panel, Panel):
|
|
|
|
bl_label = "Collision Collections"
|
|
|
|
bl_parent_id = 'PHYSICS_PT_rigid_body_collisions'
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
obj = context.object
|
|
|
|
return (obj and obj.rigid_body and
|
|
|
|
(context.engine in cls.COMPAT_ENGINES))
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
rbo = ob.rigid_body
|
|
|
|
|
|
|
|
layout.prop(rbo, "collision_groups", text="")
|
2013-01-23 05:56:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
|
2018-06-19 15:38:51 +02:00
|
|
|
bl_label = "Dynamics"
|
|
|
|
bl_parent_id = 'PHYSICS_PT_rigid_body'
|
2018-07-11 14:04:17 +02:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2018-07-11 11:43:56 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
2013-01-23 05:56:44 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2013-02-10 08:54:10 +00:00
|
|
|
obj = context.object
|
|
|
|
return (obj and obj.rigid_body and
|
|
|
|
obj.rigid_body.type == 'ACTIVE' and
|
2017-10-16 17:15:03 -02:00
|
|
|
(context.engine in cls.COMPAT_ENGINES))
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2013-01-23 05:56:44 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2018-07-31 21:06:08 +10:00
|
|
|
layout.use_property_split = True
|
2013-01-23 05:56:44 +00:00
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
rbo = ob.rigid_body
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2013-01-23 05:56:44 +00:00
|
|
|
#col = layout.column(align=1)
|
2018-06-05 16:32:11 +02:00
|
|
|
# col.label(text="Activation:")
|
2013-03-11 02:19:58 +00:00
|
|
|
# XXX: settings such as activate on collison/etc.
|
2013-02-10 08:54:10 +00:00
|
|
|
|
2018-07-31 21:06:08 +10:00
|
|
|
col = layout.column()
|
|
|
|
col.prop(rbo, "linear_damping", text="Translation Damping")
|
|
|
|
col.prop(rbo, "angular_damping", text="Rotation Damping")
|
|
|
|
|
|
|
|
|
|
|
|
class PHYSICS_PT_rigid_body_dynamics_deactivation(PHYSICS_PT_rigidbody_panel, Panel):
|
|
|
|
bl_label = "Deactivation"
|
|
|
|
bl_parent_id = 'PHYSICS_PT_rigid_body_dynamics'
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
obj = context.object
|
|
|
|
return (obj and obj.rigid_body and
|
|
|
|
obj.rigid_body.type == 'ACTIVE' and
|
|
|
|
(context.engine in cls.COMPAT_ENGINES))
|
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
ob = context.object
|
|
|
|
rbo = ob.rigid_body
|
|
|
|
self.layout.prop(rbo, "use_deactivation", text="")
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
rbo = ob.rigid_body
|
|
|
|
|
|
|
|
layout.active = rbo.use_deactivation
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
col.prop(rbo, "use_start_deactivated")
|
|
|
|
col.prop(rbo, "deactivate_linear_velocity", text="Linear Velocity")
|
|
|
|
col.prop(rbo, "deactivate_angular_velocity", text="Angular Velocity")
|
|
|
|
# TODO: other params such as time?
|
2013-01-23 05:56:44 +00:00
|
|
|
|
2017-03-18 20:03:24 +11:00
|
|
|
|
|
|
|
classes = (
|
|
|
|
PHYSICS_PT_rigid_body,
|
|
|
|
PHYSICS_PT_rigid_body_collisions,
|
2018-07-31 21:06:08 +10:00
|
|
|
PHYSICS_PT_rigid_body_collisions_surface,
|
|
|
|
PHYSICS_PT_rigid_body_collisions_sensitivity,
|
|
|
|
PHYSICS_PT_rigid_body_collisions_collections,
|
2017-03-18 20:03:24 +11:00
|
|
|
PHYSICS_PT_rigid_body_dynamics,
|
2018-07-31 21:06:08 +10:00
|
|
|
PHYSICS_PT_rigid_body_dynamics_deactivation,
|
2017-03-18 20:03:24 +11:00
|
|
|
)
|
|
|
|
|
2013-01-23 05:56:44 +00:00
|
|
|
if __name__ == "__main__": # only for live edit.
|
2017-03-18 20:03:24 +11:00
|
|
|
from bpy.utils import register_class
|
|
|
|
for cls in classes:
|
|
|
|
register_class(cls)
|