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:
authorCampbell Barton <ideasman42@gmail.com>2008-04-11 19:47:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-04-11 19:47:21 +0400
commitf057a38e985fe4db1c57f48864624985a31c9235 (patch)
treec9383d4b2727434e3971096ac8ea4101a84ac89b /source
parenta02937d86ccb30f0cc08ef451634595fb45726c6 (diff)
Changed BLI_convertstringcode to replace any number of hashes with the frame number.
somefile_##.png -> somefile_01.png somefile_########-image.png -> somefile_00000001-image.png Before, A hash at the end of the string would be replaced by a number with 4 characters. This is still default if no #'s are in the string, so nothing has changed. To use this function from the python api use scene.render.getFrameFilename()
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c4
-rw-r--r--source/blender/blenkernel/intern/effect.c2
-rw-r--r--source/blender/blenkernel/intern/image.c18
-rw-r--r--source/blender/blenkernel/intern/particle_system.c2
-rw-r--r--source/blender/blenlib/intern/util.c56
-rw-r--r--source/blender/src/buttons_scene.c6
-rw-r--r--source/blender/src/sequence.c4
7 files changed, 64 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 7624ca04984..464f851b683 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -3312,9 +3312,9 @@ void loadFluidsimMesh(Object *srcob, int useRenderParams)
srcob->data = srcob->fluidsimSettings->orgMesh;
return;
} else if(displaymode==2) {
- strcat(targetDir,"fluidsurface_preview_#");
+ strcat(targetDir,"fluidsurface_preview_####");
} else { // 3
- strcat(targetDir,"fluidsurface_final_#");
+ strcat(targetDir,"fluidsurface_final_####");
}
BLI_convertstringcode(targetDir, G.sce, curFrame); // fixed #frame-no
strcpy(targetFile,targetDir);
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index bb228a67381..f07326f995f 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -1711,7 +1711,7 @@ void build_particle_system(Object *ob)
if( (1) && (ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) && // broken, disabled for now!
(ob->fluidsimSettings) &&
(ob->fluidsimSettings->type == OB_FLUIDSIM_PARTICLE)) {
- char *suffix = "fluidsurface_particles_#";
+ char *suffix = "fluidsurface_particles_####";
char *suffix2 = ".gz";
char filename[256];
char debugStrBuffer[256];
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 195f4aa4bbf..3f885017f95 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1236,24 +1236,16 @@ int BKE_write_ibuf(ImBuf *ibuf, char *name, int imtype, int subimtype, int quali
void BKE_makepicstring(char *string, char *base, int frame, int imtype)
{
- short i, len, digits= 4; /* digits in G.scene? */
- char num[10];
-
if (string==NULL) return;
BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */
+
+ /* if we dont have any #'s to insert numbers into, use 4 numbers by default */
+ if (strchr(string, '#')==NULL)
+ strcat(string, "####"); /* 4 numbers */
+
BLI_convertstringcode(string, G.sce, frame);
- len= strlen(string);
-
- i= digits - sprintf(num, "%d", frame);
- for(; i>0; i--){
- string[len]= '0';
- len++;
- }
- string[len]= 0;
- strcat(string, num);
-
if(G.scene->r.scemode & R_EXTENSION)
BKE_add_image_extension(string, imtype);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index ebde51d4c3d..602c13008df 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4552,7 +4552,7 @@ static void particles_fluid_step(Object *ob, ParticleSystem *psys, int cfra)
(ob->fluidsimSettings)) {
ParticleSettings *part = psys->part;
ParticleData *pa=0;
- char *suffix = "fluidsurface_particles_#";
+ char *suffix = "fluidsurface_particles_####";
char *suffix2 = ".gz";
char filename[256];
char debugStrBuffer[256];
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index 6d8dd3d9b50..46bb1eb0104 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -41,6 +41,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <math.h> /* for log10 */
#include "MEM_guardedalloc.h"
@@ -1027,7 +1028,8 @@ void BLI_makestringcode(const char *relfile, char *file)
int BLI_convertstringcode(char *path, const char *basepath, int framenum)
{
- int len, wasrelative;
+ int wasrelative;
+ int ch_sta, ch_end;
char tmp[FILE_MAX];
char base[FILE_MAX];
char vol[3] = {'\0', '\0', '\0'};
@@ -1082,12 +1084,54 @@ int BLI_convertstringcode(char *path, const char *basepath, int framenum)
MEM_freeN(filepart);
}
-
- len= strlen(tmp);
- if(len && tmp[len-1]=='#') {
- sprintf(tmp+len-1, "%04d", framenum);
+
+
+ /* Insert current frame: file### -> file001 */
+ ch_end = 0;
+ for (ch_sta = 0; tmp[ch_sta] != '\0'; ch_sta++) {
+ if (tmp[ch_sta] == '#') {
+ ch_end = ch_sta+1;
+ while (tmp[ch_end] == '#') {
+ ch_end++;
+ }
+ break;
+ }
}
-
+ if (ch_end) { /* warning, ch_end is the last # +1 */
+ /* Add the frame number? */
+ short numlen, hashlen;
+ char format[16]; /* 6 is realistically the maxframe (300000), so 8 should be enough, but 16 to be safe. */
+
+ numlen = 1 + (int)log10((double)framenum); /* this is the number of chars in the number */
+ hashlen = ch_end - ch_sta;
+
+ sprintf(format, "%d", framenum);
+
+ if (numlen==hashlen) { /* simple case */
+ memcpy(tmp+ch_sta, format, numlen);
+ } else if (numlen < hashlen) {
+ memcpy(tmp+ch_sta + (hashlen-numlen), format, numlen); /*dont copy the string terminator */
+ memset(tmp+ch_sta, '0', hashlen-numlen);
+ } else {
+ /* number is longer then number of #'s */
+ if (tmp[ch_end] == '\0') { /* hashes are last, no need to move any string*/
+ /* bad juju - not testing string length here :/ */
+ memcpy(tmp+ch_sta, format, numlen+1); /* add 1 to get the string terminator \0 */
+ } else {
+ /* we need to move the end characters */
+ int i = strlen(tmp); /* +1 to copy the string terminator */
+ int j = i + (numlen-hashlen); /* from/to */
+ while (i >= ch_end) {
+ tmp[j] = tmp[i];
+ i--;
+ j--;
+ }
+ memcpy(tmp + ch_sta, format, numlen);
+ }
+ }
+ }
+ /* done with file### stuff */
+
strcpy(path, tmp);
#ifdef WIN32
/* skip first two chars, which in case of
diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c
index 0228754b599..a2678829fc3 100644
--- a/source/blender/src/buttons_scene.c
+++ b/source/blender/src/buttons_scene.c
@@ -1998,9 +1998,9 @@ static void render_panel_output(void)
if(uiNewPanel(curarea, block, "Output", "Render", 0, 0, 318, 204)==0) return;
uiBlockBeginAlign(block);
- uiDefIconBut(block, BUT, B_FS_PIC, ICON_FILESEL, 10, 190, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Pics dir/name");
- uiDefBut(block, TEX,0,"", 31, 190, 279, 20,G.scene->r.pic, 0.0,79.0, 0, 0, "Directory/name to save rendered Pics to");
- uiDefIconBut(block, BUT,B_FS_BACKBUF, ICON_FILESEL, 10, 168, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Backbuf image");
+ uiDefIconBut(block, BUT, B_FS_PIC, ICON_FILESEL, 10, 190, 20, 20, 0, 0, 0, 0, 0, "Select the directory/name for saving animations");
+ uiDefBut(block, TEX,0,"", 31, 190, 279, 20,G.scene->r.pic, 0.0,79.0, 0, 0, "Directory/name to save animations, # characters defines the position and length of frame numbers");
+ uiDefIconBut(block, BUT,B_FS_BACKBUF, ICON_FILESEL, 10, 168, 20, 20, 0, 0, 0, 0, 0, "Select the directory/name for a Backbuf image");
uiDefBut(block, TEX,0,"", 31, 168, 279, 20,G.scene->r.backbuf, 0.0,79.0, 0, 0, "Image to use as background for rendering");
uiBlockEndAlign(block);
diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c
index 9e6f1996e75..61e44630493 100644
--- a/source/blender/src/sequence.c
+++ b/source/blender/src/sequence.c
@@ -1059,7 +1059,7 @@ static int seq_proxy_get_fname(Sequence * seq, int cfra, char * name)
frameno = tse->nr + seq->anim_startofs;
- snprintf(name, PROXY_MAXFILE, "%s/%s/%d/#", dir,
+ snprintf(name, PROXY_MAXFILE, "%s/%s/%d/####", dir,
seq->strip->stripdata->name,
G.scene->r.size);
} else {
@@ -1067,7 +1067,7 @@ static int seq_proxy_get_fname(Sequence * seq, int cfra, char * name)
frameno = tse->nr + seq->anim_startofs;
- snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/#", dir,
+ snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir,
G.scene->r.size);
}