summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp')
-rw-r--r--src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp101
1 files changed, 51 insertions, 50 deletions
diff --git a/src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp b/src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp
index ec7aa8985..e9f427113 100644
--- a/src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp
+++ b/src/3rdparty/assimp/code/SkeletonMeshBuilder.cpp
@@ -2,7 +2,8 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2016, assimp team
+Copyright (c) 2006-2017, assimp team
+
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -85,7 +86,7 @@ SkeletonMeshBuilder::SkeletonMeshBuilder( aiScene* pScene, aiNode* root, bool bK
void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode)
{
// add a joint entry for the node.
- const unsigned int vertexStartIndex = mVertices.size();
+ const unsigned int vertexStartIndex = static_cast<unsigned int>(mVertices.size());
// now build the geometry.
if( pNode->mNumChildren > 0 && !mKnobsOnly)
@@ -96,31 +97,31 @@ void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode)
// find a suitable coordinate system
const aiMatrix4x4& childTransform = pNode->mChildren[a]->mTransformation;
aiVector3D childpos( childTransform.a4, childTransform.b4, childTransform.c4);
- float distanceToChild = childpos.Length();
- if( distanceToChild < 0.0001f)
+ ai_real distanceToChild = childpos.Length();
+ if( distanceToChild < 0.0001)
continue;
aiVector3D up = aiVector3D( childpos).Normalize();
- aiVector3D orth( 1.0f, 0.0f, 0.0f);
- if( std::fabs( orth * up) > 0.99f)
- orth.Set( 0.0f, 1.0f, 0.0f);
+ aiVector3D orth( 1.0, 0.0, 0.0);
+ if( std::fabs( orth * up) > 0.99)
+ orth.Set( 0.0, 1.0, 0.0);
aiVector3D front = (up ^ orth).Normalize();
aiVector3D side = (front ^ up).Normalize();
- unsigned int localVertexStart = mVertices.size();
- mVertices.push_back( -front * distanceToChild * 0.1f);
+ unsigned int localVertexStart = static_cast<unsigned int>(mVertices.size());
+ mVertices.push_back( -front * distanceToChild * (ai_real)0.1);
mVertices.push_back( childpos);
- mVertices.push_back( -side * distanceToChild * 0.1f);
- mVertices.push_back( -side * distanceToChild * 0.1f);
+ mVertices.push_back( -side * distanceToChild * (ai_real)0.1);
+ mVertices.push_back( -side * distanceToChild * (ai_real)0.1);
mVertices.push_back( childpos);
- mVertices.push_back( front * distanceToChild * 0.1f);
- mVertices.push_back( front * distanceToChild * 0.1f);
+ mVertices.push_back( front * distanceToChild * (ai_real)0.1);
+ mVertices.push_back( front * distanceToChild * (ai_real)0.1);
mVertices.push_back( childpos);
- mVertices.push_back( side * distanceToChild * 0.1f);
- mVertices.push_back( side * distanceToChild * 0.1f);
+ mVertices.push_back( side * distanceToChild * (ai_real)0.1);
+ mVertices.push_back( side * distanceToChild * (ai_real)0.1);
mVertices.push_back( childpos);
- mVertices.push_back( -front * distanceToChild * 0.1f);
+ mVertices.push_back( -front * distanceToChild * (ai_real)0.1);
mFaces.push_back( Face( localVertexStart + 0, localVertexStart + 1, localVertexStart + 2));
mFaces.push_back( Face( localVertexStart + 3, localVertexStart + 4, localVertexStart + 5));
@@ -132,33 +133,33 @@ void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode)
{
// if the node has no children, it's an end node. Put a little knob there instead
aiVector3D ownpos( pNode->mTransformation.a4, pNode->mTransformation.b4, pNode->mTransformation.c4);
- float sizeEstimate = ownpos.Length() * 0.18f;
-
- mVertices.push_back( aiVector3D( -sizeEstimate, 0.0f, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, sizeEstimate, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, 0.0f, -sizeEstimate));
- mVertices.push_back( aiVector3D( 0.0f, sizeEstimate, 0.0f));
- mVertices.push_back( aiVector3D( sizeEstimate, 0.0f, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, 0.0f, -sizeEstimate));
- mVertices.push_back( aiVector3D( sizeEstimate, 0.0f, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, -sizeEstimate, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, 0.0f, -sizeEstimate));
- mVertices.push_back( aiVector3D( 0.0f, -sizeEstimate, 0.0f));
- mVertices.push_back( aiVector3D( -sizeEstimate, 0.0f, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, 0.0f, -sizeEstimate));
-
- mVertices.push_back( aiVector3D( -sizeEstimate, 0.0f, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, 0.0f, sizeEstimate));
- mVertices.push_back( aiVector3D( 0.0f, sizeEstimate, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, sizeEstimate, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, 0.0f, sizeEstimate));
- mVertices.push_back( aiVector3D( sizeEstimate, 0.0f, 0.0f));
- mVertices.push_back( aiVector3D( sizeEstimate, 0.0f, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, 0.0f, sizeEstimate));
- mVertices.push_back( aiVector3D( 0.0f, -sizeEstimate, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, -sizeEstimate, 0.0f));
- mVertices.push_back( aiVector3D( 0.0f, 0.0f, sizeEstimate));
- mVertices.push_back( aiVector3D( -sizeEstimate, 0.0f, 0.0f));
+ ai_real sizeEstimate = ownpos.Length() * ai_real( 0.18 );
+
+ mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate));
+ mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0));
+ mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate));
+ mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate));
+ mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0));
+ mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate));
+
+ mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate));
+ mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate));
+ mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0));
+ mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate));
+ mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0));
+ mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate));
+ mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0));
mFaces.push_back( Face( vertexStartIndex + 0, vertexStartIndex + 1, vertexStartIndex + 2));
mFaces.push_back( Face( vertexStartIndex + 3, vertexStartIndex + 4, vertexStartIndex + 5));
@@ -170,7 +171,7 @@ void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode)
mFaces.push_back( Face( vertexStartIndex + 21, vertexStartIndex + 22, vertexStartIndex + 23));
}
- unsigned int numVertices = mVertices.size() - vertexStartIndex;
+ unsigned int numVertices = static_cast<unsigned int>(mVertices.size() - vertexStartIndex);
if( numVertices > 0)
{
// create a bone affecting all the newly created vertices
@@ -187,7 +188,7 @@ void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode)
bone->mNumWeights = numVertices;
bone->mWeights = new aiVertexWeight[numVertices];
for( unsigned int a = 0; a < numVertices; a++)
- bone->mWeights[a] = aiVertexWeight( vertexStartIndex + a, 1.0f);
+ bone->mWeights[a] = aiVertexWeight( vertexStartIndex + a, 1.0);
// HACK: (thom) transform all vertices to the bone's local space. Should be done before adding
// them to the array, but I'm tired now and I'm annoyed.
@@ -208,14 +209,14 @@ aiMesh* SkeletonMeshBuilder::CreateMesh()
aiMesh* mesh = new aiMesh();
// add points
- mesh->mNumVertices = mVertices.size();
+ mesh->mNumVertices = static_cast<unsigned int>(mVertices.size());
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
std::copy( mVertices.begin(), mVertices.end(), mesh->mVertices);
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
// add faces
- mesh->mNumFaces = mFaces.size();
+ mesh->mNumFaces = static_cast<unsigned int>(mFaces.size());
mesh->mFaces = new aiFace[mesh->mNumFaces];
for( unsigned int a = 0; a < mesh->mNumFaces; a++)
{
@@ -232,15 +233,15 @@ aiMesh* SkeletonMeshBuilder::CreateMesh()
aiVector3D nor = ((mVertices[inface.mIndices[2]] - mVertices[inface.mIndices[0]]) ^
(mVertices[inface.mIndices[1]] - mVertices[inface.mIndices[0]]));
- if (nor.Length() < 1e-5f) /* ensure that FindInvalidData won't remove us ...*/
- nor = aiVector3D(1.f,0.f,0.f);
+ if (nor.Length() < 1e-5) /* ensure that FindInvalidData won't remove us ...*/
+ nor = aiVector3D(1.0,0.0,0.0);
for (unsigned int n = 0; n < 3; ++n)
mesh->mNormals[inface.mIndices[n]] = nor;
}
// add the bones
- mesh->mNumBones = mBones.size();
+ mesh->mNumBones = static_cast<unsigned int>(mBones.size());
mesh->mBones = new aiBone*[mesh->mNumBones];
std::copy( mBones.begin(), mBones.end(), mesh->mBones);