Skip to content

Commit

Permalink
Merge pull request #9 from assimp/master
Browse files Browse the repository at this point in the history
Update master from assimp
  • Loading branch information
ardenpm committed Oct 25, 2019
2 parents 8a4c355 + bd25cc7 commit fa8ab3b
Show file tree
Hide file tree
Showing 12 changed files with 768 additions and 74 deletions.
3 changes: 3 additions & 0 deletions assimpTargets.cmake.in
Expand Up @@ -5,6 +5,9 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
# Required for the evaluation of "if(@BUILD_SHARED_LIBS@)" below to function
cmake_policy(SET CMP0012 NEW)

#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
Expand Down
158 changes: 94 additions & 64 deletions code/Collada/ColladaExporter.cpp

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion code/Common/BaseImporter.cpp
Expand Up @@ -67,7 +67,20 @@ using namespace Assimp;
// Constructor to be privately used by Importer
BaseImporter::BaseImporter() AI_NO_EXCEPT
: m_progress() {
// nothing to do here
/**
* Assimp Importer
* unit conversions available
* if you need another measurment unit add it below.
* it's currently defined in assimp that we prefer meters.
*
* NOTE: Initialised here rather than in the header file
* to workaround a VS2013 bug with brace initialisers
* */
importerUnits[ImporterUnits::M] = 1.0;
importerUnits[ImporterUnits::CM] = 0.01;
importerUnits[ImporterUnits::MM] = 0.001;
importerUnits[ImporterUnits::INCHES] = 0.0254;
importerUnits[ImporterUnits::FEET] = 0.3048;
}

// ------------------------------------------------------------------------------------------------
Expand Down
18 changes: 18 additions & 0 deletions code/glTF/glTFImporter.cpp
Expand Up @@ -170,6 +170,8 @@ void glTFImporter::ImportMaterials(glTF::Asset& r) {

if (mScene->mNumMaterials == 0) {
mScene->mNumMaterials = 1;
// Delete the array of length zero created above.
delete[] mScene->mMaterials;
mScene->mMaterials = new aiMaterial*[1];
mScene->mMaterials[0] = new aiMaterial();
}
Expand Down Expand Up @@ -330,6 +332,10 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)

case PrimitiveMode_LINES: {
nFaces = count / 2;
if (nFaces * 2 != count) {
ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped.");
count = nFaces * 2;
}
faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 2) {
SetFace(faces[i / 2], data.GetUInt(i), data.GetUInt(i + 1));
Expand All @@ -353,6 +359,10 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)

case PrimitiveMode_TRIANGLES: {
nFaces = count / 3;
if (nFaces * 3 != count) {
ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped.");
count = nFaces * 3;
}
faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 3) {
SetFace(faces[i / 3], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
Expand Down Expand Up @@ -395,6 +405,10 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)

case PrimitiveMode_LINES: {
nFaces = count / 2;
if (nFaces * 2 != count) {
ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped.");
count = nFaces * 2;
}
faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 2) {
SetFace(faces[i / 2], i, i + 1);
Expand All @@ -418,6 +432,10 @@ void glTFImporter::ImportMeshes(glTF::Asset& r)

case PrimitiveMode_TRIANGLES: {
nFaces = count / 3;
if (nFaces * 3 != count) {
ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped.");
count = nFaces * 3;
}
faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 3) {
SetFace(faces[i / 3], i, i + 1, i + 2);
Expand Down
16 changes: 16 additions & 0 deletions code/glTF2/glTF2Importer.cpp
Expand Up @@ -530,6 +530,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)

case PrimitiveMode_LINES: {
nFaces = count / 2;
if (nFaces * 2 != count) {
ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped.");
count = nFaces * 2;
}
faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 2) {
SetFace(faces[i / 2], data.GetUInt(i), data.GetUInt(i + 1));
Expand All @@ -553,6 +557,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)

case PrimitiveMode_TRIANGLES: {
nFaces = count / 3;
if (nFaces * 3 != count) {
ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped.");
count = nFaces * 3;
}
faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 3) {
SetFace(faces[i / 3], data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
Expand Down Expand Up @@ -604,6 +612,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)

case PrimitiveMode_LINES: {
nFaces = count / 2;
if (nFaces * 2 != count) {
ASSIMP_LOG_WARN("The number of vertices was not compatible with the LINES mode. Some vertices were dropped.");
count = nFaces * 2;
}
faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 2) {
SetFace(faces[i / 2], i, i + 1);
Expand All @@ -627,6 +639,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset& r)

case PrimitiveMode_TRIANGLES: {
nFaces = count / 3;
if (nFaces * 3 != count) {
ASSIMP_LOG_WARN("The number of vertices was not compatible with the TRIANGLES mode. Some vertices were dropped.");
count = nFaces * 3;
}
faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 3) {
SetFace(faces[i / 3], i, i + 1, i + 2);
Expand Down
15 changes: 6 additions & 9 deletions include/assimp/BaseImporter.h
Expand Up @@ -196,16 +196,13 @@ class ASSIMP_API BaseImporter {
/**
* Assimp Importer
* unit conversions available
* if you need another measurment unit add it below.
* it's currently defined in assimp that we prefer meters.
* NOTE: Valid options are initialised in the
* constructor in the implementation file to
* work around a VS2013 compiler bug if support
* for that compiler is dropped in the future
* initialisation can be moved back here
* */
std::map<ImporterUnits, double> importerUnits = {
{ImporterUnits::M, 1},
{ImporterUnits::CM, 0.01},
{ImporterUnits::MM, 0.001},
{ImporterUnits::INCHES, 0.0254},
{ImporterUnits::FEET, 0.3048}
};
std::map<ImporterUnits, double> importerUnits;

virtual void SetApplicationUnits( const ImporterUnits& unit )
{
Expand Down
Binary file added test/models/glTF/IncorrectVertexArrays/Cube.bin
Binary file not shown.

0 comments on commit fa8ab3b

Please sign in to comment.