13#include "COLLADABUPlatform.h"
15#include "COLLADAFWMeshPrimitive.h"
16#include "COLLADAFWMeshVertexData.h"
17#include "COLLADAFWPolygons.h"
46 return node->getName().empty() ? node->getOriginalId() : node->getName();
52 case COLLADAFW::MeshPrimitive::LINES:
54 case COLLADAFW::MeshPrimitive::LINE_STRIPS:
56 case COLLADAFW::MeshPrimitive::POLYGONS:
58 case COLLADAFW::MeshPrimitive::POLYLIST:
60 case COLLADAFW::MeshPrimitive::TRIANGLES:
62 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
63 return "TRIANGLE_FANS";
64 case COLLADAFW::MeshPrimitive::TRIANGLE_STRIPS:
65 return "TRIANGLE_STRIPS";
66 case COLLADAFW::MeshPrimitive::POINTS:
68 case COLLADAFW::MeshPrimitive::UNDEFINED_PRIMITIVE_TYPE:
69 return "UNDEFINED_PRIMITIVE_TYPE";
77 case COLLADAFW::Geometry::GEO_TYPE_MESH:
79 case COLLADAFW::Geometry::GEO_TYPE_SPLINE:
81 case COLLADAFW::Geometry::GEO_TYPE_CONVEX_MESH:
83 case COLLADAFW::Geometry::GEO_TYPE_UNKNOWN:
92void WVDataWrapper::print()
94 fprintf(stderr,
"UVs:\n");
95 switch (mVData->getType()) {
96 case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
97 COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
98 if (values->getCount()) {
99 for (
int i = 0; i < values->getCount(); i += 2) {
100 fprintf(stderr,
"%.1f, %.1f\n", (*values)[i], (*values)[i + 1]);
105 case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
106 COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
107 if (values->getCount()) {
108 for (
int i = 0; i < values->getCount(); i += 2) {
109 fprintf(stderr,
"%.1f, %.1f\n",
float((*values)[i]),
float((*values)[i + 1]));
115 fprintf(stderr,
"\n");
121 int stride = mVData->getStride(0);
126 switch (mVData->getType()) {
127 case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
128 COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
129 if (values->empty()) {
132 uv[0] = (*values)[uv_index * stride];
133 uv[1] = (*values)[uv_index * stride + 1];
136 case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
137 COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
138 if (values->empty()) {
141 uv[0] =
float((*values)[uv_index * stride]);
142 uv[1] =
float((*values)[uv_index * stride + 1]);
145 case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
147 fprintf(stderr,
"MeshImporter.getUV(): unknown data type\n");
156 if (values->empty() || values->getCount() < (v_index + 1) * stride) {
158 "VCOLDataWrapper.getvcol(): Out of Bounds error: index %d points outside value "
159 "list of length %zd (with stride=%d) \n",
176 int stride = mVData->getStride(0);
181 switch (mVData->getType()) {
182 case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
183 COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
187 case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
188 COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
193 fprintf(stderr,
"VCOLDataWrapper.getvcol(): unknown data type\n");
198 bool use_custom_normals,
203 : unitconverter(unitconv),
204 use_custom_normals(use_custom_normals),
207 view_layer(view_layer),
208 armature_importer(arm)
213bool MeshImporter::set_poly_indices(
int *face_verts,
218 bool broken_loop =
false;
219 for (
int index = 0; index < loop_count; index++) {
223 for (
int i = 0; i < index; i++) {
224 if (indices[i] == indices[index]) {
231 *face_verts = indices[index];
237void MeshImporter::set_vcol(
MLoopCol *mloopcol,
240 COLLADAFW::IndexList &index_list,
244 for (index = 0; index <
count; index++, mloopcol++) {
245 int v_index = index_list.getIndex(index + loop_index);
253 COLLADAFW::IndexList &index_list,
257 COLLADAFW::UIntValuesArray &indices = index_list.getIndices();
259 for (
int index = 0; index <
count; index++) {
260 int uv_index = indices[index + start_index];
261 uvs.
getUV(uv_index, mloopuv[index]);
266void MeshImporter::print_index_list(COLLADAFW::IndexList &index_list)
268 fprintf(stderr,
"Index list for \"%s\":\n", index_list.getName().c_str());
269 for (
int i = 0; i < index_list.getIndicesCount(); i += 2) {
270 fprintf(stderr,
"%u, %u\n", index_list.getIndex(i), index_list.getIndex(i + 1));
272 fprintf(stderr,
"\n");
276bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
278 COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
282 for (
uint i = 0; i < prim_arr.getCount(); i++) {
284 COLLADAFW::MeshPrimitive *mp = prim_arr[i];
285 COLLADAFW::MeshPrimitive::PrimitiveType type = mp->getPrimitiveType();
290 if (
ELEM(type, COLLADAFW::MeshPrimitive::POLYLIST, COLLADAFW::MeshPrimitive::POLYGONS)) {
292 COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
293 COLLADAFW::Polygons::VertexCountArray &vca = mpvc->getGroupedVerticesVertexCountArray();
296 int nonface_count = 0;
298 for (
uint j = 0; j < vca.getCount(); j++) {
309 if (hole_count > 0) {
311 "WARNING: Primitive %s in %s: %d holes not imported (unsupported)\n",
317 if (nonface_count > 0) {
319 "WARNING: Primitive %s in %s: %d faces with vertex count < 3 (rejected)\n",
326 else if (type == COLLADAFW::MeshPrimitive::LINES) {
331 COLLADAFW::MeshPrimitive::TRIANGLES,
332 COLLADAFW::MeshPrimitive::TRIANGLE_FANS))
334 fprintf(stderr,
"ERROR: Primitive type %s is not supported.\n", type_str);
342void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh,
Mesh *blender_mesh)
345 COLLADAFW::MeshVertexData &
pos = mesh->getPositions();
350 int stride =
pos.getStride(0);
355 blender_mesh->
verts_num =
pos.getFloatValues()->getCount() / stride;
359 for (
const int i : positions.index_range()) {
360 get_vector(positions[i],
pos, i, stride);
364bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp)
367 bool has_useable_normals =
false;
369 int normals_count = mp->getNormalIndices().getCount();
370 if (normals_count > 0) {
371 int index_count = mp->getPositionIndices().getCount();
372 if (index_count == normals_count) {
373 has_useable_normals =
true;
377 "Warning: Number of normals %d is different from the number of vertices %d, "
378 "skipping normals\n",
384 return has_useable_normals;
387bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp)
390 bool has_faces =
false;
391 int type = mp->getPrimitiveType();
393 case COLLADAFW::MeshPrimitive::TRIANGLES:
394 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
395 case COLLADAFW::MeshPrimitive::POLYLIST:
396 case COLLADAFW::MeshPrimitive::POLYGONS: {
410 std::string colname = collada_id;
411 int spos = colname.find(
"-mesh-colors-");
412 if (spos != std::string::npos) {
413 colname = colname.substr(spos + 13);
418void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh,
Mesh *mesh)
420 COLLADAFW::MeshPrimitiveArray &prim_arr = collada_mesh->getMeshPrimitives();
421 int total_poly_count = 0;
422 int total_loop_count = 0;
425 for (
int i = 0; i < prim_arr.getCount(); i++) {
426 COLLADAFW::MeshPrimitive *mp = prim_arr[i];
427 int type = mp->getPrimitiveType();
429 case COLLADAFW::MeshPrimitive::TRIANGLES:
430 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
431 case COLLADAFW::MeshPrimitive::POLYLIST:
432 case COLLADAFW::MeshPrimitive::POLYGONS: {
433 COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
434 size_t prim_poly_count = mpvc->getFaceCount();
436 size_t prim_loop_count = 0;
437 for (
int index = 0; index < prim_poly_count; index++) {
438 int vcount = get_vertex_count(mpvc, index);
440 prim_loop_count += vcount;
448 total_loop_count += prim_loop_count;
458 if (total_poly_count > 0) {
459 mesh->faces_num = total_poly_count;
460 mesh->corners_num = total_loop_count;
465 uint totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount();
466 for (
int i = 0; i < totuvset; i++) {
467 if (collada_mesh->getUVCoords().getLength(i) == 0) {
474 for (
int i = 0; i < totuvset; i++) {
475 COLLADAFW::MeshVertexData::InputInfos *info =
476 collada_mesh->getUVCoords().getInputInfosArray()[i];
477 COLLADAFW::String &uvname = info->mName;
486 int totcolset = collada_mesh->getColors().getInputInfosArray().getCount();
488 for (
int i = 0; i < totcolset; i++) {
489 COLLADAFW::MeshVertexData::InputInfos *info =
490 collada_mesh->getColors().getInputInfosArray()[i];
503uint MeshImporter::get_vertex_count(COLLADAFW::Polygons *mp,
int index)
505 int type = mp->getPrimitiveType();
508 case COLLADAFW::MeshPrimitive::TRIANGLES:
509 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS: {
513 case COLLADAFW::MeshPrimitive::POLYLIST:
514 case COLLADAFW::MeshPrimitive::POLYGONS: {
515 result = mp->getGroupedVerticesVertexCountArray()[index];
526uint MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh)
528 COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
529 int loose_edge_count = 0;
532 for (
int i = 0; i < prim_arr.getCount(); i++) {
533 COLLADAFW::MeshPrimitive *mp = prim_arr[i];
534 int type = mp->getPrimitiveType();
536 case COLLADAFW::MeshPrimitive::LINES: {
537 size_t prim_totface = mp->getFaceCount();
538 loose_edge_count += prim_totface;
545 return loose_edge_count;
548void MeshImporter::mesh_add_edges(
Mesh *mesh,
int len)
557 totedge = mesh->edges_num +
len;
569 mesh->edge_data = edge_data;
573 mesh->edges_num = totedge;
576void MeshImporter::read_lines(COLLADAFW::Mesh *mesh,
Mesh *blender_mesh)
578 uint loose_edge_count = get_loose_edge_count(mesh);
579 if (loose_edge_count > 0) {
584 mesh_add_edges(blender_mesh, loose_edge_count);
588 COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives();
590 for (
int index = 0; index < prim_arr.getCount(); index++) {
591 COLLADAFW::MeshPrimitive *mp = prim_arr[index];
593 int type = mp->getPrimitiveType();
594 if (type == COLLADAFW::MeshPrimitive::LINES) {
595 uint edge_count = mp->getFaceCount();
596 uint *indices = mp->getPositionIndices().getData();
598 for (
int j = 0; j < edge_count; j++, edge++) {
599 (*edge)[0] = indices[2 * j];
600 (*edge)[1] = indices[2 * j + 1];
607void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh,
614 allocate_poly_data(collada_mesh, mesh);
624 MaterialIdPrimitiveArrayMap mat_prim_map;
628 "material_index", bke::AttrDomain::Face);
630 "sharp_face", bke::AttrDomain::Face);
632 COLLADAFW::MeshPrimitiveArray &prim_arr = collada_mesh->getMeshPrimitives();
633 COLLADAFW::MeshVertexData &
nor = collada_mesh->getNormals();
635 for (i = 0; i < prim_arr.getCount(); i++) {
637 COLLADAFW::MeshPrimitive *mp = prim_arr[i];
640 size_t prim_faces_num = mp->getFaceCount();
641 uint *position_indices = mp->getPositionIndices().getData();
642 uint *normal_indices = mp->getNormalIndices().getData();
644 bool mp_has_normals = primitive_has_useable_normals(mp);
645 bool mp_has_faces = primitive_has_faces(mp);
647 int collada_meshtype = mp->getPrimitiveType();
649 if (collada_meshtype == COLLADAFW::MeshPrimitive::LINES) {
655 Primitive prim = {face_index, &material_indices.
span[face_index], 0};
662 if (collada_meshtype == COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
663 uint grouped_vertex_count = mp->getGroupedVertexElementsCount();
664 for (
uint group_index = 0; group_index < grouped_vertex_count; group_index++) {
665 uint first_vertex = position_indices[0];
666 uint first_normal = normal_indices[0];
667 uint vertex_count = mp->getGroupedVerticesVertexCount(group_index);
669 for (
uint vertex_index = 0; vertex_index < vertex_count - 2; vertex_index++) {
671 uint triangle_vertex_indices[3] = {
672 first_vertex, position_indices[1], position_indices[2]};
673 face_offsets[face_index] = loop_index;
674 set_poly_indices(&corner_verts[loop_index], loop_index, triangle_vertex_indices, 3);
676 if (mp_has_normals) {
678 uint vertex_normal_indices[3] = {first_normal, normal_indices[1], normal_indices[2]};
679 sharp_faces.span[face_index] = is_flat_face(vertex_normal_indices,
nor, 3);
689 if (mp_has_normals) {
693 position_indices += 2;
697 if (
ELEM(collada_meshtype,
698 COLLADAFW::MeshPrimitive::POLYLIST,
699 COLLADAFW::MeshPrimitive::POLYGONS,
700 COLLADAFW::MeshPrimitive::TRIANGLES))
702 COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
703 uint start_index = 0;
705 COLLADAFW::IndexListArray &index_list_array_uvcoord = mp->getUVCoordIndicesArray();
706 COLLADAFW::IndexListArray &index_list_array_vcolor = mp->getColorIndicesArray();
708 int invalid_loop_holes = 0;
709 for (
uint j = 0; j < prim_faces_num; j++) {
712 int vcount = get_vertex_count(mpvc, j);
717 face_offsets[face_index] = loop_index;
718 bool broken_loop = set_poly_indices(
719 &corner_verts[loop_index], loop_index, position_indices, vcount);
721 invalid_loop_holes += 1;
724 for (
uint uvset_index = 0; uvset_index < index_list_array_uvcoord.getCount();
727 COLLADAFW::IndexList &index_list = *index_list_array_uvcoord[uvset_index];
730 &mesh->corner_data,
CD_PROP_FLOAT2, index_list.getName(), mesh->corners_num));
731 if (mloopuv ==
nullptr) {
733 "Collada import: Mesh [%s] : Unknown reference to TEXCOORD [#%s].\n",
735 index_list.getName().c_str());
738 set_face_uv(mloopuv + loop_index,
741 *index_list_array_uvcoord[uvset_index],
746 if (mp_has_normals) {
749 sharp_faces.span[face_index] = is_flat_face(normal_indices,
nor, vcount);
751 if (use_custom_normals) {
753 float vert_normal[3];
754 uint *cur_normal = normal_indices;
755 for (
int k = 0; k < vcount; k++, cur_normal++) {
756 get_vector(vert_normal,
nor, *cur_normal, 3);
758 loop_normals.
append(vert_normal);
763 if (mp->hasColorIndices()) {
764 int vcolor_count = index_list_array_vcolor.getCount();
766 for (
uint vcolor_index = 0; vcolor_index < vcolor_count; vcolor_index++) {
768 COLLADAFW::IndexList &color_index_list = *mp->getColorIndices(vcolor_index);
772 if (mloopcol ==
nullptr) {
774 "Collada import: Mesh [%s] : Unknown reference to VCOLOR [#%s].\n",
776 color_index_list.getName().c_str());
779 set_vcol(mloopcol + loop_index, vcol, start_index, color_index_list, vcount);
785 loop_index += vcount;
786 start_index += vcount;
789 if (mp_has_normals) {
790 normal_indices += vcount;
793 position_indices += vcount;
796 if (invalid_loop_holes > 0) {
798 "Collada import: Mesh [%s] : contains %d unsupported loops (holes).\n",
805 mat_prim_map[mp->getMaterialId()].push_back(prim);
809 geom_uid_mat_mapping_map[collada_mesh->getUniqueId()] = mat_prim_map;
810 material_indices.
finish();
813void MeshImporter::get_vector(
float v[3], COLLADAFW::MeshVertexData &arr,
int i,
int stride)
817 switch (arr.getType()) {
818 case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
819 COLLADAFW::ArrayPrimitiveType<float> *values = arr.getFloatValues();
820 if (values->empty()) {
824 v[0] = (*values)[i++];
825 v[1] = (*values)[i++];
834 case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
835 COLLADAFW::ArrayPrimitiveType<double> *values = arr.getDoubleValues();
836 if (values->empty()) {
840 v[0] =
float((*values)[i++]);
841 v[1] =
float((*values)[i++]);
843 v[2] =
float((*values)[i]);
855bool MeshImporter::is_flat_face(
uint *nind, COLLADAFW::MeshVertexData &
nor,
int count)
859 get_vector(a,
nor, *nind, 3);
864 for (
int i = 1; i <
count; i++, nind++) {
865 get_vector(
b,
nor, *nind, 3);
870 if (dp < 0.99999f || dp > 1.00001f) {
880 if (uid_object_map.find(geom_uid) != uid_object_map.end()) {
881 return uid_object_map[geom_uid];
888 if (uid_mesh_map.find(geom_uid) != uid_mesh_map.end()) {
889 return uid_mesh_map[geom_uid];
896 if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end()) {
897 return &this->mesh_geom_map[mesh_name];
904 for (
const int vert_i : mesh->corner_verts()) {
905 if (vert_i >= mesh->verts_num) {
926 for (
int index = 0; index < ob1->
totcol; index++) {
930 if (ob1->
matbits[index] == 0) {
933 if (ob1->
mat[index] != ob2->
mat[index]) {
947 for (
int index = 0; index < ob->
totcol; index++) {
949 mesh->mat[index] = ob->
mat[index];
958 for (
int index = 0; index < ob->
totcol; index++) {
960 ob->
mat[index] =
nullptr;
964std::vector<Object *> MeshImporter::get_all_users_of(
Mesh *reference_mesh)
966 std::vector<Object *> mesh_users;
967 for (
Object *ob : imported_objects) {
971 if (mesh == reference_mesh) {
972 mesh_users.push_back(ob);
981 for (
Object *ob : imported_objects) {
989 bool can_move =
true;
990 std::vector<Object *> mesh_users = get_all_users_of(mesh);
991 if (mesh_users.size() > 1) {
992 Object *ref_ob = mesh_users[0];
993 for (
int index = 1; index < mesh_users.size(); index++) {
1001 for (
Object *
object : mesh_users) {
1012 COLLADAFW::MaterialBinding cmaterial,
1013 std::map<COLLADAFW::UniqueId, Material *> &uid_material_map,
1015 const COLLADAFW::UniqueId *geom_uid,
1018 const COLLADAFW::UniqueId &ma_uid = cmaterial.getReferencedMaterial();
1021 if (uid_material_map.find(ma_uid) == uid_material_map.end()) {
1023 fprintf(stderr,
"Cannot find material by UID.\n");
1028 materials_mapped_to_geom.insert(
1029 std::pair<COLLADAFW::UniqueId, COLLADAFW::UniqueId>(*geom_uid, ma_uid));
1031 Material *ma = uid_material_map[ma_uid];
1038 MaterialIdPrimitiveArrayMap &mat_prim_map = geom_uid_mat_mapping_map[*geom_uid];
1039 COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId();
1042 if (mat_prim_map.find(mat_id) != mat_prim_map.end()) {
1044 std::vector<Primitive> &prims = mat_prim_map[mat_id];
1046 std::vector<Primitive>::iterator it;
1048 for (it = prims.begin(); it != prims.end(); it++) {
1049 Primitive &prim = *it;
1051 for (
int i = 0; i < prim.faces_num; i++) {
1052 prim.material_indices[i] = mat_index;
1059 COLLADAFW::Node *node,
1060 COLLADAFW::InstanceGeometry *geom,
1062 std::map<COLLADAFW::UniqueId, Material *> &uid_material_map)
1064 const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
1072 fprintf(stderr,
"Couldn't find a mesh UID by controller's UID.\n");
1078 if (uid_mesh_map.find(*geom_uid) == uid_mesh_map.end()) {
1081 fprintf(stderr,
"Couldn't find a mesh by UID.\n");
1085 if (!uid_mesh_map[*geom_uid]) {
1090 const std::string &
id = node->getName().empty() ? node->getOriginalId() : node->getName();
1091 const char *name =
id.length() ?
id.c_str() :
nullptr;
1098 uid_object_map[*geom_uid] = ob;
1099 imported_objects.push_back(ob);
1103 Mesh *new_mesh = uid_mesh_map[*geom_uid];
1112 COLLADAFW::MaterialBindingArray &mat_array = geom->getMaterialBindings();
1115 for (
uint i = 0; i < mat_array.getCount(); i++) {
1117 if (mat_array[i].getReferencedMaterial().isValid()) {
1121 fprintf(stderr,
"invalid referenced material for %s\n", mat_array[i].
getName().c_str());
1134 if (geom->getType() != COLLADAFW::Geometry::GEO_TYPE_MESH) {
1136 fprintf(stderr,
"Mesh type %s is not supported\n",
bc_geomTypeToStr(geom->getType()));
1140 COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh *)geom;
1142 if (!is_nice_mesh(mesh)) {
1147 const std::string &str_geom_id = mesh->getName().empty() ? mesh->getOriginalId() :
1155 this->uid_mesh_map[mesh->getUniqueId()] = blender_mesh;
1156 this->mesh_geom_map[std::string(blender_mesh->
id.
name)] = str_geom_id;
1158 read_vertices(mesh, blender_mesh);
1161 read_polys(mesh, blender_mesh, loop_normals);
1168 if (use_custom_normals && !loop_normals.
is_empty()) {
1174 fprintf(stderr,
"Can't apply custom normals, encountered invalid loop vert indices!\n");
1180 "Can't apply custom normals, mesh->corners_num != loop_normals.size() (%d != %d)\n",
1182 int(loop_normals.
size()));
1186 reinterpret_cast<float(*)[3]
>(loop_normals.
data()));
1192 read_lines(mesh, blender_mesh);
void BKE_id_attributes_default_color_set(struct ID *id, const char *name)
void BKE_id_attributes_active_color_set(struct ID *id, const char *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, int totelem)
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
display list (or rather multi purpose list) stuff.
void BKE_id_free_us(Main *bmain, void *idv) ATTR_NONNULL()
General operations, lookup, etc. for materials.
void BKE_object_material_assign(struct Main *bmain, struct Object *ob, struct Material *ma, short act, int assign_type)
void BKE_mesh_set_custom_normals(Mesh *mesh, float(*r_custom_loop_normals)[3])
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)
#define ID_REAL_USERS(id)
Read Guarded memory(de)allocation.
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
COLLADAFW::UniqueId * get_geometry_uid(const COLLADAFW::UniqueId &controller_uid)
virtual Mesh * get_mesh_by_geom_uid(const COLLADAFW::UniqueId &geom_uid)
virtual Object * get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid)
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)
UVDataWrapper(COLLADAFW::MeshVertexData &vdata)
void getUV(int uv_index, float *uv)
void get_vcol(int v_index, MLoopCol *mloopcol)
VCOLDataWrapper(COLLADAFW::MeshVertexData &vdata)
void append(const T &value)
Object * bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name)
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
#define unit_float_to_uchar_clamp(val)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
Frequency::GEOMETRY nor[]
MutableVArraySpan< T > span
ccl_device_inline int abs(int x)