render full selection of huge part models in real time
This commit is contained in:
@@ -196,13 +196,18 @@ void SoBrepEdgeSet::renderSelection(SoGLRenderAction *action)
|
||||
|
||||
int num = (int)this->sl.size();
|
||||
if (num > 0) {
|
||||
cindices = &(this->sl[0]);
|
||||
numcindices = (int)this->sl.size();
|
||||
if (!validIndexes(coords, this->sl)) {
|
||||
SoDebugError::postWarning("SoBrepEdgeSet::renderSelection", "selectionIndex out of range");
|
||||
if (this->sl[0] < 0) {
|
||||
renderShape(static_cast<const SoGLCoordinateElement*>(coords), cindices, numcindices);
|
||||
}
|
||||
else {
|
||||
renderShape(static_cast<const SoGLCoordinateElement*>(coords), cindices, numcindices);
|
||||
cindices = &(this->sl[0]);
|
||||
numcindices = (int)this->sl.size();
|
||||
if (!validIndexes(coords, this->sl)) {
|
||||
SoDebugError::postWarning("SoBrepEdgeSet::renderSelection", "selectionIndex out of range");
|
||||
}
|
||||
else {
|
||||
renderShape(static_cast<const SoGLCoordinateElement*>(coords), cindices, numcindices);
|
||||
}
|
||||
}
|
||||
}
|
||||
state->pop();
|
||||
@@ -275,25 +280,28 @@ void SoBrepEdgeSet::doAction(SoAction* action)
|
||||
|
||||
this->selectionColor = selaction->getColor();
|
||||
if (selaction->getType() == Gui::SoSelectionElementAction::All) {
|
||||
const int32_t* cindices = this->coordIndex.getValues(0);
|
||||
int numcindices = this->coordIndex.getNum();
|
||||
unsigned int num = std::count_if(cindices, cindices+numcindices,
|
||||
std::bind2nd(std::equal_to<int32_t>(), -1));
|
||||
//const int32_t* cindices = this->coordIndex.getValues(0);
|
||||
//int numcindices = this->coordIndex.getNum();
|
||||
//unsigned int num = std::count_if(cindices, cindices+numcindices,
|
||||
// std::bind2nd(std::equal_to<int32_t>(), -1));
|
||||
|
||||
//this->sl.clear();
|
||||
//this->selectionIndex.setNum(num);
|
||||
//int32_t* v = this->selectionIndex.startEditing();
|
||||
//for (unsigned int i=0; i<num;i++)
|
||||
// v[i] = i;
|
||||
//this->selectionIndex.finishEditing();
|
||||
|
||||
//int numsegm = this->selectionIndex.getNum();
|
||||
//if (numsegm > 0) {
|
||||
// const int32_t* selsegm = this->selectionIndex.getValues(0);
|
||||
// const int32_t* cindices = this->coordIndex.getValues(0);
|
||||
// int numcindices = this->coordIndex.getNum();
|
||||
// createIndexArray(selsegm, numsegm, cindices, numcindices, this->sl);
|
||||
//}
|
||||
this->selectionIndex.setValue(-1); // all
|
||||
this->sl.clear();
|
||||
this->selectionIndex.setNum(num);
|
||||
int32_t* v = this->selectionIndex.startEditing();
|
||||
for (unsigned int i=0; i<num;i++)
|
||||
v[i] = i;
|
||||
this->selectionIndex.finishEditing();
|
||||
|
||||
int numsegm = this->selectionIndex.getNum();
|
||||
if (numsegm > 0) {
|
||||
const int32_t* selsegm = this->selectionIndex.getValues(0);
|
||||
const int32_t* cindices = this->coordIndex.getValues(0);
|
||||
int numcindices = this->coordIndex.getNum();
|
||||
createIndexArray(selsegm, numsegm, cindices, numcindices, this->sl);
|
||||
}
|
||||
this->sl.push_back(-1);
|
||||
return;
|
||||
}
|
||||
else if (selaction->getType() == Gui::SoSelectionElementAction::None) {
|
||||
|
||||
@@ -219,12 +219,13 @@ void SoBrepFaceSet::doAction(SoAction* action)
|
||||
Gui::SoSelectionElementAction* selaction = static_cast<Gui::SoSelectionElementAction*>(action);
|
||||
this->selectionColor = selaction->getColor();
|
||||
if (selaction->getType() == Gui::SoSelectionElementAction::All) {
|
||||
int num = this->partIndex.getNum();
|
||||
this->selectionIndex.setNum(num);
|
||||
int32_t* v = this->selectionIndex.startEditing();
|
||||
for (int i=0; i<num;i++)
|
||||
v[i] = i;
|
||||
this->selectionIndex.finishEditing();
|
||||
//int num = this->partIndex.getNum();
|
||||
//this->selectionIndex.setNum(num);
|
||||
//int32_t* v = this->selectionIndex.startEditing();
|
||||
//for (int i=0; i<num;i++)
|
||||
// v[i] = i;
|
||||
//this->selectionIndex.finishEditing();
|
||||
this->selectionIndex.setValue(-1); // all
|
||||
PRIVATE(this)->updateVbo = true;
|
||||
return;
|
||||
}
|
||||
@@ -933,11 +934,19 @@ void SoBrepFaceSet::renderSelection(SoGLRenderAction *action)
|
||||
}
|
||||
|
||||
// coords
|
||||
int length = (int)pindices[id]*4;
|
||||
int length=0;
|
||||
int start=0;
|
||||
for (int j=0;j<id;j++)
|
||||
start+=(int)pindices[j];
|
||||
start *= 4;
|
||||
int numparts=1;
|
||||
// if < 0 then select everything
|
||||
if (id < 0) {
|
||||
length = numindices;
|
||||
}
|
||||
else {
|
||||
length = (int)pindices[id]*4;
|
||||
for (int j=0;j<id;j++)
|
||||
start+=(int)pindices[j];
|
||||
start *= 4;
|
||||
}
|
||||
|
||||
// normals
|
||||
const SbVec3f * normals_s = normals;
|
||||
@@ -950,7 +959,7 @@ void SoBrepFaceSet::renderSelection(SoGLRenderAction *action)
|
||||
nbind = OVERALL;
|
||||
|
||||
renderShape(action, false, static_cast<const SoGLCoordinateElement*>(coords), &(cindices[start]), length,
|
||||
&(pindices[id]), 1, normals_s, nindices_s, &mb, mindices, &tb, tindices, nbind, mbind, doTextures?1:0);
|
||||
&(pindices[id]), numparts, normals_s, nindices_s, &mb, mindices, &tb, tindices, nbind, mbind, doTextures?1:0);
|
||||
}
|
||||
state->pop();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user