|
@@ -44,42 +44,46 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
namespace Assimp {
|
|
namespace Assimp {
|
|
|
|
|
|
-aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh)
|
|
|
|
|
|
+aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh, bool needPositions, bool needNormals, bool needTangents, bool needColors, bool needTexCoords)
|
|
{
|
|
{
|
|
aiAnimMesh *animesh = new aiAnimMesh;
|
|
aiAnimMesh *animesh = new aiAnimMesh;
|
|
animesh->mNumVertices = mesh->mNumVertices;
|
|
animesh->mNumVertices = mesh->mNumVertices;
|
|
- if (mesh->mVertices) {
|
|
|
|
|
|
+ if (needPositions && mesh->mVertices) {
|
|
animesh->mVertices = new aiVector3D[animesh->mNumVertices];
|
|
animesh->mVertices = new aiVector3D[animesh->mNumVertices];
|
|
std::memcpy(animesh->mVertices, mesh->mVertices, mesh->mNumVertices * sizeof(aiVector3D));
|
|
std::memcpy(animesh->mVertices, mesh->mVertices, mesh->mNumVertices * sizeof(aiVector3D));
|
|
}
|
|
}
|
|
- if (mesh->mNormals) {
|
|
|
|
|
|
+ if (needNormals && mesh->mNormals) {
|
|
animesh->mNormals = new aiVector3D[animesh->mNumVertices];
|
|
animesh->mNormals = new aiVector3D[animesh->mNumVertices];
|
|
std::memcpy(animesh->mNormals, mesh->mNormals, mesh->mNumVertices * sizeof(aiVector3D));
|
|
std::memcpy(animesh->mNormals, mesh->mNormals, mesh->mNumVertices * sizeof(aiVector3D));
|
|
}
|
|
}
|
|
- if (mesh->mTangents) {
|
|
|
|
|
|
+ if (needTangents && mesh->mTangents) {
|
|
animesh->mTangents = new aiVector3D[animesh->mNumVertices];
|
|
animesh->mTangents = new aiVector3D[animesh->mNumVertices];
|
|
std::memcpy(animesh->mTangents, mesh->mTangents, mesh->mNumVertices * sizeof(aiVector3D));
|
|
std::memcpy(animesh->mTangents, mesh->mTangents, mesh->mNumVertices * sizeof(aiVector3D));
|
|
}
|
|
}
|
|
- if (mesh->mBitangents) {
|
|
|
|
|
|
+ if (needTangents && mesh->mBitangents) {
|
|
animesh->mBitangents = new aiVector3D[animesh->mNumVertices];
|
|
animesh->mBitangents = new aiVector3D[animesh->mNumVertices];
|
|
std::memcpy(animesh->mBitangents, mesh->mBitangents, mesh->mNumVertices * sizeof(aiVector3D));
|
|
std::memcpy(animesh->mBitangents, mesh->mBitangents, mesh->mNumVertices * sizeof(aiVector3D));
|
|
}
|
|
}
|
|
|
|
|
|
- for (int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
|
|
|
- if (mesh->mColors[i]) {
|
|
|
|
- animesh->mColors[i] = new aiColor4D[animesh->mNumVertices];
|
|
|
|
- std::memcpy(animesh->mColors[i], mesh->mColors[i], mesh->mNumVertices * sizeof(aiColor4D));
|
|
|
|
- } else {
|
|
|
|
- animesh->mColors[i] = nullptr;
|
|
|
|
|
|
+ if (needColors) {
|
|
|
|
+ for (int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
|
|
|
+ if (mesh->mColors[i]) {
|
|
|
|
+ animesh->mColors[i] = new aiColor4D[animesh->mNumVertices];
|
|
|
|
+ std::memcpy(animesh->mColors[i], mesh->mColors[i], mesh->mNumVertices * sizeof(aiColor4D));
|
|
|
|
+ } else {
|
|
|
|
+ animesh->mColors[i] = nullptr;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
|
|
|
- if (mesh->mTextureCoords[i]) {
|
|
|
|
- animesh->mTextureCoords[i] = new aiVector3D[animesh->mNumVertices];
|
|
|
|
- std::memcpy(animesh->mTextureCoords[i], mesh->mTextureCoords[i], mesh->mNumVertices * sizeof(aiVector3D));
|
|
|
|
- } else {
|
|
|
|
- animesh->mTextureCoords[i] = nullptr;
|
|
|
|
|
|
+ if (needTexCoords) {
|
|
|
|
+ for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
|
|
|
+ if (mesh->mTextureCoords[i]) {
|
|
|
|
+ animesh->mTextureCoords[i] = new aiVector3D[animesh->mNumVertices];
|
|
|
|
+ std::memcpy(animesh->mTextureCoords[i], mesh->mTextureCoords[i], mesh->mNumVertices * sizeof(aiVector3D));
|
|
|
|
+ } else {
|
|
|
|
+ animesh->mTextureCoords[i] = nullptr;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return animesh;
|
|
return animesh;
|