[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33491] trunk/blender/source/blender: bpath iterator updates
Campbell Barton
ideasman42 at gmail.com
Mon Dec 6 00:14:48 CET 2010
Revision: 33491
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33491
Author: campbellbarton
Date: 2010-12-06 00:14:48 +0100 (Mon, 06 Dec 2010)
Log Message:
-----------
bpath iterator updates
- loop over sequencer plugin and texture voxel paths.
- fix leak in python bpy.utils.blend_path() and use PyUnicode_DecodeFSDefault() to ensure correct paths with different encodings.
- operators to make paths absolute & relative now redraw the view.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/depsgraph.c
trunk/blender/source/blender/blenlib/BLI_bpath.h
trunk/blender/source/blender/blenlib/intern/bpath.c
trunk/blender/source/blender/editors/space_info/info_ops.c
trunk/blender/source/blender/makesdna/DNA_texture_types.h
trunk/blender/source/blender/python/intern/bpy.c
trunk/blender/source/blender/render/intern/source/voxeldata.c
Modified: trunk/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/depsgraph.c 2010-12-05 18:59:23 UTC (rev 33490)
+++ trunk/blender/source/blender/blenkernel/intern/depsgraph.c 2010-12-05 23:14:48 UTC (rev 33491)
@@ -2456,6 +2456,7 @@
}
}
+#if 0 // UNUSED
/* recursively descends tree, each node only checked once */
/* node is checked to be of type object */
static int parent_check_node(DagNode *node, int curtime)
@@ -2485,6 +2486,7 @@
return DAG_WHITE;
}
+#endif
/* ******************* DAG FOR ARMATURE POSE ***************** */
Modified: trunk/blender/source/blender/blenlib/BLI_bpath.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_bpath.h 2010-12-05 18:59:23 UTC (rev 33490)
+++ trunk/blender/source/blender/blenlib/BLI_bpath.h 2010-12-05 23:14:48 UTC (rev 33491)
@@ -32,36 +32,17 @@
#ifndef BLI_BPATH_H
#define BLI_BPATH_H
-struct BPathIteratorSeqData {
- int totseq;
- int seq;
- struct Sequence **seqar; /* Sequence */
- struct Scene *scene; /* Current scene */
-};
+struct BPathIterator;
-struct BPathIterator {
- char* path;
- const char* lib;
- const char* name;
- void* data;
- int len;
- int type;
-
- void (*setpath_callback)(struct BPathIterator *, const char *);
- void (*getpath_callback)(struct BPathIterator *, char *);
-
- const char* base_path; /* base path, the directry the blend file is in - normally G.main->name */
- /* only for seq data */
- struct BPathIteratorSeqData seqdata;
-};
-
void BLI_bpathIterator_init (struct BPathIterator *bpi, const char *base_path);
+void BLI_bpathIterator_alloc (struct BPathIterator **bpi);
void BLI_bpathIterator_free (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getLib (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getName (struct BPathIterator *bpi);
int BLI_bpathIterator_getType (struct BPathIterator *bpi);
int BLI_bpathIterator_getPathMaxLen (struct BPathIterator *bpi);
+const char* BLI_bpathIterator_getBasePath (struct BPathIterator *bpi);
void BLI_bpathIterator_step (struct BPathIterator *bpi);
int BLI_bpathIterator_isDone (struct BPathIterator *bpi);
void BLI_bpathIterator_getPath (struct BPathIterator *bpi, char *path);
Modified: trunk/blender/source/blender/blenlib/intern/bpath.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/bpath.c 2010-12-05 18:59:23 UTC (rev 33490)
+++ trunk/blender/source/blender/blenlib/intern/bpath.c 2010-12-05 23:14:48 UTC (rev 33491)
@@ -29,6 +29,7 @@
#include <sys/stat.h>
#include <string.h>
+#include <assert.h>
/* path/file handeling stuff */
#ifndef WIN32
@@ -44,6 +45,8 @@
#include "DNA_mesh_types.h"
#include "DNA_scene_types.h" /* to get the current frame */
#include "DNA_image_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_text_types.h"
#include "DNA_sound_types.h"
#include "DNA_sequence_types.h"
#include "DNA_vfont_types.h"
@@ -65,11 +68,39 @@
//XXX #include "BSE_sequence.h"
//XXX define below from BSE_sequence.h - otherwise potentially odd behaviour
+
+typedef struct BPathIteratorSeqData {
+ int totseq;
+ int seq;
+ struct Sequence **seqar; /* Sequence */
+ struct Scene *scene; /* Current scene */
+} BPathIteratorSeqData;
+
+typedef struct BPathIterator {
+ char* _path; /* never access directly, use BLI_bpathIterator_getPath */
+ const char* _lib;
+ const char* _name;
+ void* data;
+ int len;
+ int type;
+
+ void (*setpath_callback)(struct BPathIterator *, const char *);
+ void (*getpath_callback)(struct BPathIterator *, char *);
+
+ const char* base_path; /* base path, the directry the blend file is in - normally G.main->name */
+
+ /* only for seq data */
+ struct BPathIteratorSeqData seqdata;
+} BPathIterator;
+
#define FILE_MAX 240
+
/* TODO - BPATH_PLUGIN, BPATH_SEQ */
enum BPathTypes {
- BPATH_IMAGE = 0,
+ BPATH_IMAGE= 0,
+ BPATH_TEXTURE,
+ BPATH_TEXT,
BPATH_SOUND,
BPATH_FONT,
BPATH_LIB,
@@ -80,35 +111,39 @@
};
void BLI_bpathIterator_init( struct BPathIterator *bpi, const char *base_path ) {
- bpi->type = BPATH_IMAGE;
- bpi->data = NULL;
+ bpi->type= BPATH_IMAGE;
+ bpi->data= NULL;
- bpi->getpath_callback = NULL;
- bpi->setpath_callback = NULL;
+ bpi->getpath_callback= NULL;
+ bpi->setpath_callback= NULL;
/* Sequencer specific */
- bpi->seqdata.totseq = 0;
- bpi->seqdata.seq = 0;
- bpi->seqdata.seqar = NULL;
- bpi->seqdata.scene = NULL;
+ bpi->seqdata.totseq= 0;
+ bpi->seqdata.seq= 0;
+ bpi->seqdata.seqar= NULL;
+ bpi->seqdata.scene= NULL;
bpi->base_path= base_path ? base_path : G.main->name;
BLI_bpathIterator_step(bpi);
}
+void BLI_bpathIterator_alloc(struct BPathIterator **bpi) {
+ *bpi= MEM_mallocN(sizeof(BPathIterator), "BLI_bpathIterator_alloc");
+}
+
void BLI_bpathIterator_free( struct BPathIterator *bpi ) {
if (bpi->seqdata.seqar)
MEM_freeN((void *)bpi->seqdata.seqar);
- bpi->seqdata.seqar = NULL;
- bpi->seqdata.scene = NULL;
+ bpi->seqdata.seqar= NULL;
+ bpi->seqdata.scene= NULL;
}
void BLI_bpathIterator_getPath( struct BPathIterator *bpi, char *path) {
if (bpi->getpath_callback) {
bpi->getpath_callback( bpi, path );
} else {
- strcpy(path, bpi->path); /* warning, we assume 'path' are long enough */
+ strcpy(path, bpi->_path); /* warning, we assume 'path' are long enough */
}
}
@@ -116,7 +151,7 @@
if (bpi->setpath_callback) {
bpi->setpath_callback( bpi, path );
} else {
- strcpy(bpi->path, path); /* warning, we assume 'path' are long enough */
+ strcpy(bpi->_path, path); /* warning, we assume 'path' are long enough */
}
}
@@ -124,7 +159,7 @@
const char *libpath;
BLI_bpathIterator_getPath(bpi, path_expanded);
- libpath = BLI_bpathIterator_getLib(bpi);
+ libpath= BLI_bpathIterator_getLib(bpi);
if (libpath) { /* check the files location relative to its library path */
BLI_path_abs(path_expanded, libpath);
@@ -134,10 +169,10 @@
BLI_cleanup_file(NULL, path_expanded);
}
const char* BLI_bpathIterator_getLib( struct BPathIterator *bpi) {
- return bpi->lib;
+ return bpi->_lib;
}
const char* BLI_bpathIterator_getName( struct BPathIterator *bpi) {
- return bpi->name;
+ return bpi->_name;
}
int BLI_bpathIterator_getType( struct BPathIterator *bpi) {
return bpi->type;
@@ -145,6 +180,9 @@
int BLI_bpathIterator_getPathMaxLen( struct BPathIterator *bpi) {
return bpi->len;
}
+const char* BLI_bpathIterator_getBasePath( struct BPathIterator *bpi) {
+ return bpi->base_path;
+}
/* gets the first or the next image that has a path - not a viewer node or generated image */
static struct Image *ima_stepdata__internal(struct Image *ima, int step_next) {
@@ -152,23 +190,55 @@
return NULL;
if (step_next)
- ima = ima->id.next;
+ ima= ima->id.next;
while (ima) {
if (ima->packedfile==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
break;
/* image is not a image with a path, skip it */
- ima = ima->id.next;
+ ima= ima->id.next;
}
return ima;
}
+static struct Tex *tex_stepdata__internal(struct Tex *tex, int step_next) {
+ if (tex==NULL)
+ return NULL;
+
+ if (step_next)
+ tex= tex->id.next;
+
+ while (tex) {
+ if (tex->type == TEX_VOXELDATA && TEX_VD_IS_SOURCE_PATH(tex->vd->file_format))
+ break;
+ /* image is not a image with a path, skip it */
+ tex= tex->id.next;
+ }
+ return tex;
+}
+
+static struct Text *text_stepdata__internal(struct Text *text, int step_next) {
+ if (text==NULL)
+ return NULL;
+
+ if (step_next)
+ text= text->id.next;
+
+ while (text) {
+ if (text->name)
+ break;
+ /* image is not a image with a path, skip it */
+ text= text->id.next;
+ }
+ return text;
+}
+
static struct VFont *vf_stepdata__internal(struct VFont *vf, int step_next) {
if (vf==NULL)
return NULL;
if (step_next)
- vf = vf->id.next;
+ vf= vf->id.next;
while (vf) {
if (vf->packedfile==NULL && strcmp(vf->name, FO_BUILTIN_NAME)!=0) {
@@ -176,7 +246,7 @@
}
/* font with no path, skip it */
- vf = vf->id.next;
+ vf= vf->id.next;
}
return vf;
}
@@ -186,7 +256,7 @@
return NULL;
if (step_next)
- snd = snd->id.next;
+ snd= snd->id.next;
while (snd) {
if (snd->packedfile==NULL) {
@@ -194,7 +264,7 @@
}
/* font with no path, skip it */
- snd = snd->id.next;
+ snd= snd->id.next;
}
return snd;
}
@@ -219,20 +289,20 @@
if (bpi->seqdata.seqar == NULL) {
/* allocate the sequencer array */
seq_array(ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq, 0);
- bpi->seqdata.seq = 0;
+ bpi->seqdata.seq= 0;
}
if (bpi->seqdata.seq >= bpi->seqdata.totseq) {
- seq = NULL;
+ seq= NULL;
} else {
- seq = bpi->seqdata.seqar[bpi->seqdata.seq];
- while (!SEQ_HAS_PATH(seq)) {
+ seq= bpi->seqdata.seqar[bpi->seqdata.seq];
+ while (!SEQ_HAS_PATH(seq) && seq->plugin==NULL) {
bpi->seqdata.seq++;
if (bpi->seqdata.seq >= bpi->seqdata.totseq) {
- seq = NULL;
+ seq= NULL;
break;
}
- seq = bpi->seqdata.seqar[bpi->seqdata.seq];
+ seq= bpi->seqdata.seqar[bpi->seqdata.seq];
}
}
if (seq) {
@@ -241,13 +311,13 @@
/* keep looking through the next scene, reallocate seq array */
if (bpi->seqdata.seqar) {
MEM_freeN((void *)bpi->seqdata.seqar);
- bpi->seqdata.seqar = NULL;
+ bpi->seqdata.seqar= NULL;
}
- bpi->seqdata.scene = bpi->seqdata.scene->id.next;
+ bpi->seqdata.scene= bpi->seqdata.scene->id.next;
}
} else {
/* no seq data in this scene, next */
- bpi->seqdata.scene = bpi->seqdata.scene->id.next;
+ bpi->seqdata.scene= bpi->seqdata.scene->id.next;
}
}
@@ -255,10 +325,10 @@
}
static void seq_getpath(struct BPathIterator *bpi, char *path) {
- Sequence *seq = (Sequence *)bpi->data;
+ Sequence *seq= (Sequence *)bpi->data;
- path[0] = '\0'; /* incase we cant get the path */
+ path[0]= '\0'; /* incase we cant get the path */
if (seq==NULL) return;
if (SEQ_HAS_PATH(seq)) {
if (ELEM3(seq->type, SEQ_IMAGE, SEQ_MOVIE, SEQ_SOUND)) {
@@ -268,56 +338,87 @@
/* Using the first image is weak for image sequences */
strcat(path, seq->strip->stripdata->name);
}
- } else {
+ }
+ else {
/* simple case */
BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir));
}
}
+ else if (seq->plugin) {
+ BLI_strncpy(seq->plugin->name, path, sizeof(seq->plugin->name));
+ }
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list