diff --git a/code/nel/src/3d/ps_util.cpp b/code/nel/src/3d/ps_util.cpp index a09108ed5..94d67c777 100644 --- a/code/nel/src/3d/ps_util.cpp +++ b/code/nel/src/3d/ps_util.cpp @@ -271,7 +271,6 @@ void CPSUtil::displayBasis(IDriver *driver, const CMatrix &modelMat, const NLMIS void CPSUtil::print(IDriver *driver, const std::string &text, CFontGenerator &fg, CFontManager &fm, const CVector &pos, float size, NLMISC::CRGBA col /*= NLMISC::CRGBA::White*/) { NL_PS_FUNC(CPSUtil_print) - nlassert((&fg) && (&fm)); CComputedString cptedString; fm.computeString ( text, &fg, diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index f1c91c4a4..b409de661 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -1537,7 +1537,7 @@ namespace NLGUI for (uint e=0 ; e<__num__ ; e++) \ { \ std::string str = __toStringFunc__((__enum__)e); \ - std::string temp = __name__ + toString(".") + __toStringFunc__((__enum__)e) + " = " + toString("%d;", e); \ + std::string temp = __name__ + toString(".") + __toStringFunc__((__enum__)e) + " = " + toString("%u;", e); \ ls.executeScript(temp); \ } \ diff --git a/code/nel/tools/3d/build_interface/main.cpp b/code/nel/tools/3d/build_interface/main.cpp index 343673b34..1b13a0f71 100644 --- a/code/nel/tools/3d/build_interface/main.cpp +++ b/code/nel/tools/3d/build_interface/main.cpp @@ -268,7 +268,11 @@ int main(int nNbArg, char **ppArgs) uint8 colors = pBtmp->load(inFile); - if (colors != 32) throw NLMISC::Exception(AllMapNames[i] + " is using " + toString(colors) + " bits colors, only 32 bit supported!"); + if (pBtmp->getPixelFormat() != CBitmap::RGBA) + { + nlwarning("Converting %s to RGBA (32 bits), originally using %u bits...", AllMapNames[i].c_str(), (uint)colors); + pBtmp->convertToType(CBitmap::RGBA); + } AllMaps[i] = pBtmp; } diff --git a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp index dc0ace2a3..328639eb6 100644 --- a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp +++ b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp @@ -670,8 +670,8 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str { uint8 value = 0; - // texture can be converted if all alphas are 0 or 255 - if (srcBitmap.isAlphaUniform(&value) && (value == 255 || value == 0)) + // texture can be converted if all alphas are 255 + if (srcBitmap.isAlphaUniform(&value) && value == 255) { if (bi.OptimizeTextures > 1) { diff --git a/code/nel/tools/3d/textures_optimizer/main.cpp b/code/nel/tools/3d/textures_optimizer/main.cpp index 022709444..84b28d421 100644 --- a/code/nel/tools/3d/textures_optimizer/main.cpp +++ b/code/nel/tools/3d/textures_optimizer/main.cpp @@ -29,8 +29,10 @@ void writeInstructions() std::cout << " By default, it only make checks and display if texture can optimized or not" << std::endl; std::cout << std::endl; std::cout << "with" << std::endl; - std::cout << "-a : Remove alpha channel if useless" << std::endl; + std::cout << "-a : Remove alpha channel if useless (255)" << std::endl; std::cout << "-g : Convert to grayscale if all pixels are gray" << std::endl; + std::cout << "-t : Apply texture optimizations (same as -a -g)" << std::endl; + std::cout << "-m : Apply mask optimizations (convert to grayscale using red value and remove alpha)" << std::endl; std::cout << std::endl; std::cout << "-h or -? for this help" << std::endl; std::cout << std::endl; @@ -38,6 +40,8 @@ void writeInstructions() bool FixAlpha = false; bool FixGrayscale = false; +bool TextureOptimizations = false; +bool MaskOptimizations = false; std::vector InputFilenames; @@ -74,6 +78,18 @@ bool parseOptions(int argc, char **argv) { FixGrayscale = true; } + // Texture optimizations + else if (option == "t") + { + TextureOptimizations = true; + FixAlpha = true; + FixGrayscale = true; + } + // Mask optimizations + else if (option == "m") + { + MaskOptimizations = true; + } else if (option == "h" || option == "?") { return false; @@ -168,35 +184,74 @@ int main(int argc, char **argv) isGrayscale = true; } - if (!isGrayscale && bitmap.isGrayscale()) + if (MaskOptimizations && (!isGrayscale || hasAlpha)) { - std::cout << InputFilenames[i] << " (grayscale image with RGB colors)" << std::endl; + std::cout << InputFilenames[i] << " (mask with wrong format)" << std::endl; - if (FixGrayscale) + if (!isGrayscale) { - if (!bitmap.convertToType(hasAlpha ? NLMISC::CBitmap::AlphaLuminance:NLMISC::CBitmap::Luminance)) + // get a pointer on original RGBA data + uint32 size = bitmap.getPixels().size(); + uint32 *data = (uint32*)bitmap.getPixels().getPtr(); + uint32 *endData = (uint32*)((uint8*)data + size); + + NLMISC::CRGBA *color = NULL; + + // process all pixels + while(data < endData) { - std::cerr << "Unable to convert to Luminance" << std::endl; - return 1; + 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; } - - isGrayscale = true; - modified = true; } + + // already in grayscale, just remove alpha + bitmap.convertToType(NLMISC::CBitmap::Luminance); + + isGrayscale = true; + hasAlpha = false; + modified = true; } - - uint8 alpha = 0; - - if (hasAlpha && bitmap.isAlphaUniform(&alpha)) + else { - std::cout << InputFilenames[i] << " (image with uniform alpha channel " << (sint)alpha << ")" << std::endl; - - if (FixAlpha && (alpha == 0 || alpha == 255)) + if (!isGrayscale && bitmap.isGrayscale()) { - bitmap.makeOpaque(); + std::cout << InputFilenames[i] << " (grayscale image with RGB colors)" << std::endl; - hasAlpha = false; - modified = true; + if (FixGrayscale) + { + if (!bitmap.convertToType(hasAlpha ? NLMISC::CBitmap::AlphaLuminance:NLMISC::CBitmap::Luminance)) + { + std::cerr << "Unable to convert to Luminance" << std::endl; + return 1; + } + + isGrayscale = true; + modified = true; + } + } + + uint8 alpha = 0; + + if (hasAlpha && bitmap.isAlphaUniform(&alpha)) + { + std::cout << InputFilenames[i] << " (image with uniform alpha channel " << (sint)alpha << ")" << std::endl; + + if (FixAlpha && alpha == 255) + { + bitmap.makeOpaque(); + + hasAlpha = false; + modified = true; + } } } diff --git a/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp b/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp index 69f701054..617605399 100644 --- a/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp +++ b/code/ryzom/tools/client/r2_islands_textures/screenshot_islands.cpp @@ -49,6 +49,7 @@ #include #include +#include using namespace NLMISC; using namespace NL3D; @@ -70,8 +71,8 @@ UMaterial sceneMaterial; namespace R2 { -const TBufferEntry InteriorValue= (TBufferEntry)(~0u-1); -const TBufferEntry ValueBorder= (TBufferEntry)(~0u-2); +const TBufferEntry InteriorValue = std::numeric_limits::max()-1; +const TBufferEntry ValueBorder = std::numeric_limits::max()-2; const uint32 BigValue= 15*5; const float limitValue = 200.0; @@ -1957,7 +1958,7 @@ void CProximityMapBuffer::load(const std::string& name) } } // setup the next pixel in the output buffers... - _Buffer[y*_ScanWidth+x]= (isAccessible? 0: (TBufferEntry)~0u); + _Buffer[y*_ScanWidth+x]= (isAccessible? 0:std::numeric_limits::max()); } } } @@ -2044,7 +2045,7 @@ void CProximityMapBuffer::_prepareBufferForZoneProximityMap(const CProximityZone uint32 zoneWidth= zone.getZoneWidth(); uint32 zoneHeight= zone.getZoneHeight(); zoneBuffer.clear(); - zoneBuffer.resize(zoneWidth*zoneHeight,(TBufferEntry)~0u); + zoneBuffer.resize(zoneWidth*zoneHeight, std::numeric_limits::max()); // setup the buffer's accessible points and prime vects[0] with the set of accessible points in the zone buffer for (uint32 i=0;i=startOffset && zoneBuffer[offset-1]==(TBufferEntry)~0u) + if(offset-1>=startOffset && zoneBuffer[offset-1] == std::numeric_limits::max()) { zoneBuffer[offset-1] = ValueBorder; } - if(offset+1<=endOffset && zoneBuffer[offset+1]==(TBufferEntry)~0u) + if(offset+1<=endOffset && zoneBuffer[offset+1] == std::numeric_limits::max()) { zoneBuffer[offset+1] = ValueBorder; } @@ -2105,11 +2106,11 @@ void CProximityMapBuffer::_prepareBufferForZoneProximityMap(const CProximityZone { zoneBuffer[offset]= InteriorValue; - if(offset>zoneWidth && zoneBuffer[offset-zoneWidth]==(TBufferEntry)~0u) + if(offset>zoneWidth && zoneBuffer[offset-zoneWidth] == std::numeric_limits::max()) { zoneBuffer[offset-zoneWidth] = ValueBorder; } - if(offset+zoneWidth::max()) { zoneBuffer[offset+zoneWidth] = ValueBorder; } @@ -2154,19 +2155,19 @@ void CProximityMapBuffer::generateZoneProximityMap(const CProximityZone& zone,TB zoneBuffer[val]=dist; // decompose into x and y in order to manage identification of neighbour cells correctly - uint32 x= val% zoneWidth; - uint32 y= val/ zoneWidth; + uint32 x= val % zoneWidth; + uint32 y= val / zoneWidth; #define TEST_MOVE(xoffs,yoffs,newDist)\ {\ - if (((uint32)(x+(xoffs)) BigValue) || (zoneBuffer[newVal]==ValueBorder && newDist > BigValue));\ - if (zoneBuffer[newVal]>(newDist) && !isInterior)\ + uint32 newVal= val+xoffs+(yoffs*zoneWidth);\ + bool isInterior = ((zoneBuffer[newVal] == InteriorValue && newDist > BigValue) || (zoneBuffer[newVal] == ValueBorder && newDist > BigValue));\ + if (zoneBuffer[newVal] > newDist && !isInterior)\ {\ - zoneBuffer[newVal]=(newDist);\ - vects[(newDist)&15].push_back(newVal);\ + zoneBuffer[newVal] = newDist;\ + vects[newDist & 15].push_back(newVal);\ ++entriesToTreat;\ }\ }\ @@ -2239,8 +2240,8 @@ CProximityZone::CProximityZone(uint32 scanWidth,uint32 scanHeight,sint32 xOffset _MaxOffset = scanWidth * scanHeight -1; - _XMin = ~0u; - _YMin = ~0u; + _XMin = std::numeric_limits::max(); + _YMin = std::numeric_limits::max(); _XMax = 0; _YMax = 0; diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h index 50544b090..bae7f8142 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h @@ -190,8 +190,9 @@ public: TParamInfo(const std::string &name, STRING_MANAGER::TParamType type, const std::string &compilerParam = "") : ParamName(name), - ParamType(type), - CompilerParam(compilerParam) + CompilerParam(compilerParam), + ParamType(type) + { } }; @@ -328,7 +329,7 @@ private: std::string genPreRequisites(); // forbidden copy constructor ! - CMissionData(const CMissionData &other) + CMissionData(const CMissionData &other):NLMISC::CRefCount() { nlstop; } diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp index 79b7e5095..18d17ca13 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/steps.cpp @@ -255,8 +255,8 @@ public: CStepObjective(CMissionData &md, IPrimitive *prim, const std::string &prefix = "") : CStep(md, prim), - _HideObj(false), - _Prefix(prefix) + _Prefix(prefix), + _HideObj(false) { } diff --git a/code/ryzom/tools/translation_tools/extract_new_sheet_names.cpp b/code/ryzom/tools/translation_tools/extract_new_sheet_names.cpp index dbc4d0c0b..a2ef5f2d2 100644 --- a/code/ryzom/tools/translation_tools/extract_new_sheet_names.cpp +++ b/code/ryzom/tools/translation_tools/extract_new_sheet_names.cpp @@ -206,7 +206,7 @@ void extractNewWords(string workSheetFileName, string columnId, IWordListBuilder return; } // get the name column index - uint nameColIndex; + uint nameColIndex = 0; if(!workSheet.findCol(ucstring("name"), nameColIndex)) { nlwarning("Error: Don't find the column 'name'. '%s' Aborted", workSheetFileName.c_str());