51 const std::string &geom_name,
57 size_t subname_start = 0;
59 if (sep_pos == std::string::npos) {
62 while (sep_pos != std::string::npos) {
64 if (sep_pos > subname_start) {
65 std::string subname = geom_name.substr(subname_start, sep_pos - subname_start);
82 subname_start = sep_pos + 1;
83 if (subname_start >= geom_name.size()) {
92 const Span<std::unique_ptr<Geometry>> all_geometries,
96 for (
const std::unique_ptr<Geometry> &
geometry : all_geometries) {
111 geometries.
append(std::move(geometry_set));
122 MutableSpan<std::unique_ptr<Geometry>> all_geometries,
124 Map<std::string, std::unique_ptr<MTLMaterial>> &materials,
131 parallel_sort(all_geometries.begin(), all_geometries.end(), [](
const auto &a,
const auto &
b) {
132 const char *na = a ? a->geometry_name_.c_str() :
"";
133 const char *nb = b ? b->geometry_name_.c_str() :
"";
134 return BLI_strcasecmp(na, nb) < 0;
139 objects.
reserve(all_geometries.size());
141 for (
const std::unique_ptr<Geometry> &
geometry : all_geometries) {
146 bmain, materials, created_materials, import_params);
152 if (
obj !=
nullptr) {
155 collections.
add(target_collection);
164 std::optional<Bounds<float3>>
bounds = std::nullopt;
181 bool has_instantiated_object =
false;
182 bool has_uninstantiated_object =
false;
187 has_uninstantiated_object =
true;
190 has_instantiated_object =
true;
197 if (has_instantiated_object && has_uninstantiated_object) {
198 CLOG_ERROR(&
LOG,
"Some imported objects were not instantiated, while others were");
217 obj_parser.
parse(all_geometries, global_vertices);
237 obj_parser.
parse(all_geometries, global_vertices);
253 "Could not find an editable collection in current scene, imported data will not be "
General operations, lookup, etc. for blender objects.
#define CLOG_ERROR(clg_ref,...)
#define ID_IS_EDITABLE(_id)
Object groups, one object can be in many groups at once.
void append(const T &value)
void reserve(const int64_t min_capacity)
Curves * create_curve(const OBJImportParams &import_params)
Object * create_curve_object(Main *bmain, 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)
float3x3 scale(float3x3 mat, float2 scale)
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)
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)
LayerCollection * BKE_layer_collection_get_active_editable(ViewLayer *view_layer)
void BKE_view_layer_base_select_and_set_active(ViewLayer *view_layer, Base *selbase)
LayerCollection * BKE_layer_collection_get_active(ViewLayer *view_layer)
ViewLayer * CTX_data_view_layer(const bContext *C)
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
void BKE_view_layer_base_deselect_all(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
Main * CTX_data_main(const bContext *C)
MINLINE void copy_v3_fl(float r[3], float f)
ID_Type GS(const char *name)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
std::optional< Bounds< float3 > > BKE_object_boundbox_get(const Object *ob)
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
struct Collection * collection
ListBaseT< CollectionChild > children
struct Collection * collection
char collection_separator
void set_name(std::string name)
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)