Fix T72214: Fluids: noise does not work with negative frame numbers

The issue is duplicated code. There are two functions that zero-fill
the frame number. They worked the same for positive frames numbers, but
behaved differently for negative ones.

On frame `-100`, `BLI_path_frame` outputs `-0100` and
`fluid_cache_get_framenr_formatted_$ID$` outputted `-100`.

I changed the behavior of the latter, because we depend on the behavior
of the former for much longer already.

Reviewers: sebbas

Differential Revision: https://developer.blender.org/D8107
This commit is contained in:
2020-07-03 15:27:02 +02:00
parent 2633683b52
commit 1e255ce031
2 changed files with 17 additions and 1 deletions

View File

@@ -502,10 +502,12 @@ gc.collect()\n";
// BAKE
//////////////////////////////////////////////////////////////////////
/* This has to match the behavior of BLI_path_frame,
* for positive and negative frame numbers. */
const std::string fluid_cache_helper =
"\n\
def fluid_cache_get_framenr_formatted_$ID$(framenr):\n\
return str(framenr).zfill(4) # framenr with leading zeroes\n";
return str(framenr).zfill(4) if framenr >= 0 else str(framenr).zfill(5)\n";
const std::string fluid_bake_multiprocessing =
"\n\

View File

@@ -408,6 +408,20 @@ TEST(path_util, Frame)
EXPECT_FALSE(ret);
EXPECT_STREQ("test_middle", path);
}
/* negative frame numbers */
{
char path[FILE_MAX] = "test_####";
ret = BLI_path_frame(path, -1, 4);
EXPECT_TRUE(ret);
EXPECT_STREQ("test_-0001", path);
}
{
char path[FILE_MAX] = "test_####";
ret = BLI_path_frame(path, -100, 4);
EXPECT_TRUE(ret);
EXPECT_STREQ("test_-0100", path);
}
}
/* BLI_split_dirfile */