2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2022-01-03 14:49:31 -05:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup obj
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "BLI_path_util.h"
|
2023-08-31 12:51:57 -04:00
|
|
|
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2023-08-31 12:51:57 -04:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
2022-01-03 14:49:31 -05:00
|
|
|
|
2023-09-01 10:31:17 +10:00
|
|
|
#include "IO_orientation.hh"
|
2023-08-31 12:51:57 -04:00
|
|
|
#include "IO_path_util_types.hh"
|
2022-01-03 14:49:31 -05:00
|
|
|
|
|
|
|
|
struct OBJExportParams {
|
|
|
|
|
/** Full path to the destination .OBJ file. */
|
|
|
|
|
char filepath[FILE_MAX];
|
2022-05-10 11:34:42 +03:00
|
|
|
/** Pretend that destination file folder is this, if non-empty. Used only for tests. */
|
|
|
|
|
char file_base_for_tests[FILE_MAX];
|
2022-01-03 14:49:31 -05:00
|
|
|
|
|
|
|
|
/** Full path to current blender file (used for comments in output). */
|
|
|
|
|
const char *blen_filepath;
|
|
|
|
|
|
|
|
|
|
/** Whether multiple frames should be exported. */
|
|
|
|
|
bool export_animation;
|
|
|
|
|
/** The first frame to be exported. */
|
|
|
|
|
int start_frame;
|
|
|
|
|
/** The last frame to be exported. */
|
|
|
|
|
int end_frame;
|
|
|
|
|
|
|
|
|
|
/* Geometry Transform options. */
|
2023-09-01 10:31:17 +10:00
|
|
|
eIOAxis forward_axis;
|
|
|
|
|
eIOAxis up_axis;
|
2022-10-10 10:10:33 +03:00
|
|
|
float global_scale;
|
2022-01-03 14:49:31 -05:00
|
|
|
|
|
|
|
|
/* File Write Options. */
|
|
|
|
|
bool export_selected_objects;
|
2022-03-13 12:04:52 -04:00
|
|
|
bool apply_modifiers;
|
2022-01-03 14:49:31 -05:00
|
|
|
eEvaluationMode export_eval_mode;
|
|
|
|
|
bool export_uv;
|
|
|
|
|
bool export_normals;
|
2022-06-14 10:19:02 +03:00
|
|
|
bool export_colors;
|
2022-01-03 14:49:31 -05:00
|
|
|
bool export_materials;
|
|
|
|
|
bool export_triangulated_mesh;
|
|
|
|
|
bool export_curves_as_nurbs;
|
2022-05-10 11:34:42 +03:00
|
|
|
ePathReferenceMode path_mode;
|
2022-09-13 13:28:57 +03:00
|
|
|
bool export_pbr_extensions;
|
2022-01-03 14:49:31 -05:00
|
|
|
|
|
|
|
|
/* Grouping options. */
|
|
|
|
|
bool export_object_groups;
|
|
|
|
|
bool export_material_groups;
|
|
|
|
|
bool export_vertex_groups;
|
2022-09-13 13:28:57 +03:00
|
|
|
/* Calculate smooth groups from sharp edges. */
|
2022-01-03 14:49:31 -05:00
|
|
|
bool export_smooth_groups;
|
2022-09-13 13:28:57 +03:00
|
|
|
/* Create bitflags instead of the default "0"/"1" group IDs. */
|
2022-01-03 14:49:31 -05:00
|
|
|
bool smooth_groups_bitflags;
|
2024-02-26 20:45:46 +01:00
|
|
|
|
|
|
|
|
ReportList *reports = nullptr;
|
2022-01-03 14:49:31 -05:00
|
|
|
};
|
|
|
|
|
|
OBJ: New C++ based wavefront OBJ importer
This takes state of soc-2020-io-performance branch as it was at
e9bbfd0c8c7 (2021 Oct 31), merges latest master (2022 Apr 4),
adds a bunch of tests, and fixes a bunch of stuff found by said
tests. The fixes are detailed in the differential.
Timings on my machine (Windows, VS2022 release build, AMD Ryzen
5950X 32 threads):
- Rungholt minecraft level (269MB file, 1 mesh): 54.2s -> 14.2s
(memory usage: 7.0GB -> 1.9GB).
- Blender 3.0 splash scene: "I waited for 90 minutes and gave up"
-> 109s. Now, this time is not great, but at least 20% of the
time is spent assigning unique names for the imported objects
(the scene has 24 thousand objects). This is not specific to obj
importer, but rather a general issue across blender overall.
Test suite file updates done in Subversion tests repository.
Reviewed By: @howardt, @sybren
Differential Revision: https://developer.blender.org/D13958
2022-04-04 13:36:10 +03:00
|
|
|
struct OBJImportParams {
|
|
|
|
|
/** Full path to the source OBJ file to import. */
|
|
|
|
|
char filepath[FILE_MAX];
|
|
|
|
|
/** Value 0 disables clamping. */
|
2023-12-04 09:54:52 +01:00
|
|
|
float clamp_size = 0.0f;
|
|
|
|
|
float global_scale = 1.0f;
|
|
|
|
|
eIOAxis forward_axis = IO_AXIS_NEGATIVE_Z;
|
|
|
|
|
eIOAxis up_axis = IO_AXIS_Y;
|
|
|
|
|
char collection_separator = 0;
|
|
|
|
|
bool use_split_objects = true;
|
|
|
|
|
bool use_split_groups = false;
|
|
|
|
|
bool import_vertex_groups = false;
|
|
|
|
|
bool validate_meshes = false;
|
|
|
|
|
bool relative_paths = true;
|
|
|
|
|
bool clear_selection = true;
|
2024-02-26 20:45:46 +01:00
|
|
|
|
|
|
|
|
ReportList *reports = nullptr;
|
OBJ: New C++ based wavefront OBJ importer
This takes state of soc-2020-io-performance branch as it was at
e9bbfd0c8c7 (2021 Oct 31), merges latest master (2022 Apr 4),
adds a bunch of tests, and fixes a bunch of stuff found by said
tests. The fixes are detailed in the differential.
Timings on my machine (Windows, VS2022 release build, AMD Ryzen
5950X 32 threads):
- Rungholt minecraft level (269MB file, 1 mesh): 54.2s -> 14.2s
(memory usage: 7.0GB -> 1.9GB).
- Blender 3.0 splash scene: "I waited for 90 minutes and gave up"
-> 109s. Now, this time is not great, but at least 20% of the
time is spent assigning unique names for the imported objects
(the scene has 24 thousand objects). This is not specific to obj
importer, but rather a general issue across blender overall.
Test suite file updates done in Subversion tests repository.
Reviewed By: @howardt, @sybren
Differential Revision: https://developer.blender.org/D13958
2022-04-04 13:36:10 +03:00
|
|
|
};
|
|
|
|
|
|
2022-04-05 07:44:36 +10:00
|
|
|
/**
|
2022-05-23 20:42:27 +03:00
|
|
|
* Perform the full import process.
|
|
|
|
|
* Import also changes the selection & the active object; callers
|
|
|
|
|
* need to update the UI bits if needed.
|
2022-04-05 07:44:36 +10:00
|
|
|
*/
|
2023-08-31 12:51:57 -04:00
|
|
|
void OBJ_import(bContext *C, const OBJImportParams *import_params);
|
OBJ: New C++ based wavefront OBJ importer
This takes state of soc-2020-io-performance branch as it was at
e9bbfd0c8c7 (2021 Oct 31), merges latest master (2022 Apr 4),
adds a bunch of tests, and fixes a bunch of stuff found by said
tests. The fixes are detailed in the differential.
Timings on my machine (Windows, VS2022 release build, AMD Ryzen
5950X 32 threads):
- Rungholt minecraft level (269MB file, 1 mesh): 54.2s -> 14.2s
(memory usage: 7.0GB -> 1.9GB).
- Blender 3.0 splash scene: "I waited for 90 minutes and gave up"
-> 109s. Now, this time is not great, but at least 20% of the
time is spent assigning unique names for the imported objects
(the scene has 24 thousand objects). This is not specific to obj
importer, but rather a general issue across blender overall.
Test suite file updates done in Subversion tests repository.
Reviewed By: @howardt, @sybren
Differential Revision: https://developer.blender.org/D13958
2022-04-04 13:36:10 +03:00
|
|
|
|
2022-04-05 07:44:36 +10:00
|
|
|
/**
|
2022-05-23 20:42:27 +03:00
|
|
|
* Perform the full export process.
|
2022-04-05 07:44:36 +10:00
|
|
|
*/
|
2023-08-31 12:51:57 -04:00
|
|
|
void OBJ_export(bContext *C, const OBJExportParams *export_params);
|