diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-20 18:38:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-20 18:38:11 +0400 |
commit | f1eb66aa68105ac27f371f4f708d8abf3b7da38b (patch) | |
tree | 77ce3c813f25702880e330740e06ae60a0aadca8 /source/blender/blenkernel/intern/modifier.c | |
parent | be701c7336a3f967a3a2807f8a7a0c511cb76815 (diff) |
share code for fluidsim, ocean & dynamic paint file paths.
- use BLI_join_dirfile for joining all paths (no need to ensure slash is appended).
- paths from linked library files now supported.
Diffstat (limited to 'source/blender/blenkernel/intern/modifier.c')
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index bbc1b596889..f09be8c34ad 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -60,6 +60,11 @@ #include "BKE_key.h" #include "BKE_multires.h" +/* may move these, only for modifier_path_relbase */ +#include "BKE_global.h" /* ugh, G.main->name only */ +#include "BKE_main.h" +/* end */ + #include "MOD_modifiertypes.h" ModifierTypeInfo *modifierType_getInfo(ModifierType type) @@ -573,3 +578,36 @@ void test_object_modifiers(Object *ob) } } } + +/* where should this go?, it doesnt fit well anywhere :S - campbell */ + +/* elubie: changed this to default to the same dir as the render output + * to prevent saving to C:\ on Windows */ + +/* campbell: logic behind this... + * + * - if the ID is from a library, return library path + * - else if the file has been saved return the blend file path. + * - else if the file isn't saved and the ID isnt from a library, return the temp dir. + */ +const char *modifier_path_relbase(Object *ob) +{ + if (G.relbase_valid || ob->id.lib) { + return ID_BLEND_PATH(G.main, &ob->id); + } + else { + /* last resort, better then using "" which resolves to the current + * working directory */ + return BLI_temporary_dir(); + } +} + +/* initializes the path with either */ +void modifier_path_init(char *path, int path_maxlen, const char *name) +{ + /* elubie: changed this to default to the same dir as the render output + * to prevent saving to C:\ on Windows */ + BLI_join_dirfile(path, path_maxlen, + G.relbase_valid ? "//" : BLI_temporary_dir(), + name); +} |