Merge branch 'master' into fix_gltf2_camera_fov
This commit is contained in:
@@ -448,7 +448,7 @@ void ColladaExporter::WriteLight(size_t pIndex) {
|
||||
PushTag();
|
||||
switch (light->mType) {
|
||||
case aiLightSource_AMBIENT:
|
||||
WriteAmbienttLight(light);
|
||||
WriteAmbientLight(light);
|
||||
break;
|
||||
case aiLightSource_DIRECTIONAL:
|
||||
WriteDirectionalLight(light);
|
||||
@@ -543,7 +543,7 @@ void ColladaExporter::WriteSpotLight(const aiLight *const light) {
|
||||
mOutput << startstr << "</spot>" << endstr;
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteAmbienttLight(const aiLight *const light) {
|
||||
void ColladaExporter::WriteAmbientLight(const aiLight *const light) {
|
||||
|
||||
const aiColor3D &color = light->mColorAmbient;
|
||||
mOutput << startstr << "<ambient>" << endstr;
|
||||
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
void WritePointLight(const aiLight *const light);
|
||||
void WriteDirectionalLight(const aiLight *const light);
|
||||
void WriteSpotLight(const aiLight *const light);
|
||||
void WriteAmbienttLight(const aiLight *const light);
|
||||
void WriteAmbientLight(const aiLight *const light);
|
||||
|
||||
/// Writes the controller library
|
||||
void WriteControllerLibrary();
|
||||
|
||||
@@ -666,7 +666,7 @@ struct ChannelEntry {
|
||||
const Collada::Accessor *mTimeAccessor; ///> Collada accessor to the time values
|
||||
const Collada::Data *mTimeData; ///> Source data array for the time values
|
||||
const Collada::Accessor *mValueAccessor; ///> Collada accessor to the key value values
|
||||
const Collada::Data *mValueData; ///> Source datat array for the key value values
|
||||
const Collada::Data *mValueData; ///> Source data array for the key value values
|
||||
|
||||
ChannelEntry() :
|
||||
mChannel(),
|
||||
|
||||
@@ -762,6 +762,7 @@ void ColladaParser::ReadControllerWeights(XmlNode &node, Collada::Controller &pC
|
||||
if (text == nullptr) {
|
||||
throw DeadlyImportError("Out of data while reading <vertex_weights>");
|
||||
}
|
||||
SkipSpacesAndLineEnd(&text);
|
||||
it->first = strtoul10(text, &text);
|
||||
SkipSpacesAndLineEnd(&text);
|
||||
if (*text == 0) {
|
||||
|
||||
@@ -154,7 +154,6 @@ private:
|
||||
const unsigned int column;
|
||||
};
|
||||
|
||||
// XXX should use C++11's unique_ptr - but assimp's need to keep working with 03
|
||||
typedef const Token* TokenPtr;
|
||||
typedef std::vector< TokenPtr > TokenList;
|
||||
|
||||
|
||||
@@ -162,8 +162,11 @@ void AnimResolver::UpdateAnimRangeSetup() {
|
||||
const double my_last = (*it).keys.back().time;
|
||||
|
||||
const double delta = my_last - my_first;
|
||||
if (delta == 0.0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const size_t old_size = (*it).keys.size();
|
||||
|
||||
const float value_delta = (*it).keys.back().value - (*it).keys.front().value;
|
||||
|
||||
// NOTE: We won't handle reset, linear and constant here.
|
||||
@@ -176,8 +179,7 @@ void AnimResolver::UpdateAnimRangeSetup() {
|
||||
case LWO::PrePostBehaviour_Oscillate: {
|
||||
const double start_time = delta - std::fmod(my_first - first, delta);
|
||||
std::vector<LWO::Key>::iterator n = std::find_if((*it).keys.begin(), (*it).keys.end(),
|
||||
[start_time](double t) { return start_time > t; }),
|
||||
m;
|
||||
[start_time](double t) { return start_time > t; }), m;
|
||||
|
||||
size_t ofs = 0;
|
||||
if (n != (*it).keys.end()) {
|
||||
|
||||
@@ -39,8 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||
#if !(ASSIMP_BUILD_NO_EXPORT || ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
#if !defined ASSIMP_BUILD_NO_M3D_IMPORTER || !(defined ASSIMP_BUILD_NO_EXPORT || defined ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
|
||||
#include "M3DWrapper.h"
|
||||
|
||||
@@ -149,4 +148,3 @@ void M3DWrapper::ClearSave() {
|
||||
} // namespace Assimp
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -47,8 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef AI_M3DWRAPPER_H_INC
|
||||
#define AI_M3DWRAPPER_H_INC
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||
#if !(ASSIMP_BUILD_NO_EXPORT || ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
#if !defined ASSIMP_BUILD_NO_M3D_IMPORTER || !(defined ASSIMP_BUILD_NO_EXPORT || defined ASSIMP_BUILD_NO_M3D_EXPORTER)
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -126,7 +125,6 @@ inline m3d_t *M3DWrapper::M3D() const {
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif
|
||||
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||
|
||||
#endif // AI_M3DWRAPPER_H_INC
|
||||
|
||||
@@ -270,8 +270,8 @@ if (NOT ASSIMP_NO_EXPORT)
|
||||
# ASSIMP_BUILD_XXX_EXPORTER to TRUE for each exporter
|
||||
OPTION(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_EXPORTER values" TRUE)
|
||||
|
||||
# macro to add the CMake Option ADD_ASSIMP_IMPORTER_<name> which enables compile of loader
|
||||
# this way selective loaders can be compiled (reduces filesize + compile time)
|
||||
# macro to add the CMake Option ADD_ASSIMP_EXPORTER_<name> which enables compilation of an exporter
|
||||
# this way selective exporters can be compiled (reduces filesize + compile time)
|
||||
MACRO(ADD_ASSIMP_EXPORTER name)
|
||||
IF (ASSIMP_NO_EXPORT)
|
||||
set(ASSIMP_EXPORTER_ENABLED FALSE)
|
||||
|
||||
@@ -105,7 +105,11 @@ void JoinVerticesProcess::Execute( aiScene* pScene) {
|
||||
|
||||
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.
|
||||
// Try to reuse the lookup table from the last step.
|
||||
const static float epsilon = 1e-5f;
|
||||
@@ -124,10 +128,6 @@ bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((lhs.texcoords[0] - rhs.texcoords[0]).SquareLength() > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((lhs.tangent - rhs.tangent).SquareLength() > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
@@ -136,19 +136,18 @@ bool areVerticesEqual(const Vertex &lhs, const Vertex &rhs, bool complex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Usually we won't have vertex colors or multiple UVs, so we can skip from here
|
||||
// Actually this increases runtime performance slightly, at least if branch
|
||||
// prediction is on our side.
|
||||
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 < numUVChannels; i++) {
|
||||
if ((lhs.texcoords[i] - rhs.texcoords[i]).SquareLength() > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < numColorChannels; i++) {
|
||||
if (GetColorDifference(lhs.colors[i], rhs.colors[i]) > squareEpsilon) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -241,9 +240,16 @@ struct std::hash<Vertex> {
|
||||
//template specialization for std::equal_to for Vertex
|
||||
template<>
|
||||
struct std::equal_to<Vertex> {
|
||||
equal_to(unsigned numUVChannels, unsigned numColorChannels) :
|
||||
mNumUVChannels(numUVChannels),
|
||||
mNumColorChannels(numColorChannels) {}
|
||||
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
|
||||
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);
|
||||
}
|
||||
}
|
||||
// a map that maps a vertix to its new index
|
||||
std::unordered_map<Vertex,int> vertex2Index;
|
||||
// a map that maps a vertex to its new index
|
||||
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
|
||||
vertex2Index.reserve(pMesh->mNumVertices);
|
||||
// Now check each vertex if it brings something new to the table
|
||||
|
||||
Reference in New Issue
Block a user