Cleanup: Alembic, use a structure to pass parameters
This adds a structure, `ABCReadParams`, to store some parameters passed to `ABC_read_mesh` so we avoid passing too many parameters, and makes it easier to add more parameters in the future without worrying about argument order. Differential Revision: https://developer.blender.org/D14484
This commit is contained in:
parent
45f30543db
commit
66dc4d4efb
@ -99,15 +99,19 @@ void ABC_get_transform(struct CacheReader *reader,
|
||||
double time,
|
||||
float scale);
|
||||
|
||||
typedef struct ABCReadParams {
|
||||
double time;
|
||||
int read_flags;
|
||||
const char *velocity_name;
|
||||
float velocity_scale;
|
||||
} ABCReadParams;
|
||||
|
||||
/* Either modifies existing_mesh in-place or constructs a new mesh. */
|
||||
struct Mesh *ABC_read_mesh(struct CacheReader *reader,
|
||||
struct Object *ob,
|
||||
struct Mesh *existing_mesh,
|
||||
double time,
|
||||
const char **err_str,
|
||||
int read_flags,
|
||||
const char *velocity_name,
|
||||
float velocity_scale);
|
||||
const ABCReadParams *params,
|
||||
const char **err_str);
|
||||
|
||||
bool ABC_mesh_topology_changed(struct CacheReader *reader,
|
||||
struct Object *ob,
|
||||
|
@ -785,20 +785,21 @@ static ISampleSelector sample_selector_for_time(chrono_t time)
|
||||
Mesh *ABC_read_mesh(CacheReader *reader,
|
||||
Object *ob,
|
||||
Mesh *existing_mesh,
|
||||
const double time,
|
||||
const char **err_str,
|
||||
const int read_flag,
|
||||
const char *velocity_name,
|
||||
const float velocity_scale)
|
||||
const ABCReadParams *params,
|
||||
const char **err_str)
|
||||
{
|
||||
AbcObjectReader *abc_reader = get_abc_reader(reader, ob, err_str);
|
||||
if (abc_reader == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ISampleSelector sample_sel = sample_selector_for_time(time);
|
||||
return abc_reader->read_mesh(
|
||||
existing_mesh, sample_sel, read_flag, velocity_name, velocity_scale, err_str);
|
||||
ISampleSelector sample_sel = sample_selector_for_time(params->time);
|
||||
return abc_reader->read_mesh(existing_mesh,
|
||||
sample_sel,
|
||||
params->read_flags,
|
||||
params->velocity_name,
|
||||
params->velocity_scale,
|
||||
err_str);
|
||||
}
|
||||
|
||||
bool ABC_mesh_topology_changed(CacheReader *reader,
|
||||
|
@ -226,14 +226,13 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
||||
velocity_scale *= FPS;
|
||||
}
|
||||
|
||||
result = ABC_read_mesh(mcmd->reader,
|
||||
ctx->object,
|
||||
mesh,
|
||||
time,
|
||||
&err_str,
|
||||
mcmd->read_flag,
|
||||
mcmd->cache_file->velocity_name,
|
||||
velocity_scale);
|
||||
ABCReadParams params = {};
|
||||
params.time = time;
|
||||
params.read_flags = mcmd->read_flag;
|
||||
params.velocity_name = mcmd->cache_file->velocity_name;
|
||||
params.velocity_scale = velocity_scale;
|
||||
|
||||
result = ABC_read_mesh(mcmd->reader, ctx->object, mesh, ¶ms, &err_str);
|
||||
# endif
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user