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:
authorArystanbek Dyussenov <arystan.d@gmail.com>2009-09-22 20:35:07 +0400
committerArystanbek Dyussenov <arystan.d@gmail.com>2009-09-22 20:35:07 +0400
commitabb49829ef6bdc7385e51a00a3e2d5402dc09155 (patch)
treeec2e14a06da5d24fab7863ea249e899f11f3594c /source/blender/blenkernel
parentd86864027d449114868ec531b9ccf6dd19dbe67f (diff)
parent816377cc02fe5dd4be945c0f3d415861114b4980 (diff)
Manual merge of soc-2009-kazanbas branch:
* copied I/O scripts * copied, modified rna_*_api.c and rna_*.c I/O scripts not working yet due to slight BPY differences and RNA changes. Will fix them later. Not merged changes: * C unit testing integration, because it is clumsy * scons cross-compiling, can be merged easily later
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_anim.h9
-rw-r--r--source/blender/blenkernel/intern/image.c100
-rw-r--r--source/blender/blenkernel/intern/mesh.c3
3 files changed, 103 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index 4b1e758da54..32c5ff81740 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -39,14 +39,7 @@ struct PartEff;
struct Scene;
struct ListBase;
-typedef struct DupliObject {
- struct DupliObject *next, *prev;
- struct Object *ob;
- unsigned int origlay;
- int index, no_draw, type, animated;
- float mat[4][4], omat[4][4];
- float orco[3], uv[2];
-} DupliObject;
+#include "DNA_object_types.h"
void free_path(struct Path *path);
void calc_curvepath(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index e955f10f3e3..9953540bbcf 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2175,3 +2175,103 @@ void BKE_image_user_calc_imanr(ImageUser *iuser, int cfra, int fieldnr)
}
}
+/*
+ Produce image export path.
+
+ Fails returning 0 if image filename is empty or if destination path
+ matches image path (i.e. both are the same file).
+
+ Trailing slash in dest_dir is optional.
+
+ Logic:
+
+ - if an image is "below" current .blend file directory, rebuild the
+ same dir structure in dest_dir
+
+ For example //textures/foo/bar.png becomes
+ [dest_dir]/textures/foo/bar.png.
+
+ - if an image is not "below" current .blend file directory,
+ disregard it's path and copy it in the same directory where 3D file
+ goes.
+
+ For example //../foo/bar.png becomes [dest_dir]/bar.png.
+
+ This logic will help ensure that all image paths are relative and
+ that a user gets his images in one place. It'll also provide
+ consistent behaviour across exporters.
+ */
+int BKE_get_image_export_path(struct Image *im, const char *dest_dir, char *abs, int abs_size, char *rel, int rel_size)
+{
+ char path[FILE_MAX];
+ char dir[FILE_MAX];
+ char base[FILE_MAX];
+ char blend_dir[FILE_MAX]; /* directory, where current .blend file resides */
+ char dest_path[FILE_MAX];
+ char rel_dir[FILE_MAX];
+ int len;
+
+ if (abs)
+ abs[0]= 0;
+
+ if (rel)
+ rel[0]= 0;
+
+ BLI_split_dirfile_basic(G.sce, blend_dir, NULL);
+
+ if (!strlen(im->name)) {
+ if (G.f & G_DEBUG) printf("Invalid image type.\n");
+ return 0;
+ }
+
+ BLI_strncpy(path, im->name, sizeof(path));
+
+ /* expand "//" in filename and get absolute path */
+ BLI_convertstringcode(path, G.sce);
+
+ /* get the directory part */
+ BLI_split_dirfile_basic(path, dir, base);
+
+ len= strlen(blend_dir);
+
+ rel_dir[0] = 0;
+
+ /* if image is "below" current .blend file directory */
+ if (!strncmp(path, blend_dir, len)) {
+
+ /* if image is _in_ current .blend file directory */
+ if (!strcmp(dir, blend_dir)) {
+ BLI_join_dirfile(dest_path, dest_dir, base);
+ }
+ /* "below" */
+ else {
+ /* rel = image_path_dir - blend_dir */
+ BLI_strncpy(rel_dir, dir + len, sizeof(rel_dir));
+
+ BLI_join_dirfile(dest_path, dest_dir, rel_dir);
+ BLI_join_dirfile(dest_path, dest_path, base);
+ }
+
+ }
+ /* image is out of current directory */
+ else {
+ BLI_join_dirfile(dest_path, dest_dir, base);
+ }
+
+ if (abs)
+ BLI_strncpy(abs, dest_path, abs_size);
+
+ if (rel) {
+ strncat(rel, rel_dir, rel_size);
+ strncat(rel, base, rel_size);
+ }
+
+ /* return 2 if src=dest */
+ if (!strcmp(path, dest_path)) {
+ if (G.f & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path);
+ return 2;
+ }
+
+ return 1;
+}
+
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index c92eda6d169..431543f8dbd 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -542,7 +542,8 @@ void set_mesh(Object *ob, Mesh *me)
if(ob->type==OB_MESH) {
old= ob->data;
- old->id.us--;
+ if (old)
+ old->id.us--;
ob->data= me;
id_us_plus((ID *)me);
}