diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-25 10:04:52 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-25 11:26:27 +0300 |
commit | 891949cbb47143420f4324cb60efc05ef5d70b39 (patch) | |
tree | fe70a45612ae96f9ce1f37378ef5ff035d3127f5 /source/blender/io/collada/MeshImporter.cpp | |
parent | c9e35c2ced92082c86f1ecb9ecd16c6230218c7c (diff) |
Cleanup: use 'u' prefixed integer types for brevity & cast style
To use function style cast '(unsigned char)x' can't be replaced by
'unsigned char(x)'.
Diffstat (limited to 'source/blender/io/collada/MeshImporter.cpp')
-rw-r--r-- | source/blender/io/collada/MeshImporter.cpp | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index 4b7c4275568..fea57698261 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -208,7 +208,7 @@ MeshImporter::MeshImporter(UnitConverter *unitconv, } bool MeshImporter::set_poly_indices( - MPoly *mpoly, MLoop *mloop, int loop_index, const unsigned int *indices, int loop_count) + MPoly *mpoly, MLoop *mloop, int loop_index, const uint *indices, int loop_count) { mpoly->loopstart = loop_index; mpoly->totloop = loop_count; @@ -276,7 +276,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) const std::string &name = bc_get_dae_name(mesh); - for (unsigned int i = 0; i < prim_arr.getCount(); i++) { + for (uint i = 0; i < prim_arr.getCount(); i++) { COLLADAFW::MeshPrimitive *mp = prim_arr[i]; COLLADAFW::MeshPrimitive::PrimitiveType type = mp->getPrimitiveType(); @@ -292,7 +292,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) int hole_count = 0; int nonface_count = 0; - for (unsigned int j = 0; j < vca.getCount(); j++) { + for (uint j = 0; j < vca.getCount(); j++) { int count = vca[j]; if (abs(count) < 3) { nonface_count++; @@ -455,7 +455,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) CustomData_add_layer(&me->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, me->totpoly); CustomData_add_layer(&me->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, me->totloop); - unsigned int totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount(); + uint totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount(); for (int i = 0; i < totuvset; i++) { if (collada_mesh->getUVCoords().getLength(i) == 0) { totuvset = 0; @@ -490,7 +490,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) } } -unsigned int MeshImporter::get_vertex_count(COLLADAFW::Polygons *mp, int index) +uint MeshImporter::get_vertex_count(COLLADAFW::Polygons *mp, int index) { int type = mp->getPrimitiveType(); int result; @@ -513,7 +513,7 @@ unsigned int MeshImporter::get_vertex_count(COLLADAFW::Polygons *mp, int index) return result; } -unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) +uint MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) { COLLADAFW::MeshPrimitiveArray &prim_arr = mesh->getMeshPrimitives(); int loose_edge_count = 0; @@ -571,11 +571,11 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) { - unsigned int loose_edge_count = get_loose_edge_count(mesh); + uint loose_edge_count = get_loose_edge_count(mesh); if (loose_edge_count > 0) { - unsigned int face_edge_count = me->totedge; - /* unsigned int total_edge_count = loose_edge_count + face_edge_count; */ /* UNUSED */ + uint face_edge_count = me->totedge; + /* uint total_edge_count = loose_edge_count + face_edge_count; */ /* UNUSED */ mesh_add_edges(me, loose_edge_count); MutableSpan<MEdge> edges = me->edges_for_write(); @@ -588,8 +588,8 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) int type = mp->getPrimitiveType(); if (type == COLLADAFW::MeshPrimitive::LINES) { - unsigned int edge_count = mp->getFaceCount(); - unsigned int *indices = mp->getPositionIndices().getData(); + uint edge_count = mp->getFaceCount(); + uint *indices = mp->getPositionIndices().getData(); for (int j = 0; j < edge_count; j++, med++) { med->flag |= ME_LOOSEEDGE; @@ -605,7 +605,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me, blender::Vector<blender::float3> &loop_normals) { - unsigned int i; + uint i; allocate_poly_data(collada_mesh, me); @@ -632,8 +632,8 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, /* faces */ size_t prim_totpoly = mp->getFaceCount(); - unsigned int *position_indices = mp->getPositionIndices().getData(); - unsigned int *normal_indices = mp->getNormalIndices().getData(); + uint *position_indices = mp->getPositionIndices().getData(); + uint *normal_indices = mp->getNormalIndices().getData(); bool mp_has_normals = primitive_has_useable_normals(mp); bool mp_has_faces = primitive_has_faces(mp); @@ -649,22 +649,21 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, * XXX In particular the handling of the normal_indices is very wrong */ /* TODO: UV, vertex color and custom normal support */ if (collada_meshtype == COLLADAFW::MeshPrimitive::TRIANGLE_FANS) { - unsigned int grouped_vertex_count = mp->getGroupedVertexElementsCount(); - for (unsigned int group_index = 0; group_index < grouped_vertex_count; group_index++) { - unsigned int first_vertex = position_indices[0]; /* Store first trifan vertex */ - unsigned int first_normal = normal_indices[0]; /* Store first trifan vertex normal */ - unsigned int vertex_count = mp->getGroupedVerticesVertexCount(group_index); + uint grouped_vertex_count = mp->getGroupedVertexElementsCount(); + for (uint group_index = 0; group_index < grouped_vertex_count; group_index++) { + uint first_vertex = position_indices[0]; /* Store first trifan vertex */ + uint first_normal = normal_indices[0]; /* Store first trifan vertex normal */ + uint vertex_count = mp->getGroupedVerticesVertexCount(group_index); - for (unsigned int vertex_index = 0; vertex_index < vertex_count - 2; vertex_index++) { + for (uint vertex_index = 0; vertex_index < vertex_count - 2; vertex_index++) { /* For each triangle store indices of its 3 vertices */ - unsigned int triangle_vertex_indices[3] = { + uint triangle_vertex_indices[3] = { first_vertex, position_indices[1], position_indices[2]}; set_poly_indices(mpoly, mloop, loop_index, triangle_vertex_indices, 3); if (mp_has_normals) { /* vertex normals, same implementation as for the triangles */ /* The same for vertices normals. */ - unsigned int vertex_normal_indices[3] = { - first_normal, normal_indices[1], normal_indices[2]}; + uint vertex_normal_indices[3] = {first_normal, normal_indices[1], normal_indices[2]}; if (!is_flat_face(vertex_normal_indices, nor, 3)) { mpoly->flag |= ME_SMOOTH; } @@ -693,13 +692,13 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, collada_meshtype == COLLADAFW::MeshPrimitive::POLYGONS || collada_meshtype == COLLADAFW::MeshPrimitive::TRIANGLES) { COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp; - unsigned int start_index = 0; + uint start_index = 0; COLLADAFW::IndexListArray &index_list_array_uvcoord = mp->getUVCoordIndicesArray(); COLLADAFW::IndexListArray &index_list_array_vcolor = mp->getColorIndicesArray(); int invalid_loop_holes = 0; - for (unsigned int j = 0; j < prim_totpoly; j++) { + for (uint j = 0; j < prim_totpoly; j++) { /* Vertices in polygon: */ int vcount = get_vertex_count(mpvc, j); @@ -712,7 +711,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, invalid_loop_holes += 1; } - for (unsigned int uvset_index = 0; uvset_index < index_list_array_uvcoord.getCount(); + for (uint uvset_index = 0; uvset_index < index_list_array_uvcoord.getCount(); uvset_index++) { /* get mtface by face index and uv set index */ COLLADAFW::IndexList &index_list = *index_list_array_uvcoord[uvset_index]; @@ -743,7 +742,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, if (use_custom_normals) { /* Store the custom normals for later application. */ float vert_normal[3]; - unsigned int *cur_normal = normal_indices; + uint *cur_normal = normal_indices; for (int k = 0; k < vcount; k++, cur_normal++) { get_vector(vert_normal, nor, *cur_normal, 3); normalize_v3(vert_normal); @@ -755,7 +754,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, if (mp->hasColorIndices()) { int vcolor_count = index_list_array_vcolor.getCount(); - for (unsigned int vcolor_index = 0; vcolor_index < vcolor_count; vcolor_index++) { + for (uint vcolor_index = 0; vcolor_index < vcolor_count; vcolor_index++) { COLLADAFW::IndexList &color_index_list = *mp->getColorIndices(vcolor_index); COLLADAFW::String colname = extract_vcolname(color_index_list.getName()); @@ -847,7 +846,7 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData &arr, int i, } } -bool MeshImporter::is_flat_face(unsigned int *nind, COLLADAFW::MeshVertexData &nor, int count) +bool MeshImporter::is_flat_face(uint *nind, COLLADAFW::MeshVertexData &nor, int count) { float a[3], b[3]; @@ -1107,7 +1106,7 @@ Object *MeshImporter::create_mesh_object( COLLADAFW::MaterialBindingArray &mat_array = geom->getMaterialBindings(); /* loop through geom's materials */ - for (unsigned int i = 0; i < mat_array.getCount(); i++) { + for (uint i = 0; i < mat_array.getCount(); i++) { if (mat_array[i].getReferencedMaterial().isValid()) { assign_material_to_geom(mat_array[i], uid_material_map, ob, geom_uid, i); |