[Bf-blender-cvs] [be6e1ed92ad] soc-2019-fast-io: [Fast import/export] Fixed index of normals
Hugo Sales
noreply at git.blender.org
Fri Jul 12 17:56:01 CEST 2019
Commit: be6e1ed92add58c214660d703b6834dd04aff8a2
Author: Hugo Sales
Date: Fri Jul 12 14:59:30 2019 +0100
Branches: soc-2019-fast-io
https://developer.blender.org/rBbe6e1ed92add58c214660d703b6834dd04aff8a2
[Fast import/export] Fixed index of normals
===================================================================
M release/datafiles/locale
M release/scripts/addons
M release/scripts/addons_contrib
M source/blender/editors/io/intern/iterators.hpp
M source/blender/editors/io/intern/obj.cpp
M source/tools
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 0f771b0f380..6a6b84fd505 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 0f771b0f380a1ae21d859416043c6119f66e40c9
+Subproject commit 6a6b84fd50538a65276c729b5d396be615bc79f2
diff --git a/release/scripts/addons b/release/scripts/addons
index aa3366b7805..ccf80c0e047 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit aa3366b7805bbe4d1afee890bda81b6d91bd47be
+Subproject commit ccf80c0e047d80a519b077af660aaf06e226ab94
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 0aa23a4d617..f00d4fbe848 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 0aa23a4d6177bed4c12392c81d0b767a8b35fe61
+Subproject commit f00d4fbe84852e40af281267c06dc21bafb5df49
diff --git a/source/blender/editors/io/intern/iterators.hpp b/source/blender/editors/io/intern/iterators.hpp
index fbe8b878208..6c68906684f 100644
--- a/source/blender/editors/io/intern/iterators.hpp
+++ b/source/blender/editors/io/intern/iterators.hpp
@@ -408,31 +408,24 @@ struct points_of_nurbs_iter : pointer_iterator_base<BPoint> {
// Iterator over the UVs of a mesh (as `const std::array<float, 2>`)
struct uv_iter : pointer_iterator_base<MLoopUV> {
- uv_iter(const Mesh *const m, const size_t &total)
- : pointer_iterator_base(m->mloopuv, m->mloopuv ? m->totloop : 0), total(total)
+ uv_iter(const Mesh *const m) : pointer_iterator_base(m->mloopuv, m->mloopuv ? m->totloop : 0)
{
}
- uv_iter(const pointer_iterator_base<MLoopUV> &pi, const size_t &total)
- : pointer_iterator_base(pi), total(total)
+ uv_iter(const pointer_iterator_base<MLoopUV> &pi) : pointer_iterator_base(pi)
{
}
uv_iter begin() const
{
- return {{this->first, this->size, this->first}, total};
+ return {{this->first, this->size, this->first}};
}
uv_iter end() const
{
- return {{this->first + this->size, this->size, this->first}, total};
+ return {{this->first + this->size, this->size, this->first}};
}
inline const std::array<float, 2> operator*()
{
return {this->curr->uv[0], this->curr->uv[1]};
}
- size_t index() const
- {
- return total;
- }
- const size_t &total;
};
// Iterator over the normals of mesh
@@ -518,10 +511,6 @@ struct normal_iter {
}
}
}
- size_t index() const
- {
- return ml->v;
- }
const Mesh *const mesh;
const MPoly *mp;
const MLoop *ml;
@@ -569,10 +558,6 @@ struct transformed_normal_iter {
mul_v3_m4v3(no.data(), mat, no.data());
return no;
}
- size_t index() const
- {
- return ni.ml->v;
- }
normal_iter ni;
Mat mat;
};
@@ -604,12 +589,14 @@ struct deduplicated_iterator {
if (this->it != this->it.end()) {
// Reserve space so we don't constantly allocate
dedup_pair.second.reserve(reserve);
- auto p = dedup_pair.first.insert(std::make_pair(*this->it, this->it.index()));
+ auto p = dedup_pair.first.insert(std::make_pair(*this->it, total));
// Need to insert the first element, because we need to dereference before incrementing
// dedup_pair.second.insert(dedup_pair.second.end(), reserve - dedup_pair.second.size(), {});
dedup_pair.second.push_back(p.first);
- ++total;
- ++this->it;
+ if (p.second) {
+ ++total;
+ }
+ // ++this->it;
}
}
deduplicated_iterator begin() const
@@ -630,7 +617,7 @@ struct deduplicated_iterator {
if (this->it == this->it.end())
return *this;
// try to insert it into the set
- auto p = dedup_pair.first.insert(std::make_pair(*this->it, this->it.index()));
+ auto p = dedup_pair.first.insert(std::make_pair(*this->it, total));
// push the set::iterator onto the back of the mapping vector
dedup_pair.second.push_back(p.first);
// If we actually inserted in the set
@@ -683,7 +670,7 @@ struct deduplicated_normal_iter : deduplicated_iterator<no_key_t, transformed_no
struct deduplicated_uv_iter : deduplicated_iterator<uv_key_t, uv_iter> {
deduplicated_uv_iter(const Mesh *const mesh, size_t &total, dedup_pair_t<uv_key_t> &dp)
: deduplicated_iterator<uv_key_t, uv_iter>(
- mesh, dp, total, total + mesh->totloop, uv_iter{mesh, total})
+ mesh, dp, total, total + mesh->totloop, uv_iter{mesh})
{
}
// The last element in the mapping vector. Requires we insert the first element
diff --git a/source/blender/editors/io/intern/obj.cpp b/source/blender/editors/io/intern/obj.cpp
index 6f6a43a44de..85577218a6a 100644
--- a/source/blender/editors/io/intern/obj.cpp
+++ b/source/blender/editors/io/intern/obj.cpp
@@ -161,7 +161,7 @@ bool OBJ_export_materials(bContext *C,
ss << "], '"
<< path_reference_mode[((OBJExportSettings *)settings->format_specific)->path_mode].identifier
<< "')";
- std::cerr << "Running '" << ss.str() << "'\n";
+ std::cerr << "DEBUG: Running '" << ss.str() << "'\n";
return BPY_execute_string(C, imports, ss.str().c_str());
#else
return false;
@@ -278,7 +278,7 @@ bool OBJ_export_meshes(bContext *UNUSED(C),
if (settings->export_uvs) {
for (Mesh_export &me : meshes) {
if (me.mesh->mloopuv != nullptr) {
- me.uv_offset = uv_total;
+ me.uv_offset = uv_mapping.size();
// TODO someone Is T47010 still relevant?
if (format_specific->dedup_uvs) {
for (const std::array<float, 2> &uv :
@@ -288,8 +288,7 @@ bool OBJ_export_meshes(bContext *UNUSED(C),
}
else {
uv_total += me.mesh->totloop;
- for (const std::array<float, 2> &uv :
- common::uv_iter{me.mesh, uv_total /* const reference */}) {
+ for (const std::array<float, 2> &uv : common::uv_iter{me.mesh}) {
fprintf(file, "vt %.6g %.6g\n", uv[0], uv[1]);
}
}
@@ -305,7 +304,7 @@ bool OBJ_export_meshes(bContext *UNUSED(C),
}
me.mat[3][3] = 1.0f;
normalize_m4(me.mat);
- me.no_offset = no_total;
+ me.no_offset = no_mapping.size();
if (format_specific->dedup_normals) {
for (const std::array<float, 3> &no :
common::deduplicated_normal_iter(me.mesh, no_total, no_mapping_pair, me.mat)) {
@@ -345,9 +344,17 @@ bool OBJ_export_meshes(bContext *UNUSED(C),
}
size_t poly_index = 0;
- int state_smooth = -1;
+ int state_smooth = -1, state_mat = -1;
for (auto pi = common::poly_iter(me.mesh); pi != pi.end(); ++pi, ++poly_index) {
const MPoly &p = *pi;
+
+ if (settings->export_materials) {
+ if (p.mat_nr != state_mat) {
+ fprintf(file, "usemtl %s\n", me.mesh->mat[p.mat_nr]->id.name + 2);
+ state_mat = p.mat_nr;
+ }
+ }
+
// Smooth indices start at 1, so 0 is not a valid index
int smooth = (p.flag & ME_SMOOTH) ? 1 : 0;
if (smooth && smooth_groups) {
diff --git a/source/tools b/source/tools
index aa9cc18913a..8598818108d 160000
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit aa9cc18913aca559e932d5b7894e3c222ccffae4
+Subproject commit 8598818108ddaf35e30d2a2dbd408ad371e41eb5
More information about the Bf-blender-cvs
mailing list