Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJesse Yurkovich <jesse.y@gmail.com>2022-06-07 08:34:06 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-06-22 13:27:42 +0300
commit581604d17ab7dad152a55fe555f0c68f9cf75219 (patch)
treef760cd9eba495c82487e3bcdca4c127aeeb36238 /source
parent770ce6b971af21a73449e9eafc5c74ebae13112b (diff)
OBJ: Use filename as the default object name
To match the existing Python .obj importer, and to make it easier for the user to determine which object is which, use the filename for the default object name instead of "New object". Differential Revision: https://developer.blender.org/D15133
Diffstat (limited to 'source')
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc7
-rw-r--r--source/blender/io/wavefront_obj/tests/obj_importer_tests.cc10
2 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
index c069093ac06..f1c9959cae5 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
@@ -342,9 +342,14 @@ void OBJParser::parse(Vector<std::unique_ptr<Geometry>> &r_all_geometries,
return;
}
+ /* Use the filename as the default name given to the initial object. */
+ char ob_name[FILE_MAXFILE];
+ BLI_strncpy(ob_name, BLI_path_basename(import_params_.filepath), FILE_MAXFILE);
+ BLI_path_extension_replace(ob_name, FILE_MAXFILE, "");
+
VertexIndexOffset offsets;
Geometry *curr_geom = create_geometry(
- nullptr, GEOM_MESH, "", r_global_vertices, r_all_geometries, offsets);
+ nullptr, GEOM_MESH, ob_name, r_global_vertices, r_all_geometries, offsets);
/* State variables: once set, they remain the same for the remaining
* elements in the object. */
diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
index 3d34fb6f9c6..e959f71fffb 100644
--- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
@@ -133,7 +133,7 @@ TEST_F(obj_importer_test, import_cube)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBNew object",
+ {"OBcube",
OB_MESH,
8,
12,
@@ -168,7 +168,7 @@ TEST_F(obj_importer_test, import_nurbs)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBNew object",
+ {"OBnurbs",
OB_CURVES_LEGACY,
12,
0,
@@ -184,7 +184,7 @@ TEST_F(obj_importer_test, import_nurbs_curves)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBNew object", OB_CURVES_LEGACY, 4, 0, 4, 0, float3(2, -2, 0), float3(-2, -2, 0)},
+ {"OBnurbs_curves", OB_CURVES_LEGACY, 4, 0, 4, 0, float3(2, -2, 0), float3(-2, -2, 0)},
{"OBNurbsCurveDiffWeights",
OB_CURVES_LEGACY,
4,
@@ -211,7 +211,7 @@ TEST_F(obj_importer_test, import_nurbs_cyclic)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBNew object",
+ {"OBnurbs_cyclic",
OB_CURVES_LEGACY,
31,
0,
@@ -262,7 +262,7 @@ TEST_F(obj_importer_test, import_materials)
{
Expectation expect[] = {
{"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)},
- {"OBNew object", OB_MESH, 8, 12, 6, 24, float3(-1, -1, 1), float3(1, -1, -1)},
+ {"OBmaterials", OB_MESH, 8, 12, 6, 24, float3(-1, -1, 1), float3(1, -1, -1)},
};
import_and_check("materials.obj", expect, std::size(expect), 4);
}