Merge branch 'master' into gltf_fixes
commit
e737adde50
|
@ -96,8 +96,9 @@ void ScenePreprocessor::ProcessMesh(aiMesh *mesh) {
|
||||||
if (!mesh->mTextureCoords[i]) {
|
if (!mesh->mTextureCoords[i]) {
|
||||||
mesh->mNumUVComponents[i] = 0;
|
mesh->mNumUVComponents[i] = 0;
|
||||||
} else {
|
} else {
|
||||||
if (!mesh->mNumUVComponents[i])
|
if (!mesh->mNumUVComponents[i]) {
|
||||||
mesh->mNumUVComponents[i] = 2;
|
mesh->mNumUVComponents[i] = 2;
|
||||||
|
}
|
||||||
|
|
||||||
aiVector3D *p = mesh->mTextureCoords[i], *end = p + mesh->mNumVertices;
|
aiVector3D *p = mesh->mTextureCoords[i], *end = p + mesh->mNumVertices;
|
||||||
|
|
||||||
|
@ -105,16 +106,19 @@ void ScenePreprocessor::ProcessMesh(aiMesh *mesh) {
|
||||||
// as if they were 2D channels .. just in case an application doesn't handle
|
// as if they were 2D channels .. just in case an application doesn't handle
|
||||||
// this case
|
// this case
|
||||||
if (2 == mesh->mNumUVComponents[i]) {
|
if (2 == mesh->mNumUVComponents[i]) {
|
||||||
for (; p != end; ++p)
|
for (; p != end; ++p) {
|
||||||
p->z = 0.f;
|
p->z = 0.f;
|
||||||
|
}
|
||||||
} else if (1 == mesh->mNumUVComponents[i]) {
|
} else if (1 == mesh->mNumUVComponents[i]) {
|
||||||
for (; p != end; ++p)
|
for (; p != end; ++p) {
|
||||||
p->z = p->y = 0.f;
|
p->z = p->y = 0.f;
|
||||||
|
}
|
||||||
} else if (3 == mesh->mNumUVComponents[i]) {
|
} else if (3 == mesh->mNumUVComponents[i]) {
|
||||||
// Really 3D coordinates? Check whether the third coordinate is != 0 for at least one element
|
// Really 3D coordinates? Check whether the third coordinate is != 0 for at least one element
|
||||||
for (; p != end; ++p) {
|
for (; p != end; ++p) {
|
||||||
if (p->z != 0)
|
if (p->z != 0) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (p == end) {
|
if (p == end) {
|
||||||
ASSIMP_LOG_WARN("ScenePreprocessor: UVs are declared to be 3D but they're obviously not. Reverting to 2D.");
|
ASSIMP_LOG_WARN("ScenePreprocessor: UVs are declared to be 3D but they're obviously not. Reverting to 2D.");
|
||||||
|
@ -151,7 +155,6 @@ void ScenePreprocessor::ProcessMesh(aiMesh *mesh) {
|
||||||
|
|
||||||
// If tangents and normals are given but no bitangents compute them
|
// If tangents and normals are given but no bitangents compute them
|
||||||
if (mesh->mTangents && mesh->mNormals && !mesh->mBitangents) {
|
if (mesh->mTangents && mesh->mNormals && !mesh->mBitangents) {
|
||||||
|
|
||||||
mesh->mBitangents = new aiVector3D[mesh->mNumVertices];
|
mesh->mBitangents = new aiVector3D[mesh->mNumVertices];
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
||||||
mesh->mBitangents[i] = mesh->mNormals[i] ^ mesh->mTangents[i];
|
mesh->mBitangents[i] = mesh->mNormals[i] ^ mesh->mTangents[i];
|
||||||
|
@ -165,11 +168,9 @@ void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) {
|
||||||
for (unsigned int i = 0; i < anim->mNumChannels; ++i) {
|
for (unsigned int i = 0; i < anim->mNumChannels; ++i) {
|
||||||
aiNodeAnim *channel = anim->mChannels[i];
|
aiNodeAnim *channel = anim->mChannels[i];
|
||||||
|
|
||||||
/* If the exact duration of the animation is not given
|
// If the exact duration of the animation is not given
|
||||||
* compute it now.
|
// compute it now.
|
||||||
*/
|
|
||||||
if (anim->mDuration == -1.) {
|
if (anim->mDuration == -1.) {
|
||||||
|
|
||||||
// Position keys
|
// Position keys
|
||||||
for (unsigned int j = 0; j < channel->mNumPositionKeys; ++j) {
|
for (unsigned int j = 0; j < channel->mNumPositionKeys; ++j) {
|
||||||
aiVectorKey &key = channel->mPositionKeys[j];
|
aiVectorKey &key = channel->mPositionKeys[j];
|
||||||
|
@ -192,11 +193,10 @@ void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether the animation channel has no rotation
|
// Check whether the animation channel has no rotation
|
||||||
* or position tracks. In this case we generate a dummy
|
// or position tracks. In this case we generate a dummy
|
||||||
* track from the information we have in the transformation
|
// track from the information we have in the transformation
|
||||||
* matrix of the corresponding node.
|
// matrix of the corresponding node.
|
||||||
*/
|
|
||||||
if (!channel->mNumRotationKeys || !channel->mNumPositionKeys || !channel->mNumScalingKeys) {
|
if (!channel->mNumRotationKeys || !channel->mNumPositionKeys || !channel->mNumScalingKeys) {
|
||||||
// Find the node that belongs to this animation
|
// Find the node that belongs to this animation
|
||||||
aiNode *node = scene->mRootNode->FindNode(channel->mNodeName);
|
aiNode *node = scene->mRootNode->FindNode(channel->mNodeName);
|
||||||
|
@ -210,6 +210,10 @@ void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) {
|
||||||
|
|
||||||
// No rotation keys? Generate a dummy track
|
// No rotation keys? Generate a dummy track
|
||||||
if (!channel->mNumRotationKeys) {
|
if (!channel->mNumRotationKeys) {
|
||||||
|
if (channel->mRotationKeys) {
|
||||||
|
delete[] channel->mRotationKeys;
|
||||||
|
channel->mRotationKeys = nullptr;
|
||||||
|
}
|
||||||
ai_assert(!channel->mRotationKeys);
|
ai_assert(!channel->mRotationKeys);
|
||||||
channel->mNumRotationKeys = 1;
|
channel->mNumRotationKeys = 1;
|
||||||
channel->mRotationKeys = new aiQuatKey[1];
|
channel->mRotationKeys = new aiQuatKey[1];
|
||||||
|
@ -225,6 +229,10 @@ void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) {
|
||||||
|
|
||||||
// No scaling keys? Generate a dummy track
|
// No scaling keys? Generate a dummy track
|
||||||
if (!channel->mNumScalingKeys) {
|
if (!channel->mNumScalingKeys) {
|
||||||
|
if (channel->mScalingKeys) {
|
||||||
|
delete[] channel->mScalingKeys;
|
||||||
|
channel->mScalingKeys = nullptr;
|
||||||
|
}
|
||||||
ai_assert(!channel->mScalingKeys);
|
ai_assert(!channel->mScalingKeys);
|
||||||
channel->mNumScalingKeys = 1;
|
channel->mNumScalingKeys = 1;
|
||||||
channel->mScalingKeys = new aiVectorKey[1];
|
channel->mScalingKeys = new aiVectorKey[1];
|
||||||
|
@ -240,6 +248,10 @@ void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) {
|
||||||
|
|
||||||
// No position keys? Generate a dummy track
|
// No position keys? Generate a dummy track
|
||||||
if (!channel->mNumPositionKeys) {
|
if (!channel->mNumPositionKeys) {
|
||||||
|
if (channel->mPositionKeys) {
|
||||||
|
delete[] channel->mPositionKeys;
|
||||||
|
channel->mPositionKeys = nullptr;
|
||||||
|
}
|
||||||
ai_assert(!channel->mPositionKeys);
|
ai_assert(!channel->mPositionKeys);
|
||||||
channel->mNumPositionKeys = 1;
|
channel->mNumPositionKeys = 1;
|
||||||
channel->mPositionKeys = new aiVectorKey[1];
|
channel->mPositionKeys = new aiVectorKey[1];
|
||||||
|
|
Loading…
Reference in New Issue