瀏覽代碼

Merge branch 'master' into 5781186265350144

Kim Kulling 2 年之前
父節點
當前提交
e30823fb1d
共有 2 個文件被更改,包括 13 次插入13 次删除
  1. 6 10
      Dockerfile
  2. 7 3
      code/AssetLib/Obj/ObjFileImporter.cpp

+ 6 - 10
Dockerfile

@@ -1,14 +1,9 @@
-FROM ubuntu:14.04
+FROM ubuntu:22.04
 
 
-RUN apt-get update && apt-get install -y \
+RUN apt-get update && apt-get install -y ninja-build \
     git cmake build-essential software-properties-common
     git cmake build-essential software-properties-common
 
 
-RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update && apt-get install -y gcc-4.9 g++-4.9 && \
-    cd /usr/bin && \
-    rm gcc g++ cpp && \
-    ln -s gcc-4.9 gcc && \
-    ln -s g++-4.9 g++ && \
-    ln -s cpp-4.9 cpp
+RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update 
 
 
 WORKDIR /opt
 WORKDIR /opt
 
 
@@ -19,7 +14,8 @@ WORKDIR /opt/assimp
 
 
 RUN git checkout master \
 RUN git checkout master \
     && mkdir build && cd build && \
     && mkdir build && cd build && \
-    cmake \
+    cmake -G 'Ninja' \
     -DCMAKE_BUILD_TYPE=Release \
     -DCMAKE_BUILD_TYPE=Release \
+    -DASSIMP_BUILD_ASSIMP_TOOLS=ON \
     .. && \
     .. && \
-    make && make install
+    ninja -j4 && ninja install

+ 7 - 3
code/AssetLib/Obj/ObjFileImporter.cpp

@@ -323,7 +323,7 @@ aiMesh *ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjF
         return nullptr;
         return nullptr;
     }
     }
 
 
-    aiMesh *pMesh = new aiMesh;
+    std::unique_ptr<aiMesh> pMesh(new aiMesh);
     if (!pObjMesh->m_name.empty()) {
     if (!pObjMesh->m_name.empty()) {
         pMesh->mName.Set(pObjMesh->m_name);
         pMesh->mName.Set(pObjMesh->m_name);
     }
     }
@@ -385,9 +385,9 @@ aiMesh *ObjFileImporter::createTopology(const ObjFile::Model *pModel, const ObjF
     }
     }
 
 
     // Create mesh vertices
     // Create mesh vertices
-    createVertexArray(pModel, pData, meshIndex, pMesh, uiIdxCount);
+    createVertexArray(pModel, pData, meshIndex, pMesh.get(), uiIdxCount);
 
 
-    return pMesh;
+    return pMesh.release();
 }
 }
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
@@ -498,6 +498,10 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model *pModel,
 
 
                 if (vertexIndex) {
                 if (vertexIndex) {
                     if (!last) {
                     if (!last) {
+                        if (pMesh->mNumVertices <= newIndex + 1) {
+                            throw DeadlyImportError("OBJ: bad vertex index");
+                        }
+
                         pMesh->mVertices[newIndex + 1] = pMesh->mVertices[newIndex];
                         pMesh->mVertices[newIndex + 1] = pMesh->mVertices[newIndex];
                         if (!sourceFace->m_normals.empty() && !pModel->mNormals.empty()) {
                         if (!sourceFace->m_normals.empty() && !pModel->mNormals.empty()) {
                             pMesh->mNormals[newIndex + 1] = pMesh->mNormals[newIndex];
                             pMesh->mNormals[newIndex + 1] = pMesh->mNormals[newIndex];