diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 52108378a..f96cd0080 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -6900,6 +6900,14 @@ void Renderer::selectUsingColorPicking(Selection::UnitContainer &units, PixelBufferWrapper::end(); vector rendererModels; + if(rendererUnits.empty() == false) { + copy(rendererUnits.begin(), rendererUnits.end(), std::inserter(rendererModels, rendererModels.begin())); + } + if(rendererObjects.empty() == false) { + copy(rendererObjects.begin(), rendererObjects.end(), std::inserter(rendererModels, rendererModels.begin())); + } + +/* for(unsigned int i = 0; i < rendererObjects.size(); ++i) { Object *object = rendererObjects[i]; rendererModels.push_back(object); @@ -6914,6 +6922,7 @@ void Renderer::selectUsingColorPicking(Selection::UnitContainer &units, //printf("In [%s::%s] Line: %d rendered unit i = %d [%s] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,unit->getUniquePickName().c_str(),unit->getColorDescription().c_str()); //printf("In [%s::%s] Line: %d\ni = %d [%d - %s] ptr[%p] color[%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,unit->getId(),unit->getType()->getName().c_str(),unit->getCurrentModelPtr(),unit->getColorDescription().c_str()); } +*/ vector pickedList = BaseColorPickEntity::getPickedList(x,y,w,h, rendererModels); //printf("In [%s::%s] Line: %d pickedList = %d models rendered = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,pickedList.size(),rendererModels.size()); @@ -6941,7 +6950,6 @@ void Renderer::selectUsingColorPicking(Selection::UnitContainer &units, if(unit != NULL && unit->isAlive()) { units.push_back(unit); } - } } } diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index dffcac415..3adffe79b 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -1434,14 +1434,14 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col void PixelBufferWrapper::begin() { if(PixelBufferWrapper::isPBOEnabled == true) { // set the framebuffer to read - glReadBuffer(GL_FRONT); + //glReadBuffer(GL_FRONT); } } void PixelBufferWrapper::end() { if(PixelBufferWrapper::isPBOEnabled == true) { // set the framebuffer to read - glReadBuffer(GL_BACK); + //glReadBuffer(GL_BACK); } } @@ -1557,6 +1557,7 @@ void BaseColorPickEntity::endPicking() { vector BaseColorPickEntity::getPickedList(int x,int y,int w,int h, const vector &rendererModels) { vector pickedModels; + pickedModels.reserve(rendererModels.size()); //printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //static auto_ptr cachedPixels; @@ -1629,11 +1630,11 @@ vector BaseColorPickEntity::getPickedList(int x,int y,int w,int h, unsigned char *pixel = &pixelBuffer[index]; // Skip duplicate scanned colors - map > >::iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]); + map > >::const_iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]); if(iterFind1 != colorAlreadyPickedList.end()) { - map >::iterator iterFind2 = iterFind1->second.find(pixel[1]); + map >::const_iterator iterFind2 = iterFind1->second.find(pixel[1]); if(iterFind2 != iterFind1->second.end()) { - map::iterator iterFind3 = iterFind2->second.find(pixel[2]); + map::const_iterator iterFind3 = iterFind2->second.find(pixel[2]); if(iterFind3 != iterFind2->second.end()) { continue; }