diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2011-12-21 06:41:27 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2011-12-21 06:41:27 +0400 |
commit | 056c49e9ec53849f75aa091f9a98638e77eb82f5 (patch) | |
tree | 5946a35e6eb0e1144d809eca3755c5d30dca9f9a /source | |
parent | 0e4f1ad43d74d5ed277b65b96cd6c5f51c51739c (diff) |
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."
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 48 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 |
3 files changed, 50 insertions, 0 deletions
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); |