浏览代码

Merge pull request #1457 from jaredmulconry/issue_1330

Partially address issue #1330
Kim Kulling 8 年之前
父节点
当前提交
b1410f8455

+ 5 - 5
code/FBXBinaryTokenizer.cpp

@@ -439,11 +439,11 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le
     }
 
     const char* cursor = input + 18;
-	const uint8_t unknown_1 = ReadByte(input, cursor, input + length);
-	const uint8_t unknown_2 = ReadByte(input, cursor, input + length);
-	const uint8_t unknown_3 = ReadByte(input, cursor, input + length);
-	const uint8_t unknown_4 = ReadByte(input, cursor, input + length);
-	const uint8_t unknown_5 = ReadByte(input, cursor, input + length);
+	/*Result ignored*/ ReadByte(input, cursor, input + length);
+	/*Result ignored*/ ReadByte(input, cursor, input + length);
+	/*Result ignored*/ ReadByte(input, cursor, input + length);
+	/*Result ignored*/ ReadByte(input, cursor, input + length);
+	/*Result ignored*/ ReadByte(input, cursor, input + length);
 	const uint32_t version = ReadWord(input, cursor, input + length);
 	const bool is64bits = version >= 7500;
     while (cursor < input + length)

+ 3 - 3
code/MDLFileData.h

