Refactor: move default initialization of USDExportParams to definition

Matching the default file export settings.
This commit is contained in:
Brecht Van Lommel
2023-08-05 17:01:22 +02:00
parent 288fe44d4c
commit 6e4b1f78cd
5 changed files with 29 additions and 33 deletions

View File

@@ -44,19 +44,11 @@ USDSceneDelegate::~USDSceneDelegate()
void USDSceneDelegate::populate(Depsgraph *depsgraph)
{
USDExportParams params = {};
params.export_hair = true;
params.export_uvmaps = true;
params.export_normals = true;
params.export_materials = true;
params.selected_objects_only = false;
params.visible_objects_only = true;
USDExportParams params;
params.use_instancing = true;
params.relative_paths = false; /* Unnecessary. */
params.export_textures = false; /* Don't copy all textures, is slow. */
params.evaluation_mode = DEG_get_mode(depsgraph);
params.generate_preview_surface = true;
params.export_textures = true;
params.overwrite_textures = true;
params.relative_paths = true;
/* Create clean directory for export. */
BLI_delete(temp_dir_.c_str(), true, true);

View File

@@ -109,7 +109,7 @@ TEST_F(UsdCurvesTest, usd_export_curves)
/* File sanity check. */
EXPECT_EQ(BLI_listbase_count(&bfile->main->objects), 6);
USDExportParams params{};
USDExportParams params;
const bool result = USD_export(context, output_filename.c_str(), &params, false);
EXPECT_TRUE(result) << "USD export should succed.";

View File

@@ -209,10 +209,11 @@ TEST_F(UsdExportTest, usd_export_rain_mesh)
/* File sanity check. */
EXPECT_EQ(BLI_listbase_count(&bfile->main->objects), 3);
USDExportParams params{};
USDExportParams params;
params.export_materials = false;
params.export_normals = true;
params.export_uvmaps = false;
params.visible_objects_only = true;
params.evaluation_mode = eEvaluationMode::DAG_EVAL_VIEWPORT;
bool result = USD_export(context, output_filename.c_str(), &params, false);
ASSERT_TRUE(result) << "Writing to " << output_filename << " failed!";
@@ -272,12 +273,13 @@ TEST_F(UsdExportTest, usd_export_material)
EXPECT_TRUE(bool(material));
USDExportParams params{};
params.export_normals = true;
USDExportParams params;
params.export_materials = true;
params.generate_preview_surface = true;
params.export_normals = true;
params.export_textures = false;
params.export_uvmaps = true;
params.evaluation_mode = eEvaluationMode::DAG_EVAL_VIEWPORT;
params.generate_preview_surface = true;
params.relative_paths = false;
const bool result = USD_export(context, output_filename.c_str(), &params, false);
ASSERT_TRUE(result) << "Unable to export stage to " << output_filename;

View File

@@ -94,7 +94,9 @@ TEST_F(UsdUsdzExportTest, usdz_export)
<< "BLI_current_working_dir is not expected to return a different value than the given char "
"buffer.";
USDExportParams params{};
USDExportParams params;
params.export_materials = false;
params.visible_objects_only = false;
bool result = USD_export(context, output_filepath, &params, false);
ASSERT_TRUE(result) << "usd export to " << output_filepath << " failed.";

View File

@@ -38,20 +38,20 @@ typedef enum eUSDTexNameCollisionMode {
} eUSDTexNameCollisionMode;
struct USDExportParams {
bool export_animation;
bool export_hair;
bool export_uvmaps;
bool export_normals;
bool export_materials;
bool selected_objects_only;
bool visible_objects_only;
bool use_instancing;
enum eEvaluationMode evaluation_mode;
bool generate_preview_surface;
bool export_textures;
bool overwrite_textures;
bool relative_paths;
char root_prim_path[1024]; /* FILE_MAX */
bool export_animation = false;
bool export_hair = true;
bool export_uvmaps = true;
bool export_normals = true;
bool export_materials = true;
bool selected_objects_only = false;
bool visible_objects_only = true;
bool use_instancing = false;
enum eEvaluationMode evaluation_mode = DAG_EVAL_VIEWPORT;
bool generate_preview_surface = true;
bool export_textures = true;
bool overwrite_textures = true;
bool relative_paths = true;
char root_prim_path[1024] = ""; /* FILE_MAX */
};
struct USDImportParams {