Cleanup: replace the use of listbase in io_alembic.cc with vector #108686
|
@ -29,10 +29,10 @@
|
|||
# include "BKE_main.h"
|
||||
# include "BKE_report.h"
|
||||
|
||||
# include "BLI_listbase.h"
|
||||
# include "BLI_path_util.h"
|
||||
# include "BLI_string.h"
|
||||
# include "BLI_utildefines.h"
|
||||
# include "BLI_vector.hh"
|
||||
|
||||
# include "BLT_translation.h"
|
||||
|
||||
|
@ -477,20 +477,6 @@ struct CacheFrame {
|
|||
int framenr;
|
||||
};
|
||||
|
||||
static int cmp_frame(const void *a, const void *b)
|
||||
{
|
||||
const CacheFrame *frame_a = static_cast<const CacheFrame *>(a);
|
||||
const CacheFrame *frame_b = static_cast<const CacheFrame *>(b);
|
||||
|
||||
if (frame_a->framenr < frame_b->framenr) {
|
||||
return -1;
|
||||
}
|
||||
if (frame_a->framenr > frame_b->framenr) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_sequence_len(const char *filepath, int *ofs)
|
||||
{
|
||||
int frame;
|
||||
|
@ -524,8 +510,7 @@ static int get_sequence_len(const char *filepath, int *ofs)
|
|||
const char *basename = BLI_path_basename(filepath);
|
||||
const int len = strlen(basename) - (numdigit + strlen(ext));
|
||||
|
||||
ListBase frames{};
|
||||
BLI_listbase_clear(&frames);
|
||||
blender::Vector<CacheFrame> frames;
|
||||
|
||||
dirent *fname;
|
||||
while ((fname = readdir(dir)) != nullptr) {
|
||||
|
@ -538,34 +523,34 @@ static int get_sequence_len(const char *filepath, int *ofs)
|
|||
continue;
|
||||
}
|
||||
|
||||
CacheFrame *cache_frame = MEM_cnew<CacheFrame>("abc_frame");
|
||||
CacheFrame cache_frame{};
|
||||
|
||||
BLI_path_frame_get(fname->d_name, &cache_frame->framenr, &numdigit);
|
||||
BLI_path_frame_get(fname->d_name, &cache_frame.framenr, &numdigit);
|
||||
|
||||
BLI_addtail(&frames, cache_frame);
|
||||
frames.append(cache_frame);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
BLI_listbase_sort(&frames, cmp_frame);
|
||||
std::sort(frames.begin(), frames.end(), [](const CacheFrame &a, const CacheFrame &b) {
|
||||
return a.framenr < b.framenr;
|
||||
});
|
||||
|
||||
CacheFrame *cache_frame = static_cast<CacheFrame *>(frames.first);
|
||||
|
||||
if (cache_frame != nullptr) {
|
||||
int frame_curr = cache_frame->framenr;
|
||||
(*ofs) = frame_curr;
|
||||
|
||||
while (cache_frame && (cache_frame->framenr == frame_curr)) {
|
||||
frame_curr++;
|
||||
cache_frame = cache_frame->next;
|
||||
}
|
||||
|
||||
BLI_freelistN(&frames);
|
||||
|
||||
return frame_curr - (*ofs);
|
||||
if (frames.is_empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
int frame_curr = frames.first().framenr;
|
||||
(*ofs) = frame_curr;
|
||||
|
||||
for (CacheFrame &cache_frame : frames) {
|
||||
if (cache_frame.framenr != frame_curr) {
|
||||
break;
|
||||
}
|
||||
frame_curr++;
|
||||
}
|
||||
|
||||
return frame_curr - (*ofs);
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
|
Loading…
Reference in New Issue