[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42782] trunk/blender: Patch [#29654] New menu option under Object > Game with "Copy All Physics Attributes" by Daniel Macedo

Dalai Felinto dfelinto at gmail.com
Wed Dec 21 03:41:34 CET 2011


Revision: 42782
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42782
Author:   dfelinto
Date:     2011-12-21 02:41:27 +0000 (Wed, 21 Dec 2011)
Log Message:
-----------
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."

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_view3d.py
    trunk/blender/source/blender/editors/object/object_edit.c
    trunk/blender/source/blender/editors/object/object_intern.h
    trunk/blender/source/blender/editors/object/object_ops.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d.py	2011-12-21 00:47:59 UTC (rev 42781)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d.py	2011-12-21 02:41:27 UTC (rev 42782)
@@ -993,6 +993,7 @@
         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()
 

Modified: trunk/blender/source/blender/editors/object/object_edit.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_edit.c	2011-12-21 00:47:59 UTC (rev 42781)
+++ trunk/blender/source/blender/editors/object/object_edit.c	2011-12-21 02:41:27 UTC (rev 42782)
@@ -2178,3 +2178,51 @@
 	/* 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;
+}

Modified: trunk/blender/source/blender/editors/object/object_intern.h
===================================================================
--- trunk/blender/source/blender/editors/object/object_intern.h	2011-12-21 00:47:59 UTC (rev 42781)
+++ trunk/blender/source/blender/editors/object/object_intern.h	2011-12-21 02:41:27 UTC (rev 42782)
@@ -92,6 +92,7 @@
 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);

Modified: trunk/blender/source/blender/editors/object/object_ops.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_ops.c	2011-12-21 00:47:59 UTC (rev 42781)
+++ trunk/blender/source/blender/editors/object/object_ops.c	2011-12-21 02:41:27 UTC (rev 42782)
@@ -189,6 +189,7 @@
 	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);




More information about the Bf-blender-cvs mailing list