Merge branch 'master' into fix_pretransform_vertices_with_cameras

pull/5056/head
Kim Kulling 2023-04-04 17:21:05 +02:00 committed by GitHub
commit 89ccc89298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 148 additions and 79 deletions

View File

@ -418,7 +418,6 @@ void B3DImporter::ReadTRIS(int v0) {
ASSIMP_LOG_ERROR("Bad triangle index: i0=", i0, ", i1=", i1, ", i2=", i2);
#endif
Fail("Bad triangle index");
continue;
}
face->mNumIndices = 3;
face->mIndices = new unsigned[3];

View File

@ -152,7 +152,7 @@ void FBXConverter::ConvertRootNode() {
mSceneOut->mRootNode->mName.Set(unique_name);
// root has ID 0
ConvertNodes(0L, mSceneOut->mRootNode, mSceneOut->mRootNode);
ConvertNodes(0L, mSceneOut->mRootNode, mSceneOut->mRootNode, aiMatrix4x4());
}
static std::string getAncestorBaseName(const aiNode *node) {
@ -196,7 +196,7 @@ struct FBXConverter::PotentialNode {
/// todo: get bone from stack
/// todo: make map of aiBone* to aiNode*
/// then update convert clusters to the new format
void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node) {
void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node, const aiMatrix4x4 &globalTransform) {
const std::vector<const Connection *> &conns = doc.GetConnectionsByDestinationSequenced(id, "Model");
std::vector<PotentialNode> nodes;
@ -290,14 +290,15 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node)
}
// recursion call - child nodes
ConvertNodes(model->ID(), last_parent, root_node);
aiMatrix4x4 newGlobalMatrix = globalTransform * nodes_chain.front().mNode->mTransformation;
ConvertNodes(model->ID(), last_parent, root_node, newGlobalMatrix);
if (doc.Settings().readLights) {
ConvertLights(*model, node_name);
}
if (doc.Settings().readCameras) {
ConvertCameras(*model, node_name);
ConvertCameras(*model, node_name, newGlobalMatrix);
}
nodes.push_back(std::move(nodes_chain.front()));
@ -327,12 +328,14 @@ void FBXConverter::ConvertLights(const Model &model, const std::string &orig_nam
}
}
void FBXConverter::ConvertCameras(const Model &model, const std::string &orig_name) {
void FBXConverter::ConvertCameras(const Model &model,
const std::string &orig_name,
const aiMatrix4x4 &transform) {
const std::vector<const NodeAttribute *> &node_attrs = model.GetAttributes();
for (const NodeAttribute *attr : node_attrs) {
const Camera *const cam = dynamic_cast<const Camera *>(attr);
if (cam) {
ConvertCamera(*cam, orig_name);
ConvertCamera(*cam, orig_name, transform);
}
}
}
@ -413,7 +416,9 @@ void FBXConverter::ConvertLight(const Light &light, const std::string &orig_name
}
}
void FBXConverter::ConvertCamera(const Camera &cam, const std::string &orig_name) {
void FBXConverter::ConvertCamera(const Camera &cam,
const std::string &orig_name,
aiMatrix4x4 transform) {
cameras.push_back(new aiCamera());
aiCamera *const out_camera = cameras.back();
@ -421,9 +426,16 @@ void FBXConverter::ConvertCamera(const Camera &cam, const std::string &orig_name
out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
aiVector3D pos = cam.Position();
out_camera->mLookAt = cam.InterestPosition();
out_camera->mUp = pos + cam.UpVector();
transform.Inverse();
pos *= transform;
out_camera->mLookAt *= transform;
out_camera->mUp *= transform;
out_camera->mLookAt -= pos;
out_camera->mUp -= pos;
out_camera->mPosition = aiVector3D(0.0f);
out_camera->mLookAt = aiVector3D(1.0f, 0.0f, 0.0f);
out_camera->mUp = aiVector3D(0.0f, 1.0f, 0.0f);
out_camera->mHorizontalFOV = AI_DEG_TO_RAD(cam.FieldOfView());

View File

@ -134,19 +134,22 @@ private:
// ------------------------------------------------------------------------------------------------
// collect and assign child nodes
void ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node);
void ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node,
const aiMatrix4x4 &globalTransform);
// ------------------------------------------------------------------------------------------------
void ConvertLights(const Model& model, const std::string &orig_name );
// ------------------------------------------------------------------------------------------------
void ConvertCameras(const Model& model, const std::string &orig_name );
void ConvertCameras(const Model& model, const std::string &orig_name,
const aiMatrix4x4 &transform);
// ------------------------------------------------------------------------------------------------
void ConvertLight( const Light& light, const std::string &orig_name );
// ------------------------------------------------------------------------------------------------
void ConvertCamera( const Camera& cam, const std::string &orig_name );
void ConvertCamera(const Camera& cam, const std::string &orig_name,
aiMatrix4x4 transform);
// ------------------------------------------------------------------------------------------------
void GetUniqueName( const std::string &name, std::string& uniqueName );

View File

@ -345,7 +345,7 @@ void LWOImporter::ConvertMaterial(const LWO::Surface &surf, aiMaterial *pcMat) {
// (the diffuse value is just a scaling factor)
// If a diffuse texture is set, we set this value to 1.0
clr = (b && false ? aiColor3D(1.0, 1.0, 1.0) : surf.mColor);
clr = (b ? aiColor3D(1.0, 1.0, 1.0) : surf.mColor);
clr.r *= surf.mDiffuseValue;
clr.g *= surf.mDiffuseValue;
clr.b *= surf.mDiffuseValue;

View File

@ -565,7 +565,7 @@ struct Accessor : public Object {
inline size_t GetMaxByteSize();
template <class T>
void ExtractData(T *&outData);
size_t ExtractData(T *&outData, const std::vector<unsigned int> *remappingIndices = nullptr);
void WriteData(size_t count, const void *src_buffer, size_t src_stride);
void WriteSparseValues(size_t count, const void *src_data, size_t src_dataStride);

View File

@ -962,14 +962,15 @@ inline size_t Accessor::GetMaxByteSize() {
}
template <class T>
void Accessor::ExtractData(T *&outData) {
size_t Accessor::ExtractData(T *&outData, const std::vector<unsigned int> *remappingIndices) {
uint8_t *data = GetPointer();
if (!data) {
throw DeadlyImportError("GLTF2: data is null when extracting data from ", getContextForErrorMessages(id, name));
}
const size_t usedCount = (remappingIndices != nullptr) ? remappingIndices->size() : count;
const size_t elemSize = GetElementSize();
const size_t totalSize = elemSize * count;
const size_t totalSize = elemSize * usedCount;
const size_t stride = GetStride();
@ -980,18 +981,31 @@ void Accessor::ExtractData(T *&outData) {
}
const size_t maxSize = GetMaxByteSize();
if (count * stride > maxSize) {
throw DeadlyImportError("GLTF: count*stride ", (count * stride), " > maxSize ", maxSize, " in ", getContextForErrorMessages(id, name));
}
outData = new T[count];
if (stride == elemSize && targetElemSize == elemSize) {
memcpy(outData, data, totalSize);
} else {
for (size_t i = 0; i < count; ++i) {
memcpy(outData + i, data + i * stride, elemSize);
outData = new T[usedCount];
if (remappingIndices != nullptr) {
const unsigned int maxIndex = static_cast<unsigned int>(maxSize / stride - 1);
for (size_t i = 0; i < usedCount; ++i) {
size_t srcIdx = (*remappingIndices)[i];
if (srcIdx > maxIndex) {
throw DeadlyImportError("GLTF: index*stride ", (srcIdx * stride), " > maxSize ", maxSize, " in ", getContextForErrorMessages(id, name));
}
memcpy(outData + i, data + srcIdx * stride, elemSize);
}
} else { // non-indexed cases
if (usedCount * stride > maxSize) {
throw DeadlyImportError("GLTF: count*stride ", (usedCount * stride), " > maxSize ", maxSize, " in ", getContextForErrorMessages(id, name));
}
if (stride == elemSize && targetElemSize == elemSize) {
memcpy(outData, data, totalSize);
} else {
for (size_t i = 0; i < usedCount; ++i) {
memcpy(outData + i, data + i * stride, elemSize);
}
}
}
return usedCount;
}
inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t src_stride) {

View File

@ -453,6 +453,11 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
unsigned int k = 0;
meshOffsets.clear();
std::vector<unsigned int> usedVertexIndices;
std::vector<unsigned int> reverseMappingIndices;
std::vector<unsigned int> indexBuffer;
for (unsigned int m = 0; m < r.meshes.Size(); ++m) {
Mesh &mesh = r.meshes[m];
@ -462,6 +467,50 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
for (unsigned int p = 0; p < mesh.primitives.size(); ++p) {
Mesh::Primitive &prim = mesh.primitives[p];
Mesh::Primitive::Attributes &attr = prim.attributes;
// Find out the maximum number of vertices:
size_t numAllVertices = 0;
if (!attr.position.empty() && attr.position[0]) {
numAllVertices = attr.position[0]->count;
}
// Extract used vertices:
bool useIndexBuffer = prim.indices;
std::vector<unsigned int>* vertexRemappingTable = nullptr;
if (useIndexBuffer) {
size_t count = prim.indices->count;
indexBuffer.resize(count);
usedVertexIndices.clear();
reverseMappingIndices.clear();
usedVertexIndices.reserve(count / 3); // this is a very rough heuristic to reduce re-allocations
vertexRemappingTable = &usedVertexIndices;
Accessor::Indexer data = prim.indices->GetIndexer();
if (!data.IsValid()) {
throw DeadlyImportError("GLTF: Invalid accessor without data in mesh ", getContextForErrorMessages(mesh.id, mesh.name));
}
// Build the vertex remapping table and the modified index buffer (used later instead of the original one)
// In case no index buffer is used, the original vertex arrays are being used so no remapping is required in the first place.
const unsigned int unusedIndex = ~0u;
for (unsigned int i = 0; i < count; ++i) {
unsigned int index = data.GetUInt(i);
if (index >= numAllVertices) {
// Out-of-range indices will be filtered out when adding the faces and then lead to a warning. At this stage, we just keep them.
indexBuffer[i] = index;
continue;
}
if (index >= reverseMappingIndices.size()) {
reverseMappingIndices.resize(index + 1, unusedIndex);
}
if (reverseMappingIndices[index] == unusedIndex) {
reverseMappingIndices[index] = static_cast<unsigned int>(usedVertexIndices.size());
usedVertexIndices.push_back(index);
}
indexBuffer[i] = reverseMappingIndices[index];
}
}
aiMesh *aim = new aiMesh();
meshes.push_back(std::unique_ptr<aiMesh>(aim));
@ -491,28 +540,25 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
break;
}
Mesh::Primitive::Attributes &attr = prim.attributes;
if (!attr.position.empty() && attr.position[0]) {
aim->mNumVertices = static_cast<unsigned int>(attr.position[0]->count);
attr.position[0]->ExtractData(aim->mVertices);
aim->mNumVertices = static_cast<unsigned int>(attr.position[0]->ExtractData(aim->mVertices, vertexRemappingTable));
}
if (!attr.normal.empty() && attr.normal[0]) {
if (attr.normal[0]->count != aim->mNumVertices) {
if (attr.normal[0]->count != numAllVertices) {
DefaultLogger::get()->warn("Normal count in mesh \"", mesh.name, "\" does not match the vertex count, normals ignored.");
} else {
attr.normal[0]->ExtractData(aim->mNormals);
attr.normal[0]->ExtractData(aim->mNormals, vertexRemappingTable);
// only extract tangents if normals are present
if (!attr.tangent.empty() && attr.tangent[0]) {
if (attr.tangent[0]->count != aim->mNumVertices) {
if (attr.tangent[0]->count != numAllVertices) {
DefaultLogger::get()->warn("Tangent count in mesh \"", mesh.name, "\" does not match the vertex count, tangents ignored.");
} else {
// generate bitangents from normals and tangents according to spec
Tangent *tangents = nullptr;
attr.tangent[0]->ExtractData(tangents);
attr.tangent[0]->ExtractData(tangents, vertexRemappingTable);
aim->mTangents = new aiVector3D[aim->mNumVertices];
aim->mBitangents = new aiVector3D[aim->mNumVertices];
@ -529,7 +575,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
}
for (size_t c = 0; c < attr.color.size() && c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c) {
if (attr.color[c]->count != aim->mNumVertices) {
if (attr.color[c]->count != numAllVertices) {
DefaultLogger::get()->warn("Color stream size in mesh \"", mesh.name,
"\" does not match the vertex count");
continue;
@ -537,7 +583,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
auto componentType = attr.color[c]->componentType;
if (componentType == glTF2::ComponentType_FLOAT) {
attr.color[c]->ExtractData(aim->mColors[c]);
attr.color[c]->ExtractData(aim->mColors[c], vertexRemappingTable);
} else {
if (componentType == glTF2::ComponentType_UNSIGNED_BYTE) {
aim->mColors[c] = GetVertexColorsForType<unsigned char>(attr.color[c]);
@ -552,13 +598,13 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
continue;
}
if (attr.texcoord[tc]->count != aim->mNumVertices) {
if (attr.texcoord[tc]->count != numAllVertices) {
DefaultLogger::get()->warn("Texcoord stream size in mesh \"", mesh.name,
"\" does not match the vertex count");
continue;
}
attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc]);
attr.texcoord[tc]->ExtractData(aim->mTextureCoords[tc], vertexRemappingTable);
aim->mNumUVComponents[tc] = attr.texcoord[tc]->GetNumComponents();
aiVector3D *values = aim->mTextureCoords[tc];
@ -583,11 +629,11 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
Mesh::Primitive::Target &target = targets[i];
if (needPositions) {
if (target.position[0]->count != aim->mNumVertices) {
if (target.position[0]->count != numAllVertices) {
ASSIMP_LOG_WARN("Positions of target ", i, " in mesh \"", mesh.name, "\" does not match the vertex count");
} else {
aiVector3D *positionDiff = nullptr;
target.position[0]->ExtractData(positionDiff);
target.position[0]->ExtractData(positionDiff, vertexRemappingTable);
for (unsigned int vertexId = 0; vertexId < aim->mNumVertices; vertexId++) {
aiAnimMesh.mVertices[vertexId] += positionDiff[vertexId];
}
@ -595,11 +641,11 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
}
}
if (needNormals) {
if (target.normal[0]->count != aim->mNumVertices) {
if (target.normal[0]->count != numAllVertices) {
ASSIMP_LOG_WARN("Normals of target ", i, " in mesh \"", mesh.name, "\" does not match the vertex count");
} else {
aiVector3D *normalDiff = nullptr;
target.normal[0]->ExtractData(normalDiff);
target.normal[0]->ExtractData(normalDiff, vertexRemappingTable);
for (unsigned int vertexId = 0; vertexId < aim->mNumVertices; vertexId++) {
aiAnimMesh.mNormals[vertexId] += normalDiff[vertexId];
}
@ -610,14 +656,14 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
if (!aiAnimMesh.HasNormals()) {
// prevent nullptr access to aiAnimMesh.mNormals below when no normals are available
ASSIMP_LOG_WARN("Bitangents of target ", i, " in mesh \"", mesh.name, "\" can't be computed, because mesh has no normals.");
} else if (target.tangent[0]->count != aim->mNumVertices) {
} else if (target.tangent[0]->count != numAllVertices) {
ASSIMP_LOG_WARN("Tangents of target ", i, " in mesh \"", mesh.name, "\" does not match the vertex count");
} else {
Tangent *tangent = nullptr;
attr.tangent[0]->ExtractData(tangent);
attr.tangent[0]->ExtractData(tangent, vertexRemappingTable);
aiVector3D *tangentDiff = nullptr;
target.tangent[0]->ExtractData(tangentDiff);
target.tangent[0]->ExtractData(tangentDiff, vertexRemappingTable);
for (unsigned int vertexId = 0; vertexId < aim->mNumVertices; ++vertexId) {
tangent[vertexId].xyz += tangentDiff[vertexId];
@ -641,20 +687,15 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
aiFace *facePtr = nullptr;
size_t nFaces = 0;
if (prim.indices) {
size_t count = prim.indices->count;
Accessor::Indexer data = prim.indices->GetIndexer();
if (!data.IsValid()) {
throw DeadlyImportError("GLTF: Invalid accessor without data in mesh ", getContextForErrorMessages(mesh.id, mesh.name));
}
if (useIndexBuffer) {
size_t count = indexBuffer.size();
switch (prim.mode) {
case PrimitiveMode_POINTS: {
nFaces = count;
facePtr = faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; ++i) {
SetFaceAndAdvance1(facePtr, aim->mNumVertices, data.GetUInt(i));
SetFaceAndAdvance1(facePtr, aim->mNumVertices, indexBuffer[i]);
}
break;
}
@ -667,7 +708,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
}
facePtr = faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 2) {
SetFaceAndAdvance2(facePtr, aim->mNumVertices, data.GetUInt(i), data.GetUInt(i + 1));
SetFaceAndAdvance2(facePtr, aim->mNumVertices, indexBuffer[i], indexBuffer[i + 1]);
}
break;
}
@ -676,12 +717,12 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
case PrimitiveMode_LINE_STRIP: {
nFaces = count - ((prim.mode == PrimitiveMode_LINE_STRIP) ? 1 : 0);
facePtr = faces = new aiFace[nFaces];
SetFaceAndAdvance2(facePtr, aim->mNumVertices, data.GetUInt(0), data.GetUInt(1));
SetFaceAndAdvance2(facePtr, aim->mNumVertices, indexBuffer[0], indexBuffer[1]);
for (unsigned int i = 2; i < count; ++i) {
SetFaceAndAdvance2(facePtr, aim->mNumVertices, data.GetUInt(i - 1), data.GetUInt(i));
SetFaceAndAdvance2(facePtr, aim->mNumVertices, indexBuffer[i - 1], indexBuffer[i]);
}
if (prim.mode == PrimitiveMode_LINE_LOOP) { // close the loop
SetFaceAndAdvance2(facePtr, aim->mNumVertices, data.GetUInt(static_cast<int>(count) - 1), faces[0].mIndices[0]);
SetFaceAndAdvance2(facePtr, aim->mNumVertices, indexBuffer[static_cast<int>(count) - 1], faces[0].mIndices[0]);
}
break;
}
@ -694,7 +735,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
}
facePtr = faces = new aiFace[nFaces];
for (unsigned int i = 0; i < count; i += 3) {
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
SetFaceAndAdvance3(facePtr, aim->mNumVertices, indexBuffer[i], indexBuffer[i + 1], indexBuffer[i + 2]);
}
break;
}
@ -705,10 +746,10 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
// The ordering is to ensure that the triangles are all drawn with the same orientation
if ((i + 1) % 2 == 0) {
// For even n, vertices n + 1, n, and n + 2 define triangle n
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(i + 1), data.GetUInt(i), data.GetUInt(i + 2));
SetFaceAndAdvance3(facePtr, aim->mNumVertices, indexBuffer[i + 1], indexBuffer[i], indexBuffer[i + 2]);
} else {
// For odd n, vertices n, n+1, and n+2 define triangle n
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(i), data.GetUInt(i + 1), data.GetUInt(i + 2));
SetFaceAndAdvance3(facePtr, aim->mNumVertices, indexBuffer[i], indexBuffer[i + 1], indexBuffer[i + 2]);
}
}
break;
@ -716,9 +757,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
case PrimitiveMode_TRIANGLE_FAN:
nFaces = count - 2;
facePtr = faces = new aiFace[nFaces];
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(0), data.GetUInt(1), data.GetUInt(2));
SetFaceAndAdvance3(facePtr, aim->mNumVertices, indexBuffer[0], indexBuffer[1], indexBuffer[2]);
for (unsigned int i = 1; i < nFaces; ++i) {
SetFaceAndAdvance3(facePtr, aim->mNumVertices, data.GetUInt(0), data.GetUInt(i + 1), data.GetUInt(i + 2));
SetFaceAndAdvance3(facePtr, aim->mNumVertices, indexBuffer[0], indexBuffer[i + 1], indexBuffer[i + 2]);
}
break;
}

View File

@ -1245,11 +1245,9 @@ IF (ASSIMP_WARNINGS_AS_ERRORS)
-Wno-deprecated-copy-with-dtor
-Wno-deprecated
-Wno-format-nonliteral
-Wno-format-non-iso
-Wno-comma
-Wno-unreachable-code-break
-Wno-unreachable-code-return
-Wno-unreachable-code
-Wno-implicit-fallthrough
-Wno-unused-template
-Wno-undefined-func-template

View File

@ -214,7 +214,12 @@ void GetImporterInstanceList(std::vector<BaseImporter *> &out) {
// Some importers may be unimplemented or otherwise unsuitable for general use
// in their current state. Devs can set ASSIMP_ENABLE_DEV_IMPORTERS in their
// local environment to enable them, otherwise they're left out of the registry.
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
// not supported under uwp
const char *envStr = std::getenv("ASSIMP_ENABLE_DEV_IMPORTERS");
#else
const char *envStr = { "0" };
#endif
bool devImportersEnabled = envStr && strcmp(envStr, "0");
// Ensure no unused var warnings if all uses are #ifndef'd away below:
@ -377,9 +382,6 @@ void GetImporterInstanceList(std::vector<BaseImporter *> &out) {
#ifndef ASSIMP_BUILD_NO_IQM_IMPORTER
out.push_back(new IQMImporter());
#endif
//#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER
// out.push_back(new StepFile::StepFileImporter());
//#endif
}
/** will delete all registered importers. */

View File

@ -118,8 +118,8 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
Point* p1 = triangle->PointCCW(point);
Orientation o1 = Orient2d(eq, *p1, ep);
if (o1 == COLLINEAR) {
// ASSIMP_CHANGE (aramis_acg)
throw std::runtime_error("EdgeEvent - collinear points not supported");
if( triangle->Contains(&eq, p1)) {
triangle->MarkConstrainedEdge(&eq, p1 );
// We are modifying the constraint maybe it would be better to
@ -137,8 +137,8 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl
Point* p2 = triangle->PointCW(point);
Orientation o2 = Orient2d(eq, *p2, ep);
if (o2 == COLLINEAR) {
// ASSIMP_CHANGE (aramis_acg)
throw std::runtime_error("EdgeEvent - collinear points not supported");
if( triangle->Contains(&eq, p2)) {
triangle->MarkConstrainedEdge(&eq, p2 );

View File

@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
#include <iomanip>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
#define AI_SIZEFMT "%Iu"
#else
#define AI_SIZEFMT "%zu"

View File

@ -380,7 +380,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) {
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
std::array<unsigned int, 5> l1 = { { 0u, 3u, 2u, 1u, 0u } };
std::array<unsigned int, 5> l1 = { { 0u, 1u, 2u, 3u, 0u } };
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
@ -394,7 +394,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineLoop) {
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_09.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
std::array<unsigned int, 5> l1 = { { 0, 3u, 2u, 1u, 0u } };
std::array<unsigned int, 5> l1 = { { 0, 1u, 2u, 3u, 0u } };
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
@ -408,7 +408,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLineStrip) {
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_10.gltf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
std::array<unsigned int, 5> l1 = { { 0u, 3u, 2u, 1u, 0u } };
std::array<unsigned int, 5> l1 = { { 0u, 1u, 2u, 3u, 0u } };
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u);
for (unsigned int i = 0; i < scene->mMeshes[0]->mNumFaces; ++i) {
EXPECT_EQ(scene->mMeshes[0]->mFaces[i].mIndices[0], l1[i]);
@ -423,13 +423,13 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesStrip) {
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
std::array<unsigned int, 3> f1 = { { 0u, 3u, 1u } };
std::array<unsigned int, 3> f1 = { { 0u, 1u, 2u } };
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
for (size_t i = 0; i < 3; ++i) {
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
}
std::array<unsigned int, 3> f2 = { { 1u, 3u, 2u } };
std::array<unsigned int, 3> f2 = { { 2u, 1u, 3u } };
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
for (size_t i = 0; i < 3; ++i) {
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);
@ -443,13 +443,13 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeTrianglesFan) {
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u);
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
std::array<unsigned int, 3> f1 = { { 0u, 3u, 2u } };
std::array<unsigned int, 3> f1 = { { 0u, 1u, 2u } };
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 3u);
for (size_t i = 0; i < 3; ++i) {
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mIndices[i], f1[i]);
}
std::array<unsigned int, 3> f2 = { { 0u, 2u, 1u } };
std::array<unsigned int, 3> f2 = { { 0u, 2u, 3u } };
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mNumIndices, 3u);
for (size_t i = 0; i < 3; ++i) {
EXPECT_EQ(scene->mMeshes[0]->mFaces[1].mIndices[i], f2[i]);