Jelajahi Sumber

Merge branch 'master' into fbx_unitscale_factor

Kim Kulling 7 tahun lalu
induk
melakukan
05b560ef44
4 mengubah file dengan 26 tambahan dan 55 penghapusan
  1. TEMPAT SAMPAH
      tools/assimp_view/HUD.png
  2. TEMPAT SAMPAH
      tools/assimp_view/HUDMask.png
  3. 8 16
      tools/assimp_view/MessageProc.cpp
  4. 18 39
      tools/assimp_view/assimp_view.cpp

TEMPAT SAMPAH
tools/assimp_view/HUD.png


TEMPAT SAMPAH
tools/assimp_view/HUDMask.png


+ 8 - 16
tools/assimp_view/MessageProc.cpp

@@ -118,7 +118,7 @@ void MakeFileAssociations()
         D3DCOLOR_ARGB(0xFF,0,0xFF,0));
 
     CLogDisplay::Instance().AddEntry(tmp.data,D3DCOLOR_ARGB(0xFF,0,0xFF,0));
-    }
+}
 
 
 //-------------------------------------------------------------------------------
@@ -128,17 +128,16 @@ void MakeFileAssociations()
 // Other command line parameters are not handled
 //-------------------------------------------------------------------------------
 void HandleCommandLine(char* p_szCommand)
-    {
+{
     char* sz = p_szCommand;
     //bool bQuak = false;
 
     if (strlen(sz) < 2)return;
 
-    if (*sz == '\"')
-  {
+    if (*sz == '\"') {
         char* sz2 = strrchr(sz,'\"');
         if (sz2)*sz2 = 0;
-    sz++; // skip the starting quote
+        sz++; // skip the starting quote
     }
 
     strcpy( g_szFileName, sz );
@@ -149,8 +148,7 @@ void HandleCommandLine(char* p_szCommand)
 
     // Save the list of previous files to the registry
     SaveHistory();
-    }
-
+}
 
 //-------------------------------------------------------------------------------
 // Load the light colors from the registry
@@ -158,16 +156,11 @@ void HandleCommandLine(char* p_szCommand)
 void LoadLightColors()
 {
     DWORD dwTemp = 4;
-    RegQueryValueEx(g_hRegistry,"LightColor0",NULL,NULL,
-        (BYTE*)&g_avLightColors[0],&dwTemp);
-    RegQueryValueEx(g_hRegistry,"LightColor1",NULL,NULL,
-        (BYTE*)&g_avLightColors[1],&dwTemp);
-    RegQueryValueEx(g_hRegistry,"LightColor2",NULL,NULL,
-        (BYTE*)&g_avLightColors[2],&dwTemp);
-    return;
+    RegQueryValueEx(g_hRegistry,"LightColor0",NULL,NULL, (BYTE*)&g_avLightColors[0],&dwTemp);
+    RegQueryValueEx(g_hRegistry,"LightColor1",NULL,NULL, (BYTE*)&g_avLightColors[1],&dwTemp);
+    RegQueryValueEx(g_hRegistry,"LightColor2",NULL,NULL, (BYTE*)&g_avLightColors[2],&dwTemp);
 }
 
-
 //-------------------------------------------------------------------------------
 // Save the light colors to the registry
 //-------------------------------------------------------------------------------
@@ -178,7 +171,6 @@ void SaveLightColors()
     RegSetValueExA(g_hRegistry,"LightColor2",0,REG_DWORD,(const BYTE*)&g_avLightColors[2],4);
 }
 
-
 //-------------------------------------------------------------------------------
 // Save the checker pattern colors to the registry
 //-------------------------------------------------------------------------------

+ 18 - 39
tools/assimp_view/assimp_view.cpp

@@ -787,9 +787,17 @@ int ShutdownD3D(void)
     return 1;
 }
 
+template<class TComPtr>
+inline 
+void SafeRelease(TComPtr *ptr) {
+    if (nullptr != g_piPassThroughEffect) {
+        g_piPassThroughEffect->Release();
+        g_piPassThroughEffect = nullptr;
+    }
+}
 
 //-------------------------------------------------------------------------------
-// Shutdown the D3D devie object and all resources associated with it
+// Shutdown the D3D device object and all resources associated with it
 // NOTE: Assumes that the asset has already been deleted
 //-------------------------------------------------------------------------------
 int ShutdownDevice(void)
@@ -798,49 +806,20 @@ int ShutdownDevice(void)
     CBackgroundPainter::Instance().ReleaseNativeResource();
     CLogDisplay::Instance().ReleaseNativeResource();
 
-    // release global shaders that have been allocazed
-    if (NULL != g_piDefaultEffect)
-    {
-        g_piDefaultEffect->Release();
-        g_piDefaultEffect = NULL;
-    }
-    if (NULL != g_piNormalsEffect)
-    {
-        g_piNormalsEffect->Release();
-        g_piNormalsEffect = NULL;
-    }
-    if (NULL != g_piPassThroughEffect)
-    {
-        g_piPassThroughEffect->Release();
-        g_piPassThroughEffect = NULL;
-    }
-    if (NULL != g_piPatternEffect)
-    {
-        g_piPatternEffect->Release();
-        g_piPatternEffect = NULL;
-    }
-    if (NULL != g_pcTexture)
-    {
-        g_pcTexture->Release();
-        g_pcTexture = NULL;
-    }
-
-    if( NULL != gDefaultVertexDecl)
-    {
-        gDefaultVertexDecl->Release();
-        gDefaultVertexDecl = NULL;
-    }
+    // release global shaders that have been allocated
+    SafeRelease(g_piDefaultEffect);
+    SafeRelease(g_piNormalsEffect);
+    SafeRelease(g_piPassThroughEffect);
+    SafeRelease(g_piPatternEffect);
+    SafeRelease(g_pcTexture);
+    SafeRelease(gDefaultVertexDecl);
 
     // delete the main D3D device object
-    if (NULL != g_piDevice)
-    {
-        g_piDevice->Release();
-        g_piDevice = NULL;
-    }
+    SafeRelease(g_piDevice);
 
     // deleted the one channel image allocated to hold the HUD mask
     delete[] g_szImageMask;
-    g_szImageMask = NULL;
+    g_szImageMask = nullptr;
 
     return 1;
 }