diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 1ae7274d..25d748a6 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -7035,7 +7035,6 @@ void Renderer::selectUsingColorPicking(Selection::UnitContainer &units, //printf("In [%s::%s] Line: %d pickedList = %d models rendered = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,pickedList.size(),rendererModels.size()); if(pickedList.empty() == false) { - units.reserve(pickedList.size()); for(unsigned int i = 0; i < pickedList.size(); ++i) { int index = pickedList[i]; //printf("In [%s::%s] Line: %d searching for selected object i = %d index = %d units = %d objects = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,index,rendererUnits.size(),rendererObjects.size()); @@ -7046,10 +7045,7 @@ void Renderer::selectUsingColorPicking(Selection::UnitContainer &units, if(object != NULL) { obj = object; - if(withObjectSelection == true) { - //printf("In [%s::%s] Line: %d found selected object [%p]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,obj); - break; - } + break; } } } diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 3b1dec3e..9b66876b 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -1610,7 +1610,7 @@ vector BaseColorPickEntity::getPickedList(int x,int y,int w,int h, //printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); static Chrono lastSnapshot(true); - const int selectionMillisecondUpdate = 100; + const int selectionMillisecondUpdate = -1; if(rendererModels.empty() == false) { if(PixelBufferWrapper::getIsPBOEnable() == true) { @@ -1668,9 +1668,19 @@ vector BaseColorPickEntity::getPickedList(int x,int y,int w,int h, map modelAlreadyPickedList; map > > colorAlreadyPickedList; int nEnd = w * h; - for(int x = 0; x < nEnd && pickedModels.size() < rendererModels.size(); ++x) { + unsigned char *oldpixel = &pixelBuffer[0]; + for(int x = 0; x < nEnd && pickedModels.size() < rendererModels.size(); x=x+4) { int index = x * COLOR_COMPONENTS; unsigned char *pixel = &pixelBuffer[index]; + if(pixel[3]==0) continue; + if(x>0) + { + oldpixel = &pixelBuffer[index-1*COLOR_COMPONENTS]; + if(memcmp(pixel,oldpixel,4)) continue; + } + + + // Skip duplicate scanned colors map > >::const_iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]);