[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54023] trunk/blender: rigidbody: Add rigid body simulation
Sergej Reich
sergej.reich at googlemail.com
Wed Jan 23 06:56:44 CET 2013
Revision: 54023
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54023
Author: sergof
Date: 2013-01-23 05:56:44 +0000 (Wed, 23 Jan 2013)
Log Message:
-----------
rigidbody: Add rigid body simulation
Add operators to add/remove rigid body world and objects.
Add UI scripts.
The rigid body simulation works on scene level and overrides the
position/orientation of rigid bodies when active.
It does not deform meshes or generate data so there is no modifier.
Usage:
* Add rigid body world in the scene tab
* Create a group
* Add objects to the group
* Assign group to the rigid body world
* Play animation
For convenience the rigid body tools operators in the tools panel of the 3d view
will add a world, group and add objects to the group automatically so you only have
to press one button to add/remove rigid bodies to the simulation.
Part of GSoC 2010 and 2012.
Authors: Joshua Leung (aligorith), Sergej Reich (sergof)
Modified Paths:
--------------
trunk/blender/intern/cycles/blender/addon/ui.py
trunk/blender/release/scripts/startup/bl_operators/__init__.py
trunk/blender/release/scripts/startup/bl_ui/__init__.py
trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py
trunk/blender/release/scripts/startup/bl_ui/properties_scene.py
trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
trunk/blender/source/blender/blenkernel/intern/object.c
trunk/blender/source/blender/blenkernel/intern/rigidbody.c
trunk/blender/source/blender/blenkernel/intern/scene.c
trunk/blender/source/blender/editors/include/ED_physics.h
trunk/blender/source/blender/editors/object/object_add.c
trunk/blender/source/blender/editors/physics/CMakeLists.txt
trunk/blender/source/blender/editors/physics/SConscript
trunk/blender/source/blender/editors/physics/physics_intern.h
trunk/blender/source/blender/editors/physics/physics_ops.c
Added Paths:
-----------
trunk/blender/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
trunk/blender/source/blender/editors/physics/rigidbody_object.c
trunk/blender/source/blender/editors/physics/rigidbody_world.c
Modified: trunk/blender/intern/cycles/blender/addon/ui.py
===================================================================
--- trunk/blender/intern/cycles/blender/addon/ui.py 2013-01-23 05:56:34 UTC (rev 54022)
+++ trunk/blender/intern/cycles/blender/addon/ui.py 2013-01-23 05:56:44 UTC (rev 54023)
@@ -1166,6 +1166,9 @@
types.PARTICLE_PT_velocity,
types.PARTICLE_PT_rotation,
types.PARTICLE_PT_physics,
+ bpy.types.SCENE_PT_rigid_body_world,
+ bpy.types.SCENE_PT_rigid_body_cache,
+ bpy.types.SCENE_PT_rigid_body_field_weights,
types.PARTICLE_PT_boidbrain,
types.PARTICLE_PT_render,
types.PARTICLE_PT_draw,
Modified: trunk/blender/release/scripts/startup/bl_operators/__init__.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/__init__.py 2013-01-23 05:56:34 UTC (rev 54022)
+++ trunk/blender/release/scripts/startup/bl_operators/__init__.py 2013-01-23 05:56:44 UTC (rev 54023)
@@ -35,6 +35,7 @@
"object_randomize_transform",
"object_quick_effects",
"presets",
+ "rigidbody",
"screen_play_rendered_anim",
"sequencer",
"uvcalc_follow_active",
Modified: trunk/blender/release/scripts/startup/bl_ui/__init__.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/__init__.py 2013-01-23 05:56:34 UTC (rev 54022)
+++ trunk/blender/release/scripts/startup/bl_ui/__init__.py 2013-01-23 05:56:44 UTC (rev 54023)
@@ -48,6 +48,7 @@
"properties_physics_dynamicpaint",
"properties_physics_field",
"properties_physics_fluid",
+ "properties_physics_rigidbody",
"properties_physics_smoke",
"properties_physics_softbody",
"properties_render",
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py 2013-01-23 05:56:34 UTC (rev 54022)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py 2013-01-23 05:56:44 UTC (rev 54023)
@@ -44,6 +44,12 @@
else:
sub.operator("object.modifier_add", text=name, icon=typeicon).type = type
+def physics_add_special(self, layout, data, name, addop, removeop, typeicon):
+ sub = layout.row(align=True)
+ if data:
+ sub.operator(removeop, text=name, icon='X')
+ else:
+ sub.operator(addop, text=name, icon=typeicon)
class PHYSICS_PT_add(PhysicButtonsPanel, Panel):
bl_label = ""
@@ -76,7 +82,13 @@
physics_add(self, col, context.fluid, "Fluid", 'FLUID_SIMULATION', 'MOD_FLUIDSIM', True)
physics_add(self, col, context.smoke, "Smoke", 'SMOKE', 'MOD_SMOKE', True)
+ if(ob.type == 'MESH'):
+ physics_add_special(self, col, ob.rigid_body, "Rigid Body",
+ "rigidbody.object_add",
+ "rigidbody.object_remove",
+ 'MESH_ICOSPHERE') # XXX: need dedicated icon
+
# cache-type can be 'PSYS' 'HAIR' 'SMOKE' etc
def point_cache_ui(self, context, cache, enabled, cachetype):
@@ -84,11 +96,12 @@
layout.context_pointer_set("point_cache", cache)
- row = layout.row()
- row.template_list("UI_UL_list", "", cache, "point_caches", cache.point_caches, "active_index", rows=2)
- col = row.column(align=True)
- col.operator("ptcache.add", icon='ZOOMIN', text="")
- col.operator("ptcache.remove", icon='ZOOMOUT', text="")
+ if not cachetype == 'RIGID_BODY':
+ row = layout.row()
+ row.template_list("UI_UL_list", "", cache, "point_caches", cache.point_caches, "active_index", rows=2)
+ col = row.column(align=True)
+ col.operator("ptcache.add", icon='ZOOMIN', text="")
+ col.operator("ptcache.remove", icon='ZOOMOUT', text="")
row = layout.row()
if cachetype in {'PSYS', 'HAIR', 'SMOKE'}:
@@ -131,13 +144,13 @@
row.enabled = enabled
row.prop(cache, "frame_start")
row.prop(cache, "frame_end")
- if cachetype not in {'SMOKE', 'CLOTH', 'DYNAMIC_PAINT'}:
+ if cachetype not in {'SMOKE', 'CLOTH', 'DYNAMIC_PAINT', 'RIGID_BODY'}:
row.prop(cache, "frame_step")
if cachetype != 'SMOKE':
layout.label(text=cache.info)
- if cachetype not in {'SMOKE', 'DYNAMIC_PAINT'}:
+ if cachetype not in {'SMOKE', 'DYNAMIC_PAINT', 'RIGID_BODY'}:
split = layout.split()
split.enabled = enabled and bpy.data.is_saved
Added: trunk/blender/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_physics_rigidbody.py (rev 0)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_physics_rigidbody.py 2013-01-23 05:56:44 UTC (rev 54023)
@@ -0,0 +1,130 @@
+# ##### 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
+
+
+class PHYSICS_PT_rigidbody_panel():
+ 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"
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.object
+ rd = context.scene.render
+ return (ob and ob.rigid_body and (not rd.use_game_engine))
+
+ def draw(self, context):
+ layout = self.layout
+
+ ob = context.object
+ rbo = ob.rigid_body
+
+ if rbo:
+ layout.prop(rbo, "type", text="Type")
+
+ row = layout.row()
+ row.prop(rbo, "enabled");
+ row.prop(rbo, "kinematic", text="Animated")
+
+ if rbo.type == 'ACTIVE':
+ col = layout.column()
+ col.prop(rbo, "mass")
+
+
+class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
+ bl_label = "Rigid Body Collisions"
+
+ @classmethod
+ def poll(cls, context):
+ return (context.object and context.object.rigid_body and
+ (not context.scene.render.use_game_engine))
+
+ def draw(self, context):
+ layout = self.layout
+
+ ob = context.object
+ rbo = ob.rigid_body
+
+ layout.prop(rbo, "collision_shape", text="Shape")
+
+ split = layout.split()
+
+ col = split.column()
+ col.label(text="Surface Response:")
+ col.prop(rbo, "friction")
+ col.prop(rbo, "restitution", text="Bounciness")
+
+ col = split.column()
+ col.label(text="Sensitivity:")
+ if rbo.collision_shape in {'MESH', 'CONE'}:
+ col.prop(rbo, "collision_margin", text="Margin")
+ else:
+ col.prop(rbo, "use_margin");
+ sub = col.column()
+ sub.active = rbo.use_margin
+ sub.prop(rbo, "collision_margin", text="Margin")
+ layout.prop(rbo, "collision_groups")
+
+
+class PHYSICS_PT_rigid_body_dynamics(PHYSICS_PT_rigidbody_panel, Panel):
+ bl_label = "Rigid Body Dynamics"
+ bl_default_closed = True
+
+ @classmethod
+ def poll(cls, context):
+ return (context.object and context.object.rigid_body and
+ context.object.rigid_body.type == 'ACTIVE' and
+ (not context.scene.render.use_game_engine))
+
+ def draw(self, context):
+ layout = self.layout
+
+ ob = context.object
+ rbo = ob.rigid_body
+
+ #col = layout.column(align=1)
+ #col.label(text="Activation:")
+ # XXX: settings such as activate on collison/etc.
+
+ split = layout.split();
+
+ col = split.column()
+ col.label(text="Deactivation:")
+ col.prop(rbo, "use_deactivation")
+ sub = col.column()
+ sub.active = rbo.use_deactivation
+ sub.prop(rbo, "start_deactivated")
+ sub.prop(rbo, "deactivate_linear_velocity", text="Linear Vel")
+ sub.prop(rbo, "deactivate_angular_velocity", text="Angular Vel")
+ # TODO: other params such as time?
+
+ col = split.column()
+ col.label(text="Damping:")
+ col.prop(rbo, "linear_damping", text="Translation")
+ col.prop(rbo, "angular_damping", text="Rotation")
+
+if __name__ == "__main__": # only for live edit.
+ bpy.utils.register_module(__name__)
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_scene.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_scene.py 2013-01-23 05:56:34 UTC (rev 54022)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_scene.py 2013-01-23 05:56:44 UTC (rev 54023)
@@ -21,6 +21,10 @@
from bpy.types import Panel, UIList
from rna_prop_ui import PropertyPanel
+from bl_ui.properties_physics_common import (
+ point_cache_ui,
+ effector_weights_ui,
+ )
class SCENE_UL_keying_set_paths(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
@@ -242,6 +246,83 @@
layout.prop(scene, "gravity", text="")
+class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
+ bl_label = "Rigid Body World"
+ COMPAT_ENGINES = {'BLENDER_RENDER'}
+
+ @classmethod
+ def poll(cls, context):
+ rd = context.scene.render
+ scene = context.scene
+ return scene and (rd.engine in cls.COMPAT_ENGINES)
+
+ def draw(self, context):
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list