38 const std::string &geom_name,
44 size_t subname_start = 0;
46 if (sep_pos == std::string::npos) {
49 while (sep_pos != std::string::npos) {
51 if (sep_pos > subname_start) {
52 std::string subname = geom_name.substr(subname_start, sep_pos - subname_start);
55 if (
GS(child->collection->id.name) ==
ID_GR &&
56 STREQ(child->collection->id.name + 2, subname.c_str()))
58 target = child->collection;
69 subname_start = sep_pos + 1;
70 if (subname_start >= geom_name.size()) {
79 const Span<std::unique_ptr<Geometry>> all_geometries,
83 for (
const std::unique_ptr<Geometry> &geometry : all_geometries) {
88 Mesh *mesh = mesh_ob_from_geometry.create_mesh(import_params);
98 geometries.append(std::move(geometry_set));
109 MutableSpan<std::unique_ptr<Geometry>> all_geometries,
111 Map<std::string, std::unique_ptr<MTLMaterial>> &materials,
119 all_geometries.begin(), all_geometries.end(), [](
const auto &a,
const auto &
b) {
120 const char *na = a ? a->geometry_name_.c_str() :
"";
121 const char *nb = b ? b->geometry_name_.c_str() :
"";
122 return BLI_strcasecmp(na, nb) < 0;
127 objects.
reserve(all_geometries.size());
129 for (
const std::unique_ptr<Geometry> &geometry : all_geometries) {
133 obj = mesh_ob_from_geometry.create_mesh_object(
134 bmain, materials, created_materials, import_params);
136 else if (geometry->geom_type_ ==
GEOM_CURVE) {
140 if (obj !=
nullptr) {
142 bmain, lc->
collection, geometry->geometry_name_, import_params);
143 collections.
add(target_collection);
152 for (
Object *obj : objects) {
170 size_t read_buffer_size)
177 OBJParser obj_parser{import_params, read_buffer_size};
178 obj_parser.parse(all_geometries, global_vertices);
195 size_t read_buffer_size)
205 OBJParser obj_parser{import_params, read_buffer_size};
206 obj_parser.parse(all_geometries, global_vertices);
208 for (
StringRefNull mtl_library : obj_parser.mtl_libraries()) {
210 mtl_parser.parse_and_store(materials);
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
LayerCollection * BKE_layer_collection_get_active(ViewLayer *view_layer)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
void BKE_view_layer_base_deselect_all(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void BKE_view_layer_base_select_and_set_active(ViewLayer *view_layer, Base *selbase)
#define LISTBASE_FOREACH(type, var, list)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Object groups, one object can be in many groups at once.
void reserve(const int64_t min_capacity)
Object * create_curve_object(Main *bmain, const OBJImportParams &import_params)
local_group_size(16, 16) .push_constant(Type b
Curves * curve_legacy_to_curves(const Curve &curve_legacy)
static Collection * find_or_create_collection(Main *bmain, Collection *target, const std::string &geom_name, const OBJImportParams &import_params)
static void geometry_to_blender_objects(Main *bmain, Scene *scene, ViewLayer *view_layer, const OBJImportParams &import_params, MutableSpan< std::unique_ptr< Geometry > > all_geometries, const GlobalVertices &global_vertices, Map< std::string, std::unique_ptr< MTLMaterial > > &materials, Map< std::string, Material * > &created_materials)
void importer_geometry(const OBJImportParams &import_params, Vector< bke::GeometrySet > &geometries, size_t read_buffer_size)
static void geometry_to_blender_geometry_set(const OBJImportParams &import_params, const Span< std::unique_ptr< Geometry > > all_geometries, const GlobalVertices &global_vertices, Vector< bke::GeometrySet > &geometries)
void importer_main(bContext *C, const OBJImportParams &import_params)
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end)
struct Collection * collection
char collection_separator
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)