@@ -126,16 +126,16 @@ struct Header {
     int32_t version;
 
     //! scale factors for each axis
-    aiVector3D scale;
+    ai_real scale[3];
 
     //! translation factors for each axis
-    aiVector3D translate;
+    ai_real translate[3];
 
     //! bounding radius of the mesh
     float boundingradius;
 
     //! Position of the viewer's exe. Ignored
-    aiVector3D vEyePos;
+    ai_real vEyePos[3];
 
     //! Number of textures
     int32_t num_skins;

+ 1 - 1
code/MMDImporter.cpp

@@ -118,7 +118,7 @@ void MMDImporter::InternReadFile(const std::string &file, aiScene *pScene,
 
   // Get the file-size and validate it, throwing an exception when fails
   fileStream.seekg(0, fileStream.end);
-  size_t fileSize = fileStream.tellg();
+  size_t fileSize = static_cast<size_t>(fileStream.tellg());
   fileStream.seekg(0, fileStream.beg);
 
   if (fileSize < sizeof(pmx::PmxModel)) {

+ 1 - 1
code/glTF2Exporter.cpp

@@ -741,7 +741,7 @@ void glTF2Exporter::MergeMeshes()
     for (unsigned int n = 0; n < mAsset->nodes.Size(); ++n) {
         Ref<Node> node = mAsset->nodes.Get(n);
 
-        unsigned int nMeshes = node->meshes.size();
+        unsigned int nMeshes = static_cast<unsigned int>(node->meshes.size());
 
         //skip if it's 1 or less meshes per node
         if (nMeshes > 1) {

+ 8 - 0
include/assimp/scene.h

@@ -60,6 +60,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 extern "C" {
 #endif
 
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wattributes"
+#endif
+
 // -------------------------------------------------------------------------------
 /** 
  * A node in the imported hierarchy.
@@ -163,6 +168,9 @@ struct ASSIMP_API aiNode
 #endif // __cplusplus
 };
 
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
 
 // -------------------------------------------------------------------------------
 /**

+ 5 - 0
samples/SimpleOpenGL/CMakeLists.txt

@@ -16,6 +16,11 @@ IF ( NOT GLUT_FOUND )
   ENDIF ( MSVC )
 ENDIF ( NOT GLUT_FOUND )
 
+if ( MSVC )
+  ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
+  ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
+endif ( MSVC )
+
 INCLUDE_DIRECTORIES(
   ${Assimp_SOURCE_DIR}/include
   ${Assimp_SOURCE_DIR}/code

+ 5 - 0
samples/SimpleTexturedOpenGL/CMakeLists.txt

@@ -11,6 +11,11 @@ IF ( NOT GLUT_FOUND )
   ENDIF ( MSVC )
 ENDIF ( NOT GLUT_FOUND )
 
+if ( MSVC )
+  ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
+  ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
+endif ( MSVC )
+
 INCLUDE_DIRECTORIES(
   ${Assimp_SOURCE_DIR}/include
   ${Assimp_SOURCE_DIR}/code

+ 2 - 1
samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp

@@ -13,6 +13,7 @@
 // http://nehe.gamedev.net/
 // ----------------------------------------------------------------------------
 #include <windows.h>
+#include <shellapi.h>
 #include <stdio.h>
 #include <GL/gl.h>
 #include <GL/glu.h>
@@ -666,7 +667,7 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
 		PFD_SUPPORT_OPENGL |							// Format Must Support OpenGL
 		PFD_DOUBLEBUFFER,								// Must Support Double Buffering
 		PFD_TYPE_RGBA,									// Request An RGBA Format
-		bits,											// Select Our Color Depth
+		BYTE(bits),											// Select Our Color Depth
 		0, 0, 0, 0, 0, 0,								// Color Bits Ignored
 		0,												// No Alpha Buffer
 		0,												// Shift Bit Ignored

+ 42 - 8
test/unit/utDefaultIOStream.cpp

@@ -39,6 +39,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -------------------------------------------------------------------------*/
 #include <gtest/gtest.h>
 #include "TestIOStream.h"
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+
+#if defined(__GNUC__) || defined(__clang__)
+#define TMP_PATH "/tmp/"
+void MakeTmpFilePath(char* tmplate)
+{
+    auto err = mkstemp(tmplate);
+    ASSERT_NE(err, -1);
+}
+#elif defined(_MSC_VER)
+#include <io.h>
+#define TMP_PATH "./"
+void MakeTmpFilePath(char* tmplate)
+{
+    auto pathtemplate = _mktemp(tmplate);
+    ASSERT_NE(pathtemplate, nullptr);
+}
+#endif
 
 using namespace ::Assimp;
 
@@ -46,16 +66,30 @@ class utDefaultIOStream : public ::testing::Test {
     // empty
 };
 
+
+
+const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\
+sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\
+obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\
+itor sapien ornare sagittis volutpat."};
+
 TEST_F( utDefaultIOStream, FileSizeTest ) {
-    char buffer[ L_tmpnam ];
-    tmpnam( buffer );
-    std::FILE *fs( std::fopen( buffer, "w+" ) );
-    size_t written( std::fwrite( buffer, 1, sizeof( char ) * L_tmpnam, fs ) );
+    const auto dataSize = sizeof(data);
+    const auto dataCount = dataSize / sizeof(*data);
+
+    char fpath[] = { TMP_PATH"rndfp.XXXXXX" };
+    MakeTmpFilePath(fpath);
+    
+    auto *fs = std::fopen(fpath, "w+" );
+    ASSERT_NE(fs, nullptr);
+    auto written = std::fwrite(data, sizeof(*data), dataCount, fs );
     EXPECT_NE( 0U, written );
-    std::fflush( fs );
+    auto vflush = std::fflush( fs );
+    ASSERT_EQ(vflush, 0);
 
-    TestDefaultIOStream myStream( fs, buffer );
+    TestDefaultIOStream myStream( fs, fpath);
     size_t size = myStream.FileSize();
-    EXPECT_EQ( size, sizeof( char ) * L_tmpnam );
-    remove( buffer );
+    EXPECT_EQ( size, dataSize);
+    remove(fpath);
+    
 }

+ 0 - 1
tools/assimp_view/stdafx.h

@@ -23,7 +23,6 @@
 #define _WIN32_IE 0x0600    // Ändern Sie dies in den geeigneten Wert für andere Versionen von IE.
 #endif
 
-#define WIN32_LEAN_AND_MEAN     // Selten verwendete Teile der Windows-Header nicht einbinden.
 // Windows-Headerdateien:
 #include <windows.h>