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:
Kévin Dietrich 2022-04-14 17:48:31 +02:00
parent 45f30543db
commit 66dc4d4efb
Notes: blender-bot 2023-02-13 15:18:47 +01:00
Referenced by issue #98538, Geometry input node breaks after adding Displacement Texture in Shader Editor
3 changed files with 25 additions and 21 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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, &params, &err_str);
# endif
break;
}