From 6627c04a979ba46fd3e370ebc863f87b09a62270 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 4 Jan 2016 13:43:49 +0100 Subject: [PATCH 1/6] Changed: Copy tools related to client into client bundle under OS X --HG-- branch : develop --- .../tools/misc/crash_report/CMakeLists.txt | 8 ----- code/ryzom/client/src/CMakeLists.txt | 35 ++++++++++++++++++- .../client/client_config_qt/CMakeLists.txt | 8 ----- .../client/client_patcher/CMakeLists.txt | 10 +----- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/code/nel/tools/misc/crash_report/CMakeLists.txt b/code/nel/tools/misc/crash_report/CMakeLists.txt index 221f7cabe..1169aab8d 100644 --- a/code/nel/tools/misc/crash_report/CMakeLists.txt +++ b/code/nel/tools/misc/crash_report/CMakeLists.txt @@ -48,11 +48,3 @@ NL_DEFAULT_PROPS(crash_report "NeL, Tools, Misc: Crash Report") NL_ADD_RUNTIME_FLAGS(crash_report) INSTALL(TARGETS crash_report RUNTIME DESTINATION ${NL_BIN_PREFIX}) - -IF(WITH_RYZOM_CLIENT AND APPLE) - IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE) - ADD_CUSTOM_COMMAND(TARGET crash_report POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/crash_report" COMMENT "Signing crash_report executable...") - ENDIF() - - ADD_CUSTOM_COMMAND(TARGET crash_report POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/crash_report ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MACOSX_BUNDLE_BUNDLE_NAME}.app/Contents/MacOS/CrashReport) -ENDIF() diff --git a/code/ryzom/client/src/CMakeLists.txt b/code/ryzom/client/src/CMakeLists.txt index ad55fd3d7..7c939bbeb 100644 --- a/code/ryzom/client/src/CMakeLists.txt +++ b/code/ryzom/client/src/CMakeLists.txt @@ -78,8 +78,41 @@ IF(WITH_RYZOM_CLIENT) ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp ARGS -RpX ${RYZOM_DATA_DIR} ${RYZOM_RESOURCES_DIR}) ENDIF() + IF(TARGET crash_report) + ADD_DEPENDENCIES(ryzom_client crash_report) + + # copy crash_report to bundle + ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/crash_report ${RYZOM_CONTENTS_DIR}/MacOS/CrashReport) + + IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE) + ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_CONTENTS_DIR}/MacOS/CrashReport" COMMENT "Signing CrashReport executable...") + ENDIF() + ENDIF() + + IF(TARGET ryzom_client_patcher) + ADD_DEPENDENCIES(ryzom_client ryzom_client_patcher) + + # copy ryzom_client_patcher to bundle + ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_client_patcher ${RYZOM_CONTENTS_DIR}/MacOS/RyzomClientPatcher) + + IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE) + ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_CONTENTS_DIR}/MacOS/RyzomClientPatcher" COMMENT "Signing RyzomClientPatcher executable...") + ENDIF() + ENDIF() + + IF(TARGET ryzom_configuration_qt) + ADD_DEPENDENCIES(ryzom_client ryzom_configuration_qt) + + # copy ryzom_configuration_qt to bundle + ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_configuration_qt ${RYZOM_CONTENTS_DIR}/MacOS/RyzomConfiguration) + + IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE) + ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_CONTENTS_DIR}/MacOS/RyzomConfiguration" COMMENT "Signing RyzomConfiguration executable...") + ENDIF() + ENDIF() + IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE) - ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_OUTPUT_DIR}" COMMENT "Signing bundle...") + ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_OUTPUT_DIR}" COMMENT "Signing Ryzom bundle...") ENDIF() ENDIF() diff --git a/code/ryzom/tools/client/client_config_qt/CMakeLists.txt b/code/ryzom/tools/client/client_config_qt/CMakeLists.txt index f27589afa..f0bb295b3 100644 --- a/code/ryzom/tools/client/client_config_qt/CMakeLists.txt +++ b/code/ryzom/tools/client/client_config_qt/CMakeLists.txt @@ -69,11 +69,3 @@ IF(WITH_PCH) ENDIF() INSTALL(TARGETS ryzom_configuration_qt RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client) - -IF(WITH_RYZOM_CLIENT AND APPLE) - IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE) - ADD_CUSTOM_COMMAND(TARGET ryzom_configuration_qt POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_configuration_qt" COMMENT "Signing ryzom_configuration_qt executable...") - ENDIF() - - ADD_CUSTOM_COMMAND(TARGET ryzom_configuration_qt POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_configuration_qt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MACOSX_BUNDLE_BUNDLE_NAME}.app/Contents/MacOS/RyzomConfiguration) -ENDIF() diff --git a/code/ryzom/tools/client/client_patcher/CMakeLists.txt b/code/ryzom/tools/client/client_patcher/CMakeLists.txt index f71f21a35..c2f8ff3c6 100644 --- a/code/ryzom/tools/client/client_patcher/CMakeLists.txt +++ b/code/ryzom/tools/client/client_patcher/CMakeLists.txt @@ -42,12 +42,4 @@ IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(ryzom_client_patcher ${CMAKE_SOURCE_DIR}/ryzom/client/src/stdpch.h ${CMAKE_SOURCE_DIR}/ryzom/client/src/stdpch.cpp) ENDIF(WITH_PCH) -INSTALL(TARGETS ryzom_client_patcher RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client BUNDLE DESTINATION /Applications) - -IF(WITH_RYZOM_CLIENT AND APPLE) - IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE) - ADD_CUSTOM_COMMAND(TARGET ryzom_client_patcher POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_client_patcher" COMMENT "Signing ryzom_client_patcher executable...") - ENDIF() - - ADD_CUSTOM_COMMAND(TARGET ryzom_client_patcher POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_client_patcher ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MACOSX_BUNDLE_BUNDLE_NAME}.app/Contents/MacOS/RyzomClientPatcher) -ENDIF() +INSTALL(TARGETS ryzom_client_patcher RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client) From c263e4dffb32334a669fdab7e8e64d9d59cc95f5 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 4 Jan 2016 13:48:57 +0100 Subject: [PATCH 2/6] Changed: Don't redefine new and delete operators if targetting x86_64 --HG-- branch : develop --- code/nel/include/nel/misc/types_nl.h | 19 ++++++++++++++++++- code/nel/src/misc/common.cpp | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 46dd00cba..32b6a85d0 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -43,11 +43,25 @@ // This way we know about _HAS_TR1 and _STLPORT_VERSION #include +#if defined(HAVE_X86_64) +# define NL_CPU_INTEL +# define NL_CPU_X86_64 +// x86_64 CPU always have SSE2 instructions +# ifndef NL_HAS_SSE2 +# define NL_HAS_SSE2 +# endif +#elif defined(HAVE_X86) +# define NL_CPU_INTEL +# define NL_CPU_X86 +#endif + // Operating systems definition #ifdef _WIN32 # define NL_OS_WINDOWS # define NL_LITTLE_ENDIAN -# define NL_CPU_INTEL +# ifndef NL_CPU_INTEL +# define NL_CPU_INTEL +# endif # ifndef _WIN32_WINNT # define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98) # endif @@ -384,10 +398,13 @@ inline void aligned_free(void *ptr) { free(ptr); } #define NL_DEFAULT_MEMORY_ALIGNMENT 16 #define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) +#ifndef NL_CPU_X86_64 +// on x86_64, new and delete are already aligned on 16 bytes extern void *operator new(size_t size) throw(std::bad_alloc); extern void *operator new[](size_t size) throw(std::bad_alloc); extern void operator delete(void *p) throw(); extern void operator delete[](void *p) throw(); +#endif #else /* NL_HAS_SSE2 */ diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 4799ac10e..982d42da3 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -80,7 +80,7 @@ extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); } #endif // !NL_COMP_MINGW -#ifdef NL_HAS_SSE2 +#if defined(NL_HAS_SSE2) && !defined(NL_CPU_X86_64) void *operator new(size_t size) throw(std::bad_alloc) { From 47bde9ccc7ceb006fd80a9f7cbae2a4b7aa8b155 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 4 Jan 2016 13:54:59 +0100 Subject: [PATCH 3/6] Changed: Allow to resample Luminance (grayscale) bitmaps --HG-- branch : develop --- code/nel/include/nel/misc/bitmap.h | 28 ++++ code/nel/src/misc/bitmap.cpp | 252 ++++++++++++++++++++++++++++- 2 files changed, 273 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/misc/bitmap.h b/code/nel/include/nel/misc/bitmap.h index e572c8de0..8d2bf156f 100644 --- a/code/nel/include/nel/misc/bitmap.h +++ b/code/nel/include/nel/misc/bitmap.h @@ -236,6 +236,34 @@ private : sint32 nDestWidth, sint32 nDestHeight); + /** + * The grayscale resample function + * \param pSrc grayscale 8-bits array + * \param pDest grayscale 8-bits array for storing resampled texture + * \param nSrcWidth original width + * \param nSrcHeight original height + * \param nDestWidth width after resample + * \param nDestHeight height after resample + */ + void resamplePicture8 (const uint8 *pSrc, uint8 *pDest, + sint32 nSrcWidth, sint32 nSrcHeight, + sint32 nDestWidth, sint32 nDestHeight); + + /** + * The FAST resample function : works only when reducing the size by two + * and when the image is square + * \param pSrc grayscale 8-bits array + * \param pDest grayscale 8-bits array for storing resampled texture + * \param nSrcWidth original width + * \param nSrcHeight original height + * \param nDestWidth width after resample + * \param nDestHeight height after resample + */ + void resamplePicture8Fast (const uint8 *pSrc, uint8 *pDest, + sint32 nSrcWidth, sint32 nSrcHeight, + sint32 nDestWidth, sint32 nDestHeight); + + /** * Quadratic interpolator * \return the interpolation in (x,y) of the values (xy**) diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index eef7386f7..7a90b6282 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -1785,7 +1785,7 @@ void CBitmap::releaseMipMaps() \*-------------------------------------------------------------------*/ void CBitmap::resample(sint32 nNewWidth, sint32 nNewHeight) { - nlassert(PixelFormat == RGBA); + nlassert(PixelFormat == RGBA || PixelFormat == Luminance); bool needRebuild = false; // Deleting mipmaps @@ -1804,13 +1804,27 @@ void CBitmap::resample(sint32 nNewWidth, sint32 nNewHeight) //logResample("Resample: 30"); CObjectVector pDestui; - pDestui.resize(nNewWidth*nNewHeight*4); - //logResample("Resample: 40"); - NLMISC::CRGBA *pDestRgba = (NLMISC::CRGBA*)&pDestui[0]; - //logResample("Resample: 50"); - resamplePicture32 ((NLMISC::CRGBA*)&_Data[0][0], pDestRgba, _Width, _Height, nNewWidth, nNewHeight); - //logResample("Resample: 60"); + if (PixelFormat == RGBA) + { + pDestui.resize(nNewWidth*nNewHeight*4); + //logResample("Resample: 40"); + NLMISC::CRGBA *pDestRgba = (NLMISC::CRGBA*)&pDestui[0]; + //logResample("Resample: 50"); + + resamplePicture32 ((NLMISC::CRGBA*)&_Data[0][0], pDestRgba, _Width, _Height, nNewWidth, nNewHeight); + //logResample("Resample: 60"); + } + else if (PixelFormat == Luminance) + { + pDestui.resize(nNewWidth*nNewHeight); + //logResample("Resample: 40"); + uint8 *pDestGray = &pDestui[0]; + //logResample("Resample: 50"); + + resamplePicture8 (&_Data[0][0], pDestGray, _Width, _Height, nNewWidth, nNewHeight); + //logResample("Resample: 60"); + } NLMISC::contReset(_Data[0]); // free memory //logResample("Resample: 70"); @@ -2126,6 +2140,230 @@ void CBitmap::resamplePicture32Fast (const NLMISC::CRGBA *pSrc, NLMISC::CRGBA *p } +/*-------------------------------------------------------------------*\ + resamplePicture32 +\*-------------------------------------------------------------------*/ +void CBitmap::resamplePicture8 (const uint8 *pSrc, uint8 *pDest, + sint32 nSrcWidth, sint32 nSrcHeight, + sint32 nDestWidth, sint32 nDestHeight) +{ + //logResample("RP8: 0 pSrc=%p pDest=%p, Src=%d x %d Dest=%d x %d", pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight); + if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestHeight<=0)||(nDestHeight<=0)) + return; + + // If we're reducing it by 2, call the fast resample + if (((nSrcHeight / 2) == nDestHeight) && ((nSrcHeight % 2) == 0) && + ((nSrcWidth / 2) == nDestWidth) && ((nSrcWidth % 2) == 0)) + { + resamplePicture8Fast(pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight); + return; + } + + bool bXMag=(nDestWidth>=nSrcWidth); + bool bYMag=(nDestHeight>=nSrcHeight); + bool bXEq=(nDestWidth==nSrcWidth); + bool bYEq=(nDestHeight==nSrcHeight); + std::vector pIterm (nDestWidth*nSrcHeight); + + if (bXMag) + { + float fXdelta=(float)(nSrcWidth)/(float)(nDestWidth); + float *pItermPtr=&*pIterm.begin(); + sint32 nY; + for (nY=0; nY=0.f); + float vColor; + if (fVirgule>=0.5f) + { + if (fX<(float)(nSrcWidth-1)) + { + float vColor1 (pSrcLine[(sint32)floor(fX)]); + float vColor2 (pSrcLine[(sint32)floor(fX)+1]); + vColor=vColor1*(1.5f-fVirgule)+vColor2*(fVirgule-0.5f); + } + else + vColor = float(pSrcLine[(sint32)floor(fX)]); + } + else + { + if (fX>=1.f) + { + float vColor1 (pSrcLine[(sint32)floor(fX)]); + float vColor2 (pSrcLine[(sint32)floor(fX)-1]); + vColor = vColor1*(0.5f+fVirgule)+vColor2*(0.5f-fVirgule); + } + else + vColor = float (pSrcLine[(sint32)floor(fX)]); + } + *(pItermPtr++)=vColor; + fX+=fXdelta; + } + pSrc+=nSrcWidth; + } + } + else if (bXEq) + { + float *pItermPtr=&*pIterm.begin(); + for (sint32 nY=0; nY1.f); + float *pItermPtr=&*pIterm.begin(); + sint32 nY; + for (nY=0; nYfFinal) + fNext=fFinal; + vColor+=((float)(fNext-fX))* float (pSrcLine[(sint32)floor(fX)]); + fX=fNext; + } + fX = fFinal; // ensure fX == fFinal + vColor/=(float)fXdelta; + *(pItermPtr++)=vColor; + } + pSrc+=nSrcWidth; + } + } + + if (bYMag) + { + double fYdelta=(double)(nSrcHeight)/(double)(nDestHeight); + sint32 nX; + for (nX=0; nX=0.f); + float vColor; + if (fVirgule>=0.5f) + { + if (fY<(double)(nSrcHeight-1)) + { + float vColor1=pIterm[((sint32)floor(fY))*nDestWidth+nX]; + float vColor2=pIterm[(((sint32)floor(fY))+1)*nDestWidth+nX]; + vColor=vColor1*(1.5f-(float)fVirgule)+vColor2*((float)fVirgule-0.5f); + } + else + vColor=pIterm[((sint32)floor(fY))*nDestWidth+nX]; + } + else + { + if (fY>=1.f) + { + float vColor1=pIterm[((sint32)floor(fY))*nDestWidth+nX]; + float vColor2=pIterm[(((sint32)floor(fY))-1)*nDestWidth+nX]; + vColor=vColor1*(0.5f+(float)fVirgule)+vColor2*(0.5f-(float)fVirgule); + } + else + vColor=pIterm[((sint32)floor(fY))*nDestWidth+nX]; + } + pDest[nX+nY*nDestWidth]=vColor; + fY+=fYdelta; + } + } + } + else if (bYEq) + { + for (sint32 nX=0; nX1.f); + sint32 nX; + for (nX=0; nXfFinal) + fNext=fFinal; + vColor+=((float)(fNext-fY))*pIterm[((sint32)floor(fY))*nDestWidth+nX]; + fY=fNext; + } + vColor/=(float)fYdelta; + pDest[nX+nY*nDestWidth]=vColor; + } + } + } +} + + +/*-------------------------------------------------------------------*\ + resamplePicture8Fast +\*-------------------------------------------------------------------*/ +void CBitmap::resamplePicture8Fast (const uint8 *pSrc, uint8 *pDest, + sint32 nSrcWidth, sint32 nSrcHeight, + sint32 nDestWidth, sint32 nDestHeight) +{ + // the image is divided by two : 1 pixel in dest = 4 pixels in src + // the resulting pixel in dest is an average of the four pixels in src + + nlassert(nSrcWidth % 2 == 0); + nlassert(nSrcHeight % 2 == 0); + nlassert(nSrcWidth / 2 == nDestWidth); + nlassert(nSrcHeight / 2 == nDestHeight); + + sint32 x, y, twoX, twoSrcWidthByY; + + for (y=0 ; y>2; + } + } +} + + /*-------------------------------------------------------------------*\ readTGA From fe018c959bf9bb8b9b1cc0226bde0e6f489bf8d7 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 4 Jan 2016 13:56:56 +0100 Subject: [PATCH 4/6] Changed: Use lowercase instead of uppercase for extensions --HG-- branch : develop --- code/nel/tools/3d/panoply_maker/panoply_maker.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp index e3fb126db..38a8818d7 100644 --- a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp +++ b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp @@ -322,8 +322,7 @@ int main(int argc, char* argv[]) NLMISC::CConfigFile::CVar &bitmap_extensions = cf.getVar ("bitmap_extensions"); for (uint k = 0; k < (uint) bitmap_extensions.size(); ++k) { - std::string ext = "." + bitmap_extensions.asString(k); - ext = NLMISC::strupr(ext); + std::string ext = "." + NLMISC::toLower(bitmap_extensions.asString(k)); if (std::find(bi.BitmapExtensions.begin(), bi.BitmapExtensions.end(), ext) == bi.BitmapExtensions.end()) { bi.BitmapExtensions.push_back(ext); @@ -481,7 +480,7 @@ static void BuildColoredVersions(const CBuildInfo &bi) { for (uint l = 0; l < bi.BitmapExtensions.size(); ++l) { - std::string fileExt = "." + NLMISC::strupr(NLMISC::CFile::getExtension(files[k])); + std::string fileExt = "." + NLMISC::toLower(NLMISC::CFile::getExtension(files[k])); if (fileExt == bi.BitmapExtensions[l]) { //nlwarning("Processing : %s ", files[k].c_str()); @@ -530,7 +529,7 @@ static bool CheckIfNeedRebuildColoredVersionForOneBitmap(const CBuildInfo &bi, c masks.clear(); std::string fileName = NLMISC::CFile::getFilenameWithoutExtension(fileNameWithExtension); - std::string fileExt = NLMISC::strupr(NLMISC::CFile::getExtension(fileNameWithExtension)); + std::string fileExt = NLMISC::toLower(NLMISC::CFile::getExtension(fileNameWithExtension)); for (uint k = 0; k < bi.ColorMasks.size(); ++k) { @@ -759,7 +758,7 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str masks.clear(); std::string fileName = NLMISC::CFile::getFilenameWithoutExtension(fileNameWithExtension); - std::string fileExt = NLMISC::strupr(NLMISC::CFile::getExtension(fileNameWithExtension)); + std::string fileExt = NLMISC::toLower(NLMISC::CFile::getExtension(fileNameWithExtension)); uint k; for (k = 0; k < bi.ColorMasks.size(); ++k) @@ -831,7 +830,7 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str if (os.open(maskFileName)) { - std::string ext = CFile::getExtension(maskFileName); + std::string ext = NLMISC::toLower(CFile::getExtension(maskFileName)); nlwarning("Optimizing mask %s...", maskFileName.c_str()); From ed98662de34f8875484020ce20a9bc68874b1e7e Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 4 Jan 2016 13:57:21 +0100 Subject: [PATCH 5/6] Changed: OutputPath is already "standardized" --HG-- branch : develop --- code/nel/tools/3d/panoply_maker/panoply_maker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp index 38a8818d7..70e3b979e 100644 --- a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp +++ b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp @@ -936,7 +936,7 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str nlinfo("Writing %s", outputFileName.c_str()); /// Save the result. We let propagate exceptions (if there's no more space disk it useless to continue...) { - std::string fullOutputPath = bi.OutputPath + "/" + outputFileName + bi.OutputFormat; + std::string fullOutputPath = bi.OutputPath + outputFileName + bi.OutputFormat; try { From aaa9c394d707cb90ed825961ea73e9c02120a3b8 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 4 Jan 2016 13:58:54 +0100 Subject: [PATCH 6/6] Fixed: If mask is using colors, convert it to grayscale using Red value (compatible with previous algorithm) --HG-- branch : develop --- .../tools/3d/panoply_maker/panoply_maker.cpp | 69 ++++++++++--------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp index 70e3b979e..dc0ace2a3 100644 --- a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp +++ b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp @@ -791,41 +791,49 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str throw NLMISC::Exception("Failed to load mask"); } - // masks can be converted to grayscale files - if (bi.OptimizeTextures > 0 && maskDepth > 8) + // convert color mask to grayscale (red is the new gray value) + if (li.Mask.getPixelFormat() == CBitmap::RGBA) { - if (!li.Mask.isGrayscale()) + // display a warning if checks enabled + if (bi.OptimizeTextures > 0 && !li.Mask.isGrayscale()) { nlwarning("Mask %s is using colors, results may by incorrect! Use OptimizeTextures = 2 to fix it.", maskFileName.c_str()); } + // get a pointer on original data + uint32 size = li.Mask.getPixels().size(); + uint32 *data = (uint32*)li.Mask.getPixels().getPtr(); + uint32 *endData = (uint32*)((uint8*)data + size); + + NLMISC::CRGBA *color = NULL; + + // process all pixels + while(data < endData) + { + color = (NLMISC::CRGBA*)data; + + // copy red value to green and blue, + // because only red is used for mask + color->B = color->G = color->R; + + // make opaque + color->A = 255; + + ++data; + } + } + + // convert image to real grayscale + if (li.Mask.PixelFormat != NLMISC::CBitmap::Luminance) + { + li.Mask.convertToType(NLMISC::CBitmap::Luminance); + } + + // masks can be converted to grayscale files + if (bi.OptimizeTextures > 0 && maskDepth > 8) + { if (bi.OptimizeTextures > 1) { - // get a pointer on original data - uint32 size = li.Mask.getPixels().size(); - uint32 *data = (uint32*)li.Mask.getPixels().getPtr(); - uint32 *endData = (uint32*)((uint8*)data + size); - - NLMISC::CRGBA *color = NULL; - - // process all pixels - while(data < endData) - { - color = (NLMISC::CRGBA*)data; - - // copy red value to green and blue, - // because only red is used for mask - color->B = color->G = color->R; - - // make opaque - color->A = 255; - - ++data; - } - - // convert image to real grayscale - li.Mask.convertToType(NLMISC::CBitmap::Luminance); - NLMISC::COFile os; if (os.open(maskFileName)) @@ -855,11 +863,6 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str } } - if (li.Mask.PixelFormat != NLMISC::CBitmap::Luminance) - { - li.Mask.convertToType(NLMISC::CBitmap::Luminance); - } - /// make sure the mask has the same size if (li.Mask.getWidth() != srcBitmap.getWidth() || li.Mask.getHeight() != srcBitmap.getHeight())