Changeset View
Changeset View
Standalone View
Standalone View
source/blender/alembic/intern/abc_customdata.cc
| Show All 20 Lines | |||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| * | * | ||||
| */ | */ | ||||
| #include "abc_customdata.h" | #include "abc_customdata.h" | ||||
| #include <Alembic/AbcGeom/All.h> | #include <Alembic/AbcGeom/All.h> | ||||
| #include <algorithm> | #include <algorithm> | ||||
| #if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1900) | |||||
| #include <unordered_map> | #include <unordered_map> | ||||
sergey: I would keep `uv_index_map` as a typedef, otherwise it's ridiculous to type `std… | |||||
| typedef std::unordered_map<uint64_t, int> uv_index_map; | |||||
| #else | |||||
| #include <map> | |||||
| typedef std::map<uint64_t, int> uv_index_map; | |||||
| #endif | |||||
| extern "C" { | extern "C" { | ||||
| #include "DNA_customdata_types.h" | #include "DNA_customdata_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "BLI_math_base.h" | #include "BLI_math_base.h" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | for (int i = 0; i < num_poly; ++i) { | ||||
| uvidx[cnt] = cnt; | uvidx[cnt] = cnt; | ||||
| uvs[cnt][0] = loopuvpoly->uv[0]; | uvs[cnt][0] = loopuvpoly->uv[0]; | ||||
| uvs[cnt][1] = loopuvpoly->uv[1]; | uvs[cnt][1] = loopuvpoly->uv[1]; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| uv_index_map idx_map; | std::unordered_map<uint64_t, int> idx_map; | ||||
| int idx_count = 0; | int idx_count = 0; | ||||
| for (int i = 0; i < num_poly; ++i) { | for (int i = 0; i < num_poly; ++i) { | ||||
| MPoly ¤t_poly = polygons[i]; | MPoly ¤t_poly = polygons[i]; | ||||
| MLoopUV *loopuvpoly = mloopuv_array + current_poly.loopstart + current_poly.totloop; | MLoopUV *loopuvpoly = mloopuv_array + current_poly.loopstart + current_poly.totloop; | ||||
| for (int j = 0; j < current_poly.totloop; ++j) { | for (int j = 0; j < current_poly.totloop; ++j) { | ||||
| loopuvpoly--; | loopuvpoly--; | ||||
| Imath::V2f uv(loopuvpoly->uv[0], loopuvpoly->uv[1]); | Imath::V2f uv(loopuvpoly->uv[0], loopuvpoly->uv[1]); | ||||
| uint64_t k = uv_to_hash_key(uv); | uint64_t k = uv_to_hash_key(uv); | ||||
| uv_index_map::iterator it = idx_map.find(k); | std::unordered_map<uint64_t, int>::iterator it = idx_map.find(k); | ||||
| if (it == idx_map.end()) { | if (it == idx_map.end()) { | ||||
| idx_map[k] = idx_count; | idx_map[k] = idx_count; | ||||
| uvs.push_back(uv); | uvs.push_back(uv); | ||||
| uvidx.push_back(idx_count++); | uvidx.push_back(idx_count++); | ||||
| } | } | ||||
| else { | else { | ||||
| uvidx.push_back(it->second); | uvidx.push_back(it->second); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 346 Lines • Show Last 20 Lines | |||||
I would keep uv_index_map as a typedef, otherwise it's ridiculous to type std::unordered_map<uint64_t, int>every time.