11#include "COLLADAFWMeshPrimitive.h"
12#include "COLLADAFWMeshVertexData.h"
13#include "COLLADAFWPolygons.h"
36 return node->getName().empty() ? node->getOriginalId() : node->getName();
42 case COLLADAFW::MeshPrimitive::LINES:
44 case COLLADAFW::MeshPrimitive::LINE_STRIPS:
46 case COLLADAFW::MeshPrimitive::POLYGONS:
48 case COLLADAFW::MeshPrimitive::POLYLIST:
50 case COLLADAFW::MeshPrimitive::TRIANGLES:
52 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
53 return "TRIANGLE_FANS";
54 case COLLADAFW::MeshPrimitive::TRIANGLE_STRIPS:
55 return "TRIANGLE_STRIPS";
56 case COLLADAFW::MeshPrimitive::POINTS:
58 case COLLADAFW::MeshPrimitive::UNDEFINED_PRIMITIVE_TYPE:
59 return "UNDEFINED_PRIMITIVE_TYPE";
67 case COLLADAFW::Geometry::GEO_TYPE_MESH:
69 case COLLADAFW::Geometry::GEO_TYPE_SPLINE:
71 case COLLADAFW::Geometry::GEO_TYPE_CONVEX_MESH:
73 case COLLADAFW::Geometry::GEO_TYPE_UNKNOWN:
82void WVDataWrapper::print()
84 fprintf(stderr,
"UVs:\n");
85 switch (mVData->getType()) {
86 case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
87 COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
88 if (values->getCount()) {
89 for (
int i = 0;
i < values->getCount();
i += 2) {
90 fprintf(stderr,
"%.1f, %.1f\n", (*values)[
i], (*values)[
i + 1]);
95 case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
96 COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
97 if (values->getCount()) {
98 for (
int i = 0;
i < values->getCount();
i += 2) {
99 fprintf(stderr,
"%.1f, %.1f\n",
float((*values)[
i]),
float((*values)[
i + 1]));
105 fprintf(stderr,
"\n");
111 int stride = mVData->getStride(0);
116 switch (mVData->getType()) {
117 case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
118 COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
119 if (values->empty()) {
122 uv[0] = (*values)[uv_index * stride];
123 uv[1] = (*values)[uv_index * stride + 1];
126 case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
127 COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
128 if (values->empty()) {
131 uv[0] = float((*values)[uv_index * stride]);
132 uv[1] = float((*values)[uv_index * stride + 1]);
135 case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
137 fprintf(stderr,
"MeshImporter.getUV(): unknown data type\n");
146 if (values->empty() || values->getCount() < (v_index + 1) * stride) {
148 "VCOLDataWrapper.getvcol(): Out of Bounds error: index %d points outside value "
149 "list of length %zd (with stride=%d) \n",
166 int stride = mVData->getStride(0);
171 switch (mVData->getType()) {
172 case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
173 COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
177 case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
178 COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
183 fprintf(stderr,
"VCOLDataWrapper.getvcol(): unknown data type\n");
188 bool use_custom_normals,
193 : unitconverter(unitconv),
194 use_custom_normals(use_custom_normals),
197 view_layer(view_layer),
198 armature_importer(arm)
203bool MeshImporter::set_poly_indices(
int *face_verts,
208 bool broken_loop =
false;
209 for (
int index = 0; index < loop_count; index++) {
213 for (
int i = 0;
i < index;
i++) {
227void MeshImporter::set_vcol(
MLoopCol *mloopcol,
230 COLLADAFW::IndexList &index_list,
234 for (index = 0; index <
count; index++, mloopcol++) {
235 int v_index = index_list.getIndex(index + loop_index);
243 COLLADAFW::IndexList &index_list,
247 COLLADAFW::UIntValuesArray &
indices = index_list.getIndices();
249 for (
int index = 0; index <
count; index++) {
250 int uv_index =
indices[index + start_index];
251 uvs.
getUV(uv_index, mloopuv[index]);
256void MeshImporter::print_index_list(COLLADAFW::IndexList &index_list)
258 fprintf(stderr,
"Index list for \"%s\":\n", index_list.getName().c_str());
259 for (
int i = 0;
i < index_list.getIndicesCount();
i += 2) {
260 fprintf(stderr,
"%u, %u\n", index_list.getIndex(
i), index_list.getIndex(
i + 1));
262 fprintf(stderr,
"\n");
266bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
268 COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
272 for (
uint i = 0;
i < prim_arr.getCount();
i++) {
274 COLLADAFW::MeshPrimitive *mp = prim_arr[
i];
275 COLLADAFW::MeshPrimitive::PrimitiveType type = mp->getPrimitiveType();
280 if (
ELEM(type, COLLADAFW::MeshPrimitive::POLYLIST, COLLADAFW::MeshPrimitive::POLYGONS)) {
282 COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
283 COLLADAFW::Polygons::VertexCountArray &vca = mpvc->getGroupedVerticesVertexCountArray();
286 int nonface_count = 0;
288 for (
uint j = 0; j < vca.getCount(); j++) {
299 if (hole_count > 0) {
301 "WARNING: Primitive %s in %s: %d holes not imported (unsupported)\n",
307 if (nonface_count > 0) {
309 "WARNING: Primitive %s in %s: %d faces with vertex count < 3 (rejected)\n",
316 else if (type == COLLADAFW::MeshPrimitive::LINES) {
321 COLLADAFW::MeshPrimitive::TRIANGLES,
322 COLLADAFW::MeshPrimitive::TRIANGLE_FANS))
324 fprintf(stderr,
"ERROR: Primitive type %s is not supported.\n", type_str);
332void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh,
Mesh *blender_mesh)
335 COLLADAFW::MeshVertexData &
pos = mesh->getPositions();
340 int stride =
pos.getStride(0);
345 blender_mesh->
verts_num =
pos.getFloatValues()->getCount() / stride;
348 MutableSpan<float3> positions = blender_mesh->vert_positions_for_write();
350 get_vector(positions[
i],
pos,
i, stride);
354bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp)
357 bool has_useable_normals =
false;
359 int normals_count = mp->getNormalIndices().getCount();
360 if (normals_count > 0) {
361 int index_count = mp->getPositionIndices().getCount();
362 if (index_count == normals_count) {
363 has_useable_normals =
true;
367 "Warning: Number of normals %d is different from the number of vertices %d, "
368 "skipping normals\n",
374 return has_useable_normals;
377bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp)
380 bool has_faces =
false;
381 int type = mp->getPrimitiveType();
383 case COLLADAFW::MeshPrimitive::TRIANGLES:
384 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
385 case COLLADAFW::MeshPrimitive::POLYLIST:
386 case COLLADAFW::MeshPrimitive::POLYGONS: {
400 std::string colname = collada_id;
401 int spos = colname.find(
"-mesh-colors-");
402 if (spos != std::string::npos) {
403 colname = colname.substr(spos + 13);
408void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh,
Mesh *mesh)
410 COLLADAFW::MeshPrimitiveArray &prim_arr = collada_mesh->getMeshPrimitives();
411 int total_poly_count = 0;
412 int total_loop_count = 0;
415 for (
int i = 0;
i < prim_arr.getCount();
i++) {
416 COLLADAFW::MeshPrimitive *mp = prim_arr[
i];
417 int type = mp->getPrimitiveType();
419 case COLLADAFW::MeshPrimitive::TRIANGLES:
420 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
421 case COLLADAFW::MeshPrimitive::POLYLIST:
422 case COLLADAFW::MeshPrimitive::POLYGONS: {
423 COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
424 size_t prim_poly_count = mpvc->getFaceCount();
426 size_t prim_loop_count = 0;
427 for (
int index = 0; index < prim_poly_count; index++) {
428 int vcount = get_vertex_count(mpvc, index);
430 prim_loop_count += vcount;
438 total_loop_count += prim_loop_count;
448 if (total_poly_count > 0) {
455 uint totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount();
456 for (
int i = 0;
i < totuvset;
i++) {
457 if (collada_mesh->getUVCoords().getLength(
i) == 0) {
464 for (
int i = 0;
i < totuvset;
i++) {
465 COLLADAFW::MeshVertexData::InputInfos *info =
466 collada_mesh->getUVCoords().getInputInfosArray()[
i];
467 COLLADAFW::String &uvname = info->mName;
476 int totcolset = collada_mesh->getColors().getInputInfosArray().getCount();
478 for (
int i = 0;
i < totcolset;
i++) {
479 COLLADAFW::MeshVertexData::InputInfos *info =
480 collada_mesh->getColors().getInputInfosArray()[
i];
493uint MeshImporter::get_vertex_count(COLLADAFW::Polygons *mp,
int index)
495 int type = mp->getPrimitiveType();
498 case COLLADAFW::MeshPrimitive::TRIANGLES:
499 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS: {
503 case COLLADAFW::MeshPrimitive::POLYLIST:
504 case COLLADAFW::MeshPrimitive::POLYGONS: {
505 result = mp->getGroupedVerticesVertexCountArray()[index];
516uint MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh)
518 COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
519 int loose_edge_count = 0;
522 for (
int i = 0;
i < prim_arr.getCount();
i++) {
523 COLLADAFW::MeshPrimitive *mp = prim_arr[
i];
524 int type = mp->getPrimitiveType();
526 case COLLADAFW::MeshPrimitive::LINES: {
527 size_t prim_totface = mp->getFaceCount();
528 loose_edge_count += prim_totface;
535 return loose_edge_count;
538void MeshImporter::mesh_add_edges(
Mesh *mesh,
int len)
566void MeshImporter::read_lines(COLLADAFW::Mesh *mesh,
Mesh *blender_mesh)
568 uint loose_edge_count = get_loose_edge_count(mesh);
569 if (loose_edge_count > 0) {
574 mesh_add_edges(blender_mesh, loose_edge_count);
575 MutableSpan<blender::int2> edges = blender_mesh->edges_for_write();
578 COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
580 for (
int index = 0; index < prim_arr.getCount(); index++) {
581 COLLADAFW::MeshPrimitive *mp = prim_arr[index];
583 int type = mp->getPrimitiveType();
584 if (type == COLLADAFW::MeshPrimitive::LINES) {
585 uint edge_count = mp->getFaceCount();
586 uint *
indices = mp->getPositionIndices().getData();
588 for (
int j = 0; j < edge_count; j++, edge++) {
590 (*edge)[1] =
indices[2 * j + 1];
597void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh,
601 using namespace blender;
604 allocate_poly_data(collada_mesh, mesh);
606 UVDataWrapper uvs(collada_mesh->getUVCoords());
607 VCOLDataWrapper vcol(collada_mesh->getColors());
609 MutableSpan<int> face_offsets = mesh->face_offsets_for_write();
610 MutableSpan<int> corner_verts = mesh->corner_verts_for_write();
614 MaterialIdPrimitiveArrayMap mat_prim_map;
616 bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
618 "material_index", bke::AttrDomain::Face);
620 "sharp_face", bke::AttrDomain::Face);
622 COLLADAFW::MeshPrimitiveArray &prim_arr = collada_mesh->getMeshPrimitives();
623 COLLADAFW::MeshVertexData &
nor = collada_mesh->getNormals();
625 for (
i = 0;
i < prim_arr.getCount();
i++) {
627 COLLADAFW::MeshPrimitive *mp = prim_arr[
i];
630 size_t prim_faces_num = mp->getFaceCount();
631 uint *position_indices = mp->getPositionIndices().getData();
632 uint *normal_indices = mp->getNormalIndices().getData();
634 bool mp_has_normals = primitive_has_useable_normals(mp);
635 bool mp_has_faces = primitive_has_faces(mp);
637 int collada_meshtype = mp->getPrimitiveType();
639 if (collada_meshtype == COLLADAFW::MeshPrimitive::LINES) {
645 Primitive prim = {face_index, &material_indices.
span[face_index], 0};
652 if (collada_meshtype == COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
653 uint grouped_vertex_count = mp->getGroupedVertexElementsCount();
654 for (
uint group_index = 0; group_index < grouped_vertex_count; group_index++) {
655 uint first_vertex = position_indices[0];
656 uint first_normal = normal_indices[0];
657 uint vertex_count = mp->getGroupedVerticesVertexCount(group_index);
659 for (
uint vertex_index = 0; vertex_index < vertex_count - 2; vertex_index++) {
661 uint triangle_vertex_indices[3] = {
662 first_vertex, position_indices[1], position_indices[2]};
663 face_offsets[face_index] = loop_index;
664 set_poly_indices(&corner_verts[loop_index], loop_index, triangle_vertex_indices, 3);
666 if (mp_has_normals) {
668 uint vertex_normal_indices[3] = {first_normal, normal_indices[1], normal_indices[2]};
669 sharp_faces.span[face_index] = is_flat_face(vertex_normal_indices,
nor, 3);
679 if (mp_has_normals) {
683 position_indices += 2;
687 if (
ELEM(collada_meshtype,
688 COLLADAFW::MeshPrimitive::POLYLIST,
689 COLLADAFW::MeshPrimitive::POLYGONS,
690 COLLADAFW::MeshPrimitive::TRIANGLES))
692 COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
693 uint start_index = 0;
695 COLLADAFW::IndexListArray &index_list_array_uvcoord = mp->getUVCoordIndicesArray();
696 COLLADAFW::IndexListArray &index_list_array_vcolor = mp->getColorIndicesArray();
698 int invalid_loop_holes = 0;
699 for (
uint j = 0; j < prim_faces_num; j++) {
702 int vcount = get_vertex_count(mpvc, j);
707 face_offsets[face_index] = loop_index;
708 bool broken_loop = set_poly_indices(
709 &corner_verts[loop_index], loop_index, position_indices, vcount);
711 invalid_loop_holes += 1;
714 for (
uint uvset_index = 0; uvset_index < index_list_array_uvcoord.getCount();
717 COLLADAFW::IndexList &index_list = *index_list_array_uvcoord[uvset_index];
721 if (mloopuv ==
nullptr) {
723 "Collada import: Mesh [%s] : Unknown reference to TEXCOORD [#%s].\n",
725 index_list.getName().c_str());
728 set_face_uv(mloopuv + loop_index,
731 *index_list_array_uvcoord[uvset_index],
736 if (mp_has_normals) {
739 sharp_faces.span[face_index] = is_flat_face(normal_indices,
nor, vcount);
741 if (use_custom_normals) {
743 float vert_normal[3];
744 uint *cur_normal = normal_indices;
745 for (
int k = 0; k < vcount; k++, cur_normal++) {
746 get_vector(vert_normal,
nor, *cur_normal, 3);
748 loop_normals.
append(vert_normal);
753 if (mp->hasColorIndices()) {
754 int vcolor_count = index_list_array_vcolor.getCount();
756 for (
uint vcolor_index = 0; vcolor_index < vcolor_count; vcolor_index++) {
758 COLLADAFW::IndexList &color_index_list = *mp->getColorIndices(vcolor_index);
762 if (mloopcol ==
nullptr) {
764 "Collada import: Mesh [%s] : Unknown reference to VCOLOR [#%s].\n",
766 color_index_list.getName().c_str());
769 set_vcol(mloopcol + loop_index, vcol, start_index, color_index_list, vcount);
775 loop_index += vcount;
776 start_index += vcount;
779 if (mp_has_normals) {
780 normal_indices += vcount;
783 position_indices += vcount;
786 if (invalid_loop_holes > 0) {
788 "Collada import: Mesh [%s] : contains %d unsupported loops (holes).\n",
795 mat_prim_map[mp->getMaterialId()].push_back(prim);
799 geom_uid_mat_mapping_map[collada_mesh->getUniqueId()] = mat_prim_map;
800 material_indices.
finish();
801 sharp_faces.finish();
804void MeshImporter::get_vector(
float v[3], COLLADAFW::MeshVertexData &arr,
int i,
int stride)
808 switch (arr.getType()) {
809 case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
810 COLLADAFW::ArrayPrimitiveType<float> *values = arr.getFloatValues();
811 if (values->empty()) {
815 v[0] = (*values)[
i++];
816 v[1] = (*values)[
i++];
825 case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
826 COLLADAFW::ArrayPrimitiveType<double> *values = arr.getDoubleValues();
827 if (values->empty()) {
831 v[0] = float((*values)[
i++]);
832 v[1] = float((*values)[
i++]);
834 v[2] = float((*values)[
i]);
846bool MeshImporter::is_flat_face(
uint *nind, COLLADAFW::MeshVertexData &
nor,
int count)
850 get_vector(a,
nor, *nind, 3);
855 for (
int i = 1;
i <
count;
i++, nind++) {
856 get_vector(
b,
nor, *nind, 3);
861 if (dp < 0.99999f || dp > 1.00001f) {
871 if (uid_object_map.find(geom_uid) != uid_object_map.end()) {
872 return uid_object_map[geom_uid];
879 if (uid_mesh_map.find(geom_uid) != uid_mesh_map.end()) {
880 return uid_mesh_map[geom_uid];
887 if (this->mesh_geom_map.find(mesh_name) !=
this->mesh_geom_map.end()) {
888 return &this->mesh_geom_map[mesh_name];
895 for (
const int vert_i : mesh->corner_verts()) {
917 for (
int index = 0; index < ob1->
totcol; index++) {
921 if (ob1->
matbits[index] == 0) {
924 if (ob1->
mat[index] != ob2->
mat[index]) {
938 for (
int index = 0; index < ob->
totcol; index++) {
940 mesh->
mat[index] = ob->
mat[index];
949 for (
int index = 0; index < ob->
totcol; index++) {
951 ob->
mat[index] =
nullptr;
955std::vector<Object *> MeshImporter::get_all_users_of(
Mesh *reference_mesh)
957 std::vector<Object *> mesh_users;
958 for (
Object *ob : imported_objects) {
962 if (mesh == reference_mesh) {
963 mesh_users.push_back(ob);
972 for (
Object *ob : imported_objects) {
980 bool can_move =
true;
981 std::vector<Object *> mesh_users = get_all_users_of(mesh);
982 if (mesh_users.size() > 1) {
983 Object *ref_ob = mesh_users[0];
984 for (
int index = 1; index < mesh_users.size(); index++) {
992 for (
Object *
object : mesh_users) {
1003 COLLADAFW::MaterialBinding cmaterial,
1004 std::map<COLLADAFW::UniqueId, Material *> &uid_material_map,
1006 const COLLADAFW::UniqueId *geom_uid,
1009 const COLLADAFW::UniqueId &ma_uid = cmaterial.getReferencedMaterial();
1012 if (uid_material_map.find(ma_uid) == uid_material_map.end()) {
1014 fprintf(stderr,
"Cannot find material by UID.\n");
1019 materials_mapped_to_geom.insert(
1020 std::pair<COLLADAFW::UniqueId, COLLADAFW::UniqueId>(*geom_uid, ma_uid));
1022 Material *ma = uid_material_map[ma_uid];
1029 MaterialIdPrimitiveArrayMap &mat_prim_map = geom_uid_mat_mapping_map[*geom_uid];
1030 COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId();
1033 if (mat_prim_map.find(mat_id) != mat_prim_map.end()) {
1035 std::vector<Primitive> &prims = mat_prim_map[mat_id];
1037 std::vector<Primitive>::iterator it;
1039 for (it = prims.begin(); it != prims.end(); it++) {
1040 Primitive &prim = *it;
1042 for (
int i = 0;
i < prim.faces_num;
i++) {
1043 prim.material_indices[
i] = mat_index;
1050 COLLADAFW::Node *node,
1051 COLLADAFW::InstanceGeometry *geom,
1053 std::map<COLLADAFW::UniqueId, Material *> &uid_material_map)
1055 const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
1060 geom_uid = armature_importer->get_geometry_uid(*geom_uid);
1063 fprintf(stderr,
"Couldn't find a mesh UID by controller's UID.\n");
1069 if (uid_mesh_map.find(*geom_uid) == uid_mesh_map.end()) {
1072 fprintf(stderr,
"Couldn't find a mesh by UID.\n");
1076 if (!uid_mesh_map[*geom_uid]) {
1081 const std::string &
id = node->getName().empty() ? node->getOriginalId() : node->getName();
1082 const char *name =
id.length() ?
id.c_str() :
nullptr;
1089 uid_object_map[*geom_uid] = ob;
1090 imported_objects.push_back(ob);
1094 Mesh *new_mesh = uid_mesh_map[*geom_uid];
1103 COLLADAFW::MaterialBindingArray &mat_array = geom->getMaterialBindings();
1106 for (
uint i = 0;
i < mat_array.getCount();
i++) {
1108 if (mat_array[
i].getReferencedMaterial().isValid()) {
1112 fprintf(stderr,
"invalid referenced material for %s\n", mat_array[
i].
getName().c_str());
1125 if (geom->getType() != COLLADAFW::Geometry::GEO_TYPE_MESH) {
1127 fprintf(stderr,
"Mesh type %s is not supported\n",
bc_geomTypeToStr(geom->getType()));
1131 COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh *)geom;
1133 if (!is_nice_mesh(mesh)) {
1138 const std::string &str_geom_id = mesh->getName().empty() ? mesh->getOriginalId() :
1146 this->uid_mesh_map[mesh->getUniqueId()] = blender_mesh;
1147 this->mesh_geom_map[std::string(blender_mesh->
id.
name)] = str_geom_id;
1149 read_vertices(mesh, blender_mesh);
1152 read_polys(mesh, blender_mesh, loop_normals);
1159 if (use_custom_normals && !loop_normals.
is_empty()) {
1165 fprintf(stderr,
"Can't apply custom normals, encountered invalid loop vert indices!\n");
1171 "Can't apply custom normals, mesh->corners_num != loop_normals.size() (%d != %d)\n",
1173 int(loop_normals.
size()));
1182 read_lines(mesh, blender_mesh);
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< blender::StringRef > name)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_get_layer_named_for_write(CustomData *data, eCustomDataType type, blender::StringRef name, int totelem)
void * CustomData_add_layer_named(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem, blender::StringRef name)
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
const char * CustomData_get_layer_name(const CustomData *data, eCustomDataType type, int n)
void CustomData_free(CustomData *data)
void CustomData_init_layout_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, eCDAllocType alloctype, int totelem)
void CustomData_copy_data(const CustomData *source, CustomData *dest, int source_index, int dest_index, int count)
void CustomData_set_layer_active(CustomData *data, eCustomDataType type, int n)
const CustomData_MeshMasks CD_MASK_MESH
void BKE_id_free_us(Main *bmain, void *idv) ATTR_NONNULL()
General operations, lookup, etc. for materials.
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
bool BKE_mesh_validate(Mesh *mesh, bool do_verbose, bool cddata_check_mask)
Mesh * BKE_mesh_add(Main *bmain, const char *name)
void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *mesh)
void BKE_mesh_face_offsets_ensure_alloc(Mesh *mesh)
void BKE_mesh_runtime_clear_cache(Mesh *mesh)
General operations, lookup, etc. for blender objects.
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float n[3])
void bc_remove_mark(Object *ob)
int bc_is_marked(Object *ob)
void bc_set_mark(Object *ob)
struct CustomData CustomData
static bool bc_has_same_material_configuration(Object *ob1, Object *ob2)
static bool bc_has_out_of_bound_indices(Mesh *mesh)
static void bc_remove_materials_from_object(Object *ob, Mesh *mesh)
static void bc_copy_materials_to_data(Object *ob, Mesh *mesh)
static const char * bc_geomTypeToStr(COLLADAFW::Geometry::GeometryType type)
static std::string extract_vcolname(const COLLADAFW::String &collada_id)
static const char * bc_primTypeToStr(COLLADAFW::MeshPrimitive::PrimitiveType type)
static void colladaAddColor(T values, MLoopCol *mloopcol, int v_index, int stride)
static std::string bc_get_dae_name(T *node)
ATTR_WARN_UNUSED_RESULT const BMVert * v
virtual const char * getName() const
Mesh * get_mesh_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) override
void optimize_material_assignements()
bool write_geometry(const COLLADAFW::Geometry *geom)
void assign_material_to_geom(COLLADAFW::MaterialBinding cmaterial, std::map< COLLADAFW::UniqueId, Material * > &uid_material_map, Object *ob, const COLLADAFW::UniqueId *geom_uid, short mat_index)
MeshImporter(UnitConverter *unitconv, bool use_custom_normals, ArmatureImporter *arm, Main *bmain, Scene *sce, ViewLayer *view_layer)
Object * create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, bool isController, std::map< COLLADAFW::UniqueId, Material * > &uid_material_map)
std::string * get_geometry_name(const std::string &mesh_name) override
Object * get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid) override
UVDataWrapper(COLLADAFW::MeshVertexData &vdata)
void getUV(int uv_index, float *uv)
void get_vcol(int v_index, MLoopCol *mloopcol)
VCOLDataWrapper(COLLADAFW::MeshVertexData &vdata)
constexpr T * data() const
constexpr IndexRange index_range() const
void append(const T &value)
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
Object * bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name)
#define ID_REAL_USERS(id)
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
void mesh_set_custom_normals(Mesh &mesh, MutableSpan< float3 > corner_normals)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
MutableVArraySpan< T > span