[Bf-blender-cvs] [010680c] alembic_basic_io: Consolidate alembic export options into a struct

Campbell Barton noreply at git.blender.org
Thu Jul 21 02:02:55 CEST 2016


Commit: 010680cd9c66fb5cc8ba452ddf8fd9e514708288
Author: Campbell Barton
Date:   Thu Jul 21 10:03:16 2016 +1000
Branches: alembic_basic_io
https://developer.blender.org/rB010680cd9c66fb5cc8ba452ddf8fd9e514708288

Consolidate alembic export options into a struct

Having 15+ args gets unmanageable.

===================================================================

M	source/blender/alembic/ABC_alembic.h
M	source/blender/alembic/intern/abc_exporter.cc
M	source/blender/alembic/intern/abc_exporter.h
M	source/blender/alembic/intern/abc_mesh.cc
M	source/blender/alembic/intern/alembic_capi.cc
M	source/blender/editors/io/io_alembic.c
M	source/blender/makesrna/intern/rna_scene_api.c

===================================================================

diff --git a/source/blender/alembic/ABC_alembic.h b/source/blender/alembic/ABC_alembic.h
index 940793f..bb735b1 100644
--- a/source/blender/alembic/ABC_alembic.h
+++ b/source/blender/alembic/ABC_alembic.h
@@ -42,29 +42,38 @@ enum {
 
 int ABC_get_version(void);
 
+struct AlembicExportParams {
+	double frame_start;
+	double frame_end;
+
+	double frame_step_xform;
+	double frame_step_shape;
+
+	double shutter_open;
+	double shutter_close;
+
+	/* bools */
+	unsigned int selected_only : 1;
+	unsigned int uvs : 1;
+	unsigned int normals : 1;
+	unsigned int vcolors : 1;
+	unsigned int apply_subdiv : 1;
+	unsigned int flatten_hierarchy : 1;
+	unsigned int visible_layers_only : 1;
+	unsigned int renderable_only : 1;
+	unsigned int face_sets : 1;
+	unsigned int use_subdiv_schema : 1;
+	unsigned int packuv : 1;
+
+	unsigned int compression_type : 1;
+	float global_scale;
+};
+
 void ABC_export(
         struct Scene *scene,
         struct bContext *C,
         const char *filepath,
-        const double start,
-        const double end,
-        const double xformstep,
-        const double geomstep,
-        const double shutter_open,
-        const double shutter_close,
-        const bool selected_only,
-        const bool uvs,
-        const bool normals,
-        const bool vcolors,
-        const bool apply_subdiv,
-        const bool flatten_hierarchy,
-        const bool vislayers,
-        const bool renderable,
-        const bool facesets,
-        const bool use_subdiv_schema,
-        const bool compression,
-        const bool packuv,
-        const float global_scale);
+        const struct AlembicExportParams *params);
 
 void ABC_import(struct bContext *C,
                 const char *filepath,
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc
index a018425..127e885 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -73,10 +73,10 @@ ExportSettings::ExportSettings()
     , selected_only(false)
     , visible_layers_only(false)
     , renderable_only(false)
-    , startframe(1)
-    , endframe(1)
-    , xform_frame_step(1)
-    , shape_frame_step(1)
+    , frame_start(1)
+    , frame_end(1)
+    , frame_step_xform(1)
+    , frame_step_shape(1)
     , shutter_open(0.0)
     , shutter_close(1.0)
     , global_scale(1.0f)
@@ -194,7 +194,7 @@ Alembic::Abc::TimeSamplingPtr AbcExporter::createTimeSampling(double step)
 	TimeSamplingPtr time_sampling;
 	std::vector<double> samples;
 
-	if (m_settings.startframe == m_settings.endframe) {
+	if (m_settings.frame_start == m_settings.frame_end) {
 		time_sampling.reset(new Alembic::Abc::TimeSampling());
 		return time_sampling;
 	}
@@ -215,7 +215,7 @@ void AbcExporter::getFrameSet(double step, std::set<double> &frames)
 
 	getShutterSamples(step, false, shutter_samples);
 
-	for (int frame = m_settings.startframe; frame <= m_settings.endframe; ++frame) {
+	for (int frame = m_settings.frame_start; frame <= m_settings.frame_end; ++frame) {
 		for (int j = 0, e = shutter_samples.size(); j < e; ++j) {
 			frames.insert(frame + shutter_samples[j]);
 		}
@@ -268,20 +268,20 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
 
 	/* Create time samplings for transforms and shapes. */
 
-	TimeSamplingPtr trans_time = createTimeSampling(m_settings.xform_frame_step);
+	TimeSamplingPtr trans_time = createTimeSampling(m_settings.frame_step_xform);
 
 	m_trans_sampling_index = m_archive.addTimeSampling(*trans_time);
 
 	TimeSamplingPtr shape_time;
 
-	if ((m_settings.shape_frame_step == m_settings.xform_frame_step) ||
-	    (m_settings.startframe == m_settings.endframe))
+	if ((m_settings.frame_step_shape == m_settings.frame_step_xform) ||
+	    (m_settings.frame_start == m_settings.frame_end))
 	{
 		shape_time = trans_time;
 		m_shape_sampling_index = m_trans_sampling_index;
 	}
 	else {
-		shape_time = createTimeSampling(m_settings.shape_frame_step);
+		shape_time = createTimeSampling(m_settings.frame_step_shape);
 		m_shape_sampling_index = m_archive.addTimeSampling(*shape_time);
 	}
 
@@ -299,10 +299,10 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
 	/* Make a list of frames to export. */
 
 	std::set<double> xform_frames;
-	getFrameSet(m_settings.xform_frame_step, xform_frames);
+	getFrameSet(m_settings.frame_step_xform, xform_frames);
 
 	std::set<double> shape_frames;
-	getFrameSet(m_settings.shape_frame_step, shape_frames);
+	getFrameSet(m_settings.frame_step_shape, shape_frames);
 
 	/* Merge all frames needed. */
 
diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h
index 2b5fb94..070eb9e 100644
--- a/source/blender/alembic/intern/abc_exporter.h
+++ b/source/blender/alembic/intern/abc_exporter.h
@@ -45,9 +45,9 @@ struct ExportSettings {
 	bool visible_layers_only;
 	bool renderable_only;
 
-	double startframe, endframe;
-	double xform_frame_step;
-	double shape_frame_step;
+	double frame_start, frame_end;
+	double frame_step_xform;
+	double frame_step_shape;
 	double shutter_open;
 	double shutter_close;
 	float global_scale;
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index e1b9db8..83c7eba 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -473,7 +473,7 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm)
 	get_creases(dm, crease_indices, crease_lengths, crease_sharpness);
 
 	if (m_first_frame) {
-		/* create materials' facesets */
+		/* create materials' face_sets */
 		writeCommonData(dm, m_subdiv_schema);
 	}
 
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 7ff0321..d7a1500 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -357,25 +357,7 @@ void ABC_export(
         Scene *scene,
         bContext *C,
         const char *filepath,
-        const double start,
-        const double end,
-        const double xformstep,
-        const double geomstep,
-        const double shutter_open,
-        const double shutter_close,
-        const bool selected_only,
-        const bool uvs,
-        const bool normals,
-        const bool vcolors,
-        const bool apply_subdiv,
-        const bool flatten_hierarchy,
-        const bool vislayers,
-        const bool renderable,
-        const bool facesets,
-        const bool use_subdiv_schema,
-        const bool compression,
-        const bool packuv,
-        const float global_scale)
+        const struct AlembicExportParams *params)
 {
 	ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
 	job->scene = scene;
@@ -383,28 +365,28 @@ void ABC_export(
 	BLI_strncpy(job->filename, filepath, 1024);
 
 	job->settings.scene = job->scene;
-	job->settings.startframe = start;
-	job->settings.endframe = end;
-	job->settings.xform_frame_step = xformstep;
-	job->settings.shape_frame_step = geomstep;
-	job->settings.shutter_open = shutter_open;
-	job->settings.shutter_close = shutter_close;
-	job->settings.selected_only = selected_only;
-	job->settings.export_face_sets = facesets;
-	job->settings.export_normals = normals;
-	job->settings.export_uvs = uvs;
-	job->settings.export_vcols = vcolors;
-	job->settings.apply_subdiv = apply_subdiv;
-	job->settings.flatten_hierarchy = flatten_hierarchy;
-	job->settings.visible_layers_only = vislayers;
-	job->settings.renderable_only = renderable;
-	job->settings.use_subdiv_schema = use_subdiv_schema;
-	job->settings.export_ogawa = (compression == ABC_ARCHIVE_OGAWA);
-	job->settings.pack_uv = packuv;
-	job->settings.global_scale = global_scale;
-
-	if (job->settings.startframe > job->settings.endframe) {
-		std::swap(job->settings.startframe, job->settings.endframe);
+	job->settings.frame_start = params->frame_start;
+	job->settings.frame_end = params->frame_end;
+	job->settings.frame_step_xform = params->frame_step_xform;
+	job->settings.frame_step_shape = params->frame_step_shape;
+	job->settings.shutter_open = params->shutter_open;
+	job->settings.shutter_close = params->shutter_close;
+	job->settings.selected_only = params->selected_only;
+	job->settings.export_face_sets = params->face_sets;
+	job->settings.export_normals = params->normals;
+	job->settings.export_uvs = params->uvs;
+	job->settings.export_vcols = params->vcolors;
+	job->settings.apply_subdiv = params->apply_subdiv;
+	job->settings.flatten_hierarchy = params->flatten_hierarchy;
+	job->settings.visible_layers_only = params->visible_layers_only;
+	job->settings.renderable_only = params->renderable_only;
+	job->settings.use_subdiv_schema = params->use_subdiv_schema;
+	job->settings.export_ogawa = (params->compression_type == ABC_ARCHIVE_OGAWA);
+	job->settings.pack_uv = params->packuv;
+	job->settings.global_scale = params->global_scale;
+
+	if (job->settings.frame_start > job->settings.frame_end) {
+		std::swap(job->settings.frame_start, job->settings.frame_end);
 	}
 
 	wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index 4cf0313..a344609 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -90,48 +90,34 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op)
 
 	char filename[FILE_MAX];
 	RNA_string_get(op->ptr, "filepath", filename);
-	const int start = RNA_int_get(op->ptr, "start");
-	const int end = RNA_int_get(op->ptr, "end");
-	const int xsamples = RNA_int_get(op->ptr, "xsamples");
-	const int gsamples = RNA_int_get(op->ptr, "gsamples");
-	const float sh_open = RNA_float_get(op->ptr, "sh_open");
-	const float sh_close = RNA_float_get(op->ptr, "sh_close");
-	const bool selected = RNA_boolean_get(op->ptr, "selected");
-	const bool uvs = RNA_boolean_get(op->ptr, "uvs");
-	const bool normals = RNA_boolean_get(op->ptr, "normals");
-	const bool vcolors = RNA_boolean_get(op->ptr, "vcolors");
-	const bool apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv");
-	const bool flatten = RNA_bool

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list