43 const std::string &geom_name,
49 size_t subname_start = 0;
51 if (sep_pos == std::string::npos) {
54 while (sep_pos != std::string::npos) {
56 if (sep_pos > subname_start) {
57 std::string subname = geom_name.substr(subname_start, sep_pos - subname_start);
60 if (
GS(child->collection->id.name) ==
ID_GR &&
61 STREQ(child->collection->id.name + 2, subname.c_str()))
63 target = child->collection;
74 subname_start = sep_pos + 1;
75 if (subname_start >= geom_name.size()) {
84 const Span<std::unique_ptr<Geometry>> all_geometries,
88 for (
const std::unique_ptr<Geometry> &
geometry : all_geometries) {
103 geometries.
append(std::move(geometry_set));
114 MutableSpan<std::unique_ptr<Geometry>> all_geometries,
116 Map<std::string, std::unique_ptr<MTLMaterial>> &materials,
124 all_geometries.begin(), all_geometries.end(), [](
const auto &a,
const auto &
b) {
125 const char *na = a ? a->geometry_name_.c_str() :
"";
126 const char *nb = b ? b->geometry_name_.c_str() :
"";
127 return BLI_strcasecmp(na, nb) < 0;
132 objects.
reserve(all_geometries.size());
134 for (
const std::unique_ptr<Geometry> &
geometry : all_geometries) {
139 bmain, materials, created_materials, import_params);
145 if (
obj !=
nullptr) {
148 collections.
add(target_collection);
157 std::optional<Bounds<float3>>
bounds = std::nullopt;
164 const float scale = import_params.
clamp_size / max_diff;
192 size_t read_buffer_size)
199 OBJParser obj_parser{import_params, read_buffer_size};
200 obj_parser.
parse(all_geometries, global_vertices);
217 size_t read_buffer_size)
227 OBJParser obj_parser{import_params, read_buffer_size};
228 obj_parser.
parse(all_geometries, global_vertices);
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)
General operations, lookup, etc. for blender objects.
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_get(const Object *ob)
#define LISTBASE_FOREACH(type, var, list)
MINLINE void copy_v3_fl(float r[3], float f)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Object groups, one object can be in many groups at once.
void append(const T &value)
void reserve(const int64_t min_capacity)
Object * create_curve_object(Main *bmain, const OBJImportParams &import_params)
Curves * create_curve(const OBJImportParams &import_params)
void parse_and_store(Map< std::string, std::unique_ptr< MTLMaterial > > &r_materials)
Mesh * create_mesh(const OBJImportParams &import_params)
Object * create_mesh_object(Main *bmain, Map< std::string, std::unique_ptr< MTLMaterial > > &materials, Map< std::string, Material * > &created_materials, const OBJImportParams &import_params)
Span< std::string > mtl_libraries() const
void parse(Vector< std::unique_ptr< Geometry > > &r_all_geometries, GlobalVertices &r_global_vertices)
DEG_id_tag_update_ex(cb_data->bmain, cb_data->owner_id, ID_RECALC_TAG_FOR_UNDO|ID_RECALC_SYNC_TO_EVAL)
Bounds< T > merge(const Bounds< T > &a, const Bounds< T > &b)
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)
T reduce_max(const VecBase< T, Size > &a)
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)