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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-04 20:42:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-04 20:42:58 +0400
commit68a9dd54ec909d8e56da0da487c6ec3559551edd (patch)
tree9b0949fdc65604fe3e39b765b4085a714b8e7471 /source/blender/blenloader
parent2230f3346e8a7ac2191690627856a1a8745bd8e9 (diff)
mask mode for clip editor developed by Sergey Sharybin, Pete Larabell and myself.
see: http://wiki.blender.org/index.php/User:Nazg-gul/MaskEditor note - mask editing tools need continued development, feather option is not working 100%
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c125
-rw-r--r--source/blender/blenloader/intern/writefile.c55
2 files changed, 173 insertions, 7 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e41e9ba18a1..826d9d196b8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -95,6 +95,7 @@
#include "DNA_vfont_types.h"
#include "DNA_world_types.h"
#include "DNA_movieclip_types.h"
+#include "DNA_mask_types.h"
#include "MEM_guardedalloc.h"
@@ -5353,9 +5354,10 @@ static void lib_link_screen(FileData *fd, Main *main)
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
-
+
sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
-
+ sclip->mask = newlibadr_us(fd, sc->id.lib, sclip->mask);
+
sclip->scopes.track_preview = NULL;
sclip->draw_context = NULL;
sclip->scopes.ok = 0;
@@ -5616,9 +5618,10 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
-
+
sclip->clip = restore_pointer_by_name(newmain, (ID *)sclip->clip, 1);
-
+ sclip->mask = restore_pointer_by_name(newmain, (ID *)sclip->mask, 1);
+
sclip->scopes.ok = 0;
}
}
@@ -6173,6 +6176,88 @@ static void lib_link_movieclip(FileData *fd, Main *main)
}
}
+/* ***************** READ MOVIECLIP *************** */
+
+static void direct_link_mask(FileData *fd, Mask *mask)
+{
+ MaskLayer *masklay;
+
+ mask->adt = newdataadr(fd, mask->adt);
+
+ link_list(fd, &mask->masklayers);
+
+ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ MaskSpline *spline;
+ MaskLayerShape *masklay_shape;
+
+ link_list(fd, &masklay->splines);
+
+ for (spline = masklay->splines.first; spline; spline = spline->next) {
+ int i;
+
+ spline->points = newdataadr(fd, spline->points);
+
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
+
+ if (point->tot_uw)
+ point->uw = newdataadr(fd, point->uw);
+ }
+ }
+
+ link_list(fd, &masklay->splines_shapes);
+
+ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
+ masklay_shape->data = newdataadr(fd, masklay_shape->data);
+ }
+
+ masklay->act_spline = newdataadr(fd, masklay->act_spline);
+ masklay->act_point = newdataadr(fd, masklay->act_point);
+ }
+}
+
+static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent)
+{
+ parent->id = newlibadr_us(fd, mask->id.lib, parent->id);
+}
+
+static void lib_link_mask(FileData *fd, Main *main)
+{
+ Mask *mask;
+
+ mask = main->mask.first;
+ while (mask) {
+ if(mask->id.flag & LIB_NEEDLINK) {
+ MaskLayer *masklay;
+
+ if (mask->adt)
+ lib_link_animdata(fd, &mask->id, mask->adt);
+
+ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ MaskSpline *spline;
+
+ spline = masklay->splines.first;
+ while (spline) {
+ int i;
+
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
+
+ lib_link_mask_parent(fd, mask, &point->parent);
+ }
+
+ lib_link_mask_parent(fd, mask, &spline->parent);
+
+ spline = spline->next;
+ }
+ }
+
+ mask->id.flag -= LIB_NEEDLINK;
+ }
+ mask = mask->id.next;
+ }
+}
+
/* ************** GENERAL & MAIN ******************** */
@@ -6378,6 +6463,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
case ID_MC:
direct_link_movieclip(fd, (MovieClip *)id);
break;
+ case ID_MSK:
+ direct_link_mask(fd, (Mask *)id);
+ break;
}
/*link direct data of ID properties*/
@@ -7506,7 +7594,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
-
+
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 8))
{
/* set new deactivation values for game settings */
@@ -7533,7 +7621,29 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
-
+
+ {
+ bScreen *sc;
+
+ for (sc = main->screen.first; sc; sc = sc->id.next) {
+ ScrArea *sa;
+
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_CLIP) {
+ SpaceClip *sclip = (SpaceClip *)sl;
+
+ if (sclip->around == 0) {
+ sclip->around = V3D_CENTROID;
+ }
+ }
+ }
+ }
+ }
+ }
+
/* don't forget to set version number in blender.c! */
}
@@ -7576,7 +7686,8 @@ static void lib_link_all(FileData *fd, Main *main)
lib_link_brush(fd, main);
lib_link_particlesettings(fd, main);
lib_link_movieclip(fd, main);
-
+ lib_link_mask(fd, main);
+
lib_link_mesh(fd, main); /* as last: tpage images with users at zero */
lib_link_library(fd, main); /* only init users */
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 4f75e8e5fbf..655adf97b04 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -133,6 +133,7 @@ Any case: direct data is ALWAYS after the lib block
#include "DNA_world_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_movieclip_types.h"
+#include "DNA_mask_types.h"
#include "MEM_guardedalloc.h" // MEM_freeN
#include "BLI_bitmap.h"
@@ -2752,6 +2753,59 @@ static void write_movieclips(WriteData *wd, ListBase *idbase)
mywrite(wd, MYWRITE_FLUSH, 0);
}
+static void write_masks(WriteData *wd, ListBase *idbase)
+{
+ Mask *mask;
+
+ mask = idbase->first;
+ while (mask) {
+ if (mask->id.us > 0 || wd->current) {
+ MaskLayer *masklay;
+
+ writestruct(wd, ID_MSK, "Mask", 1, mask);
+
+ if (mask->adt)
+ write_animdata(wd, mask->adt);
+
+ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ MaskSpline *spline;
+ MaskLayerShape *masklay_shape;
+
+ writestruct(wd, DATA, "MaskLayer", 1, masklay);
+
+ for (spline = masklay->splines.first; spline; spline = spline->next) {
+ int i;
+
+ void *points_deform = spline->points_deform;
+ spline->points_deform = NULL;
+
+ writestruct(wd, DATA, "MaskSpline", 1, spline);
+ writestruct(wd, DATA, "MaskSplinePoint", spline->tot_point, spline->points);
+
+ spline->points_deform = points_deform;
+
+ for (i = 0; i < spline->tot_point; i++) {
+ MaskSplinePoint *point = &spline->points[i];
+
+ if (point->tot_uw)
+ writestruct(wd, DATA, "MaskSplinePointUW", point->tot_uw, point->uw);
+ }
+ }
+
+ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
+ writestruct(wd, DATA, "MaskLayerShape", 1, masklay_shape);
+ writedata(wd, DATA, masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, masklay_shape->data);
+ }
+ }
+ }
+
+ mask = mask->id.next;
+ }
+
+ /* flush helps the compression for undo-save */
+ mywrite(wd, MYWRITE_FLUSH, 0);
+}
+
/* context is usually defined by WM, two cases where no WM is available:
* - for forward compatibility, curscreen has to be saved
* - for undofile, curscene needs to be saved */
@@ -2836,6 +2890,7 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
write_screens (wd, &mainvar->screen);
}
write_movieclips (wd, &mainvar->movieclip);
+ write_masks (wd, &mainvar->mask);
write_scenes (wd, &mainvar->scene);
write_curves (wd, &mainvar->curve);
write_mballs (wd, &mainvar->mball);