Speed for colorpicking :-D. Its nearly as fast as selectbuf now . ( and tree selection for colorpicking is fixed )
This commit is contained in:
parent
c8b6a9f410
commit
9d3c99d6d0
|
@ -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());
|
//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) {
|
if(pickedList.empty() == false) {
|
||||||
units.reserve(pickedList.size());
|
|
||||||
for(unsigned int i = 0; i < pickedList.size(); ++i) {
|
for(unsigned int i = 0; i < pickedList.size(); ++i) {
|
||||||
int index = pickedList[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());
|
//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) {
|
if(object != NULL) {
|
||||||
obj = object;
|
obj = object;
|
||||||
if(withObjectSelection == true) {
|
break;
|
||||||
//printf("In [%s::%s] Line: %d found selected object [%p]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,obj);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1610,7 +1610,7 @@ vector<int> BaseColorPickEntity::getPickedList(int x,int y,int w,int h,
|
||||||
//printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
static Chrono lastSnapshot(true);
|
static Chrono lastSnapshot(true);
|
||||||
const int selectionMillisecondUpdate = 100;
|
const int selectionMillisecondUpdate = -1;
|
||||||
|
|
||||||
if(rendererModels.empty() == false) {
|
if(rendererModels.empty() == false) {
|
||||||
if(PixelBufferWrapper::getIsPBOEnable() == true) {
|
if(PixelBufferWrapper::getIsPBOEnable() == true) {
|
||||||
|
@ -1668,9 +1668,19 @@ vector<int> BaseColorPickEntity::getPickedList(int x,int y,int w,int h,
|
||||||
map<int,bool> modelAlreadyPickedList;
|
map<int,bool> modelAlreadyPickedList;
|
||||||
map<unsigned char,map<unsigned char, map<unsigned char,bool> > > colorAlreadyPickedList;
|
map<unsigned char,map<unsigned char, map<unsigned char,bool> > > colorAlreadyPickedList;
|
||||||
int nEnd = w * h;
|
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;
|
int index = x * COLOR_COMPONENTS;
|
||||||
unsigned char *pixel = &pixelBuffer[index];
|
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
|
// Skip duplicate scanned colors
|
||||||
map<unsigned char,map<unsigned char, map<unsigned char,bool> > >::const_iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]);
|
map<unsigned char,map<unsigned char, map<unsigned char,bool> > >::const_iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user