From 056c49e9ec53849f75aa091f9a98638e77eb82f5 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 21 Dec 2011 02:41:27 +0000 Subject: [PATCH] Patch [#29654] New menu option under Object > Game with "Copy All Physics Attributes" by Daniel Macedo "This is a patch that adds an option under the menu Object > Game to copy all the physics attributes from Game Engine." --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/editors/object/object_edit.c | 48 +++++++++++++++++++ source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + 4 files changed, 51 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 5444ad327a9..57bde4eb0dd 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -993,6 +993,7 @@ class VIEW3D_MT_object_game(Menu): layout = self.layout layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks") + layout.operator("object.game_physics_copy", text="Copy Physics Properties") layout.separator() diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 07ab80f6d15..fa308624454 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2178,3 +2178,51 @@ void OBJECT_OT_logic_bricks_copy(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } + +static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob=ED_object_active_context(C); + + CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { + if(ob != ob_iter) { + ob_iter->gameflag = ob->gameflag; + ob_iter->gameflag2 = ob->gameflag2; + ob_iter->inertia = ob->inertia; + ob_iter->formfactor = ob->formfactor;; + ob_iter->damping = ob->damping; + ob_iter->rdamping = ob->rdamping; + ob_iter->min_vel = ob->min_vel; + ob_iter->max_vel = ob->max_vel; + ob_iter->obstacleRad = ob->obstacleRad; + ob_iter->mass = ob->mass; + ob_iter->anisotropicFriction[0] = ob->anisotropicFriction[0]; + ob_iter->anisotropicFriction[1] = ob->anisotropicFriction[1]; + ob_iter->anisotropicFriction[2] = ob->anisotropicFriction[2]; + ob_iter->collision_boundtype = ob->collision_boundtype; + ob_iter->margin = ob->margin; + ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft); + if(ob->restrictflag & OB_RESTRICT_RENDER) + ob_iter->restrictflag |= OB_RESTRICT_RENDER; + else + ob_iter->restrictflag &= ~OB_RESTRICT_RENDER; + } + } + CTX_DATA_END; + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Game Physics Properties to Selected"; + ot->description = "Copy game physics properties to other selected objects"; + ot->idname= "OBJECT_OT_game_physics_copy"; + + /* api callbacks */ + ot->exec= game_physics_copy_exec; + ot->poll= ED_operator_object_active_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 185d8d43765..35e802e3e11 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -92,6 +92,7 @@ void OBJECT_OT_game_property_remove(struct wmOperatorType *ot); void OBJECT_OT_game_property_copy(struct wmOperatorType *ot); void OBJECT_OT_game_property_clear(struct wmOperatorType *ot); void OBJECT_OT_logic_bricks_copy(struct wmOperatorType *ot); +void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot); /* object_select.c */ void OBJECT_OT_select_all(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 3b4a5ed976e..a899d60c2ab 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -189,6 +189,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_game_property_copy); WM_operatortype_append(OBJECT_OT_game_property_clear); WM_operatortype_append(OBJECT_OT_logic_bricks_copy); + WM_operatortype_append(OBJECT_OT_game_physics_copy); WM_operatortype_append(OBJECT_OT_shape_key_add); WM_operatortype_append(OBJECT_OT_shape_key_remove);