- see if this speeds up color picking

This commit is contained in:
Mark Vejvoda
2013-01-16 16:58:28 +00:00
parent d7eeaa4d8d
commit ce7982dc91
2 changed files with 15 additions and 6 deletions

View File

@@ -6900,6 +6900,14 @@ void Renderer::selectUsingColorPicking(Selection::UnitContainer &units,
PixelBufferWrapper::end();
vector<BaseColorPickEntity *> 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<int> 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);
}
}
}
}

View File

@@ -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<int> BaseColorPickEntity::getPickedList(int x,int y,int w,int h,
const vector<BaseColorPickEntity *> &rendererModels) {
vector<int> pickedModels;
pickedModels.reserve(rendererModels.size());
//printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//static auto_ptr<unsigned char> cachedPixels;
@@ -1629,11 +1630,11 @@ vector<int> BaseColorPickEntity::getPickedList(int x,int y,int w,int h,
unsigned char *pixel = &pixelBuffer[index];
// Skip duplicate scanned colors
map<unsigned char,map<unsigned char, map<unsigned char,bool> > >::iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]);
map<unsigned char,map<unsigned char, map<unsigned char,bool> > >::const_iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]);
if(iterFind1 != colorAlreadyPickedList.end()) {
map<unsigned char, map<unsigned char,bool> >::iterator iterFind2 = iterFind1->second.find(pixel[1]);
map<unsigned char, map<unsigned char,bool> >::const_iterator iterFind2 = iterFind1->second.find(pixel[1]);
if(iterFind2 != iterFind1->second.end()) {
map<unsigned char,bool>::iterator iterFind3 = iterFind2->second.find(pixel[2]);
map<unsigned char,bool>::const_iterator iterFind3 = iterFind2->second.find(pixel[2]);
if(iterFind3 != iterFind2->second.end()) {
continue;
}