Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-10-25 19:58:51 +0400
committerTon Roosendaal <ton@blender.org>2005-10-25 19:58:51 +0400
commit77ad2928c31cbd9a1f2a7769cca27b17fa5c2a1a (patch)
tree117c1f841069e364c6ef06aa4ebde9beca43cf47 /source
parent6894526265818ff5188f1fd82616c81ae9015ae5 (diff)
First commit, for test, for using Library files for synchronizing partial
data. This functionality is going to be in Outliner, for now only use for testing while consulting me. :) Usage: New option in SHIFT+F1 append window, "Sync Pose". When pressed, you can append/load an *Object* of type Armature, this then replaces its Armature and Pose with the selected Objects. After that it deletes the appended object. Note: it currently appends also Objects when used in Pose Constraints...
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_space_types.h1
-rw-r--r--source/blender/src/filesel.c84
-rw-r--r--source/blender/src/header_filesel.c8
3 files changed, 83 insertions, 10 deletions
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index f56f620cc0e..4483d23dea1 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -406,6 +406,7 @@ typedef struct SpaceImaSel {
#define FILE_AUTOSELECT 16
#define FILE_ACTIVELAY 32
#define FILE_ATCURSOR 64
+#define FILE_SYNCPOSE 128
/* sfile->sort */
#define FILE_SORTALPHA 0
diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c
index 84f89da48b4..96178d2f20c 100644
--- a/source/blender/src/filesel.c
+++ b/source/blender/src/filesel.c
@@ -61,10 +61,11 @@
#include "IMB_imbuf.h"
+#include "DNA_armature_types.h"
+#include "DNA_action_types.h"
#include "DNA_curve_types.h"
#include "DNA_image_types.h"
#include "DNA_ipo_types.h"
-#include "DNA_vfont_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
@@ -72,16 +73,20 @@
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
-#include "DNA_view3d_types.h"
#include "DNA_userdef_types.h"
+#include "DNA_vfont_types.h"
+#include "DNA_view3d_types.h"
-#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_library.h"
+#include "BKE_action.h"
+#include "BKE_constraint.h"
#include "BKE_curve.h"
+#include "BKE_depsgraph.h"
#include "BKE_font.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_material.h"
+#include "BKE_utildefines.h"
#include "BIF_gl.h"
#include "BIF_interface.h"
@@ -95,6 +100,8 @@
#include "BLO_readfile.h"
#include "BDR_editcurve.h"
+#include "BDR_editobject.h"
+
#include "BPI_script.h"
#include "BSE_filesel.h"
#include "BSE_view.h"
@@ -2245,6 +2252,64 @@ static int is_a_library(SpaceFile *sfile, char *dir, char *group)
return 1;
}
+/* orange hack... :) */
+static void do_sync_pose(Library *lib)
+{
+ Object *ob, *obt;
+ Base *base;
+ bArmature *arm;
+
+ /* find the armature and the pose from library */
+ for(ob= G.main->object.first; ob; ob= ob->id.next)
+ if(ob->type==OB_ARMATURE && ob->id.lib==lib)
+ break;
+
+ if(ob==NULL || ob->pose==NULL)
+ error("No pose appended");
+
+ arm= ob->data;
+
+ /* for all visible objects in this scene */
+ for(base= G.scene->base.first; base; base= base->next) {
+ if((base->flag & SELECT) || (base->object->flag & OB_POSEMODE)) {
+ obt= base->object;
+ if(obt->type==OB_ARMATURE && obt->pose && ob!=obt) {
+ bPoseChannel *chan;
+ bArmature *oldarm= obt->data;
+
+ /* link armature */
+ oldarm->id.us--;
+ obt->data= arm;
+ arm->id.us++;
+
+ /* link pose */
+ free_pose_channels(obt->pose);
+ MEM_freeN(obt->pose);
+ copy_pose(&obt->pose, ob->pose, 1);
+
+ /* relink */
+ ob->id.newid= &obt->id;
+ for (chan = obt->pose->chanbase.first; chan; chan=chan->next){
+ relink_constraints(&chan->constraints);
+ }
+
+ obt->pose->flag |= POSE_RECALC;
+ obt->recalc |= OB_RECALC_DATA;
+ }
+ }
+ }
+
+ /* prevent saving in file, unlink from scene */
+ for(base= G.scene->base.first; base; base= base->next) {
+ if(base->object==ob)
+ break;
+ }
+
+ if(base) {
+ free_and_unlink_base(base);
+ }
+}
+
static void do_library_append(SpaceFile *sfile)
{
Library *lib;
@@ -2283,7 +2348,12 @@ static void do_library_append(SpaceFile *sfile)
lib= lib->id.next;
}
- if((sfile->flag & FILE_LINK)==0) all_local(lib);
+ if(sfile->flag & FILE_SYNCPOSE)
+ do_sync_pose(lib);
+ if((sfile->flag & FILE_LINK)==0)
+ all_local(lib);
+
+ DAG_scene_sort(G.scene);
}
}
diff --git a/source/blender/src/header_filesel.c b/source/blender/src/header_filesel.c
index 4fefdc41a6e..1d661a7940d 100644
--- a/source/blender/src/header_filesel.c
+++ b/source/blender/src/header_filesel.c
@@ -144,13 +144,15 @@ void file_buttons(void)
uiDefButBitS(block, TOG, FILE_AUTOSELECT, B_REDR, "Autosel", xco+=125,0,65,YIC, &sfile->flag, 0, 0, 0, 0, "Autoselect imported objects");
uiDefButBitS(block, TOG, FILE_ACTIVELAY, B_REDR, "Active Layer", xco+=65,0,80,YIC, &sfile->flag, 0, 0, 0, 0, "Append object(s) in active layer");
uiDefButBitS(block, TOG, FILE_ATCURSOR, B_REDR, "At Cursor", xco+=80,0,65,YIC, &sfile->flag, 0, 0, 0, 0, "Append object(s) at cursor, use centroid if more than one object is selected");
+ uiDefButBitS(block, TOG, FILE_SYNCPOSE, B_REDR, "Sync Pose", xco+=80,0,65,YIC, &sfile->flag, 0, 0, 0, 0, "If Object with Pose appended, link the Pose and Armature to all selected Objects");
uiBlockEndAlign(block);
+
+ xco+= 100; // scroll
+
} else if(sfile->type==FILE_BLENDER) {
uiDefButBitI(block, TOGN, G_FILE_NO_UI, B_REDR, "Load UI", xco+=XIC,0,80,YIC, &G.fileflags, 0, 0, 0, 0, "Load the UI setup as well as the scene data");
-
- xco+=100;
-
+ xco+= 100; // scroll
}
if(sfile->type==FILE_UNIX) {