Merge branch 'master' into fix-build-without-armaturepopulate-post-process
commit
d331a7e5d4
|
@ -762,6 +762,7 @@ void ColladaParser::ReadControllerWeights(XmlNode &node, Collada::Controller &pC
|
||||||
if (text == nullptr) {
|
if (text == nullptr) {
|
||||||
throw DeadlyImportError("Out of data while reading <vertex_weights>");
|
throw DeadlyImportError("Out of data while reading <vertex_weights>");
|
||||||
}
|
}
|
||||||
|
SkipSpacesAndLineEnd(&text);
|
||||||
it->first = strtoul10(text, &text);
|
it->first = strtoul10(text, &text);
|
||||||
SkipSpacesAndLineEnd(&text);
|
SkipSpacesAndLineEnd(&text);
|
||||||
if (*text == 0) {
|
if (*text == 0) {
|
||||||
|
|
|
@ -39,8 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
#if !defined ASSIMP_BUILD_NO_M3D_IMPORTER || !(defined ASSIMP_BUILD_NO_EXPORT || defined ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||||
#if !(ASSIMP_BUILD_NO_EXPORT || ASSIMP_BUILD_NO_M3D_EXPORTER)
|
|
||||||
|
|
||||||
#include "M3DWrapper.h"
|
#include "M3DWrapper.h"
|
||||||
|
|
||||||
|
@ -149,4 +148,3 @@ void M3DWrapper::ClearSave() {
|
||||||
} // namespace Assimp
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
|
@ -47,8 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_M3DWRAPPER_H_INC
|
#ifndef AI_M3DWRAPPER_H_INC
|
||||||
#define AI_M3DWRAPPER_H_INC
|
#define AI_M3DWRAPPER_H_INC
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
#if !defined ASSIMP_BUILD_NO_M3D_IMPORTER || !(defined ASSIMP_BUILD_NO_EXPORT || defined ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||||
#if !(ASSIMP_BUILD_NO_EXPORT || ASSIMP_BUILD_NO_M3D_EXPORTER)
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -126,7 +125,6 @@ inline m3d_t *M3DWrapper::M3D() const {
|
||||||
|
|
||||||
} // namespace Assimp
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
|
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||||
|
|
||||||
#endif // AI_M3DWRAPPER_H_INC
|
#endif // AI_M3DWRAPPER_H_INC
|
||||||
|
|
|
@ -105,7 +105,11 @@ void JoinVerticesProcess::Execute( aiScene* pScene) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) {
|
bool areVerticesEqual(
|
||||||
|
const Vertex &lhs,
|
||||||
|
const Vertex &rhs,
|
||||||
|
unsigned numUVChannels,
|
||||||
|
unsigned numColorChannels) {
|
||||||
// A little helper to find locally close vertices faster.
|
// A little helper to find locally close vertices faster.
|
||||||
// Try to reuse the lookup table from the last step.
|
// Try to reuse the lookup table from the last step.
|
||||||
const static float epsilon = 1e-5f;
|
const static float epsilon = 1e-5f;
|
||||||
|
@ -124,10 +128,6 @@ bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((lhs.texcoords[0] - rhs.texcoords[0]).SquareLength() > squareEpsilon) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((lhs.tangent - rhs.tangent).SquareLength() > squareEpsilon) {
|
if ((lhs.tangent - rhs.tangent).SquareLength() > squareEpsilon) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -136,19 +136,18 @@ bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Usually we won't have vertex colors or multiple UVs, so we can skip from here
|
for (unsigned i = 0; i < numUVChannels; i++) {
|
||||||
// Actually this increases runtime performance slightly, at least if branch
|
if ((lhs.texcoords[i] - rhs.texcoords[i]).SquareLength() > squareEpsilon) {
|
||||||
// prediction is on our side.
|
return false;
|
||||||
if (complex) {
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
if (i > 0 && (lhs.texcoords[i] - rhs.texcoords[i]).SquareLength() > squareEpsilon) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (GetColorDifference(lhs.colors[i], rhs.colors[i]) > squareEpsilon) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < numColorChannels; i++) {
|
||||||
|
if (GetColorDifference(lhs.colors[i], rhs.colors[i]) > squareEpsilon) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,9 +240,16 @@ struct std::hash<Vertex> {
|
||||||
//template specialization for std::equal_to for Vertex
|
//template specialization for std::equal_to for Vertex
|
||||||
template<>
|
template<>
|
||||||
struct std::equal_to<Vertex> {
|
struct std::equal_to<Vertex> {
|
||||||
|
equal_to(unsigned numUVChannels, unsigned numColorChannels) :
|
||||||
|
mNumUVChannels(numUVChannels),
|
||||||
|
mNumColorChannels(numColorChannels) {}
|
||||||
bool operator()(const Vertex &lhs, const Vertex &rhs) const {
|
bool operator()(const Vertex &lhs, const Vertex &rhs) const {
|
||||||
return areVerticesEqual(lhs, rhs, false);
|
return areVerticesEqual(lhs, rhs, mNumUVChannels, mNumColorChannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned mNumUVChannels;
|
||||||
|
unsigned mNumColorChannels;
|
||||||
};
|
};
|
||||||
// now start the JoinVerticesProcess
|
// now start the JoinVerticesProcess
|
||||||
int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
||||||
|
@ -316,8 +322,13 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
||||||
uniqueAnimatedVertices[animMeshIndex].reserve(pMesh->mNumVertices);
|
uniqueAnimatedVertices[animMeshIndex].reserve(pMesh->mNumVertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// a map that maps a vertix to its new index
|
// a map that maps a vertex to its new index
|
||||||
std::unordered_map<Vertex,int> vertex2Index;
|
const auto numBuckets = pMesh->mNumVertices;
|
||||||
|
const auto hasher = std::hash<Vertex>();
|
||||||
|
const auto comparator = std::equal_to<Vertex>(
|
||||||
|
pMesh->GetNumUVChannels(),
|
||||||
|
pMesh->GetNumColorChannels());
|
||||||
|
std::unordered_map<Vertex, int> vertex2Index(numBuckets, hasher, comparator);
|
||||||
// we can not end up with more vertices than we started with
|
// we can not end up with more vertices than we started with
|
||||||
vertex2Index.reserve(pMesh->mNumVertices);
|
vertex2Index.reserve(pMesh->mNumVertices);
|
||||||
// Now check each vertex if it brings something new to the table
|
// Now check each vertex if it brings something new to the table
|
||||||
|
|
Loading…
Reference in New Issue