ScenePicking.cpp (pymol-open-source-2.2.0) | : | ScenePicking.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 210 | skipping to change at line 210 | |||
/* atom picking HACK - obfuscative coding */ | /* atom picking HACK - obfuscative coding */ | |||
CScene *I = G->Scene; | CScene *I = G->Scene; | |||
int debug_pick = 0; | int debug_pick = 0; | |||
unsigned int lowBits = 0, highBits = 0; | unsigned int lowBits = 0, highBits = 0; | |||
unsigned int index; | unsigned int index; | |||
bool bits32 = SceneHas32BitColor(G); | bool bits32 = SceneHas32BitColor(G); | |||
debug_pick = SettingGetGlobal_i(G, cSetting_debug_pick); | debug_pick = SettingGetGlobal_i(G, cSetting_debug_pick); | |||
SceneGLClearColor(0.0, 0.0, 0.0, 0.); | SceneGLClearColor(0.0, 0.0, 0.0, 0.); | |||
if (!I->pickVLA){ | if (I->pickVLA.empty()){ | |||
I->pickVLA = VLACalloc(Picking, 5000); | I->pickVLA.resize(5000); | |||
} | } | |||
if(I->grid.active) | if(I->grid.active) | |||
GridGetGLViewport(G, &I->grid); | GridGetGLViewport(G, &I->grid); | |||
// two passes in 16bit picking mode, if needed | // two passes in 16bit picking mode, if needed | |||
for (int pass = 0;; ++pass) { | for (int pass = 0;; ++pass) { | |||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |||
if (I->invPick || !SettingGetGlobal_b(G, cSetting_use_shaders)){ | if (I->invPick || !SettingGetGlobal_b(G, cSetting_use_shaders)){ | |||
I->pickVLA[0].src.index = 0; | I->pickVLA.begin()->src.index = 0; | |||
I->pickVLA[0].src.bond = 2 + pass; | I->pickVLA.begin()->src.bond = 2 + pass; | |||
} else { | } else { | |||
I->pickVLA[0].src.bond = 0 + pass; | I->pickVLA.begin()->src.bond = 0 + pass; | |||
} | } | |||
{ | { | |||
int slot; | int slot; | |||
for(slot = 0; slot <= I->grid.last_slot; slot++) { | for(slot = 0; slot <= I->grid.last_slot; slot++) { | |||
if(I->grid.active) { | if(I->grid.active) { | |||
GridSetGLViewport(&I->grid, slot); | GridSetGLViewport(&I->grid, slot); | |||
} | } | |||
SceneRenderAll(G, context, NULL, &I->pickVLA, 0, true, 0.0F, &I->grid, 0 , 0, bits32); | SceneRenderAll(G, context, NULL, std::addressof(I->pickVLA), 0, true, 0. 0F, &I->grid, 0, 0, bits32); | |||
} | } | |||
} | } | |||
if(debug_pick) { | if(debug_pick) { | |||
PyMOL_SwapBuffers(G->PyMOL); | PyMOL_SwapBuffers(G->PyMOL); | |||
PSleep(G, 1000000 * debug_pick / 4); | PSleep(G, 1000000 * debug_pick / 4); | |||
PyMOL_SwapBuffers(G->PyMOL); | PyMOL_SwapBuffers(G->PyMOL); | |||
} | } | |||
if (pass == 1) { | if (pass == 1) { | |||
skipping to change at line 263 | skipping to change at line 263 | |||
break; | break; | |||
} | } | |||
} | } | |||
if(I->grid.active) | if(I->grid.active) | |||
GridSetGLViewport(&I->grid, -1); | GridSetGLViewport(&I->grid, -1); | |||
if(debug_pick) { | if(debug_pick) { | |||
if (bits32){ | if (bits32){ | |||
PRINTFB(G, FB_Scene, FB_Details) | PRINTFB(G, FB_Scene, FB_Details) | |||
" SceneClick-Detail: lowBits=%u index %u < %u?\n", lowBits, index, I->pic kVLA[0].src.index ENDFB(G); | " SceneClick-Detail: lowBits=%u index %u < %u?\n", lowBits, index, I->pic kVLA.begin()->src.index ENDFB(G); | |||
} else { | } else { | |||
PRINTFB(G, FB_Scene, FB_Details) | PRINTFB(G, FB_Scene, FB_Details) | |||
" SceneClick-Detail: lowBits=%u highBits=%u index %u < %u?\n", lowBits, h ighBits, index, I->pickVLA[0].src.index ENDFB(G); | " SceneClick-Detail: lowBits=%u highBits=%u index %u < %u?\n", lowBits, h ighBits, index, I->pickVLA.begin()->src.index ENDFB(G); | |||
} | } | |||
} | } | |||
if(index && (index <= I->pickVLA[0].src.index)) { | if(index && (index <= I->pickVLA.begin()->src.index)) { | |||
*pick = I->pickVLA[index]; /* return object info */ | *pick = I->pickVLA[index]; /* return object info */ | |||
if(debug_pick) { | if(debug_pick) { | |||
PRINTFB(G, FB_Scene, FB_Details) | PRINTFB(G, FB_Scene, FB_Details) | |||
" SceneClick-Detail: obj %p index %d bond %d\n", | " SceneClick-Detail: obj %p index %d bond %d\n", | |||
pick->context.object, pick->src.index, pick->src.bond ENDFB(G); | pick->context.object, pick->src.index, pick->src.bond ENDFB(G); | |||
} | } | |||
// if cPickableNoPick then set object to NULL since nothing picked | // if cPickableNoPick then set object to NULL since nothing picked | |||
if (pick->src.bond == cPickableNoPick) | if (pick->src.bond == cPickableNoPick) | |||
pick->context.object = NULL; | pick->context.object = NULL; | |||
} else { | } else { | |||
skipping to change at line 399 | skipping to change at line 399 | |||
void SceneRenderPickingMultiPick(PyMOLGlobals * G, SceneUnitContext *context, Mu ltipick * smp, GLenum render_buffer){ | void SceneRenderPickingMultiPick(PyMOLGlobals * G, SceneUnitContext *context, Mu ltipick * smp, GLenum render_buffer){ | |||
/* multiple atom picking HACK - even more obfuscative coding */ | /* multiple atom picking HACK - even more obfuscative coding */ | |||
CScene *I = G->Scene; | CScene *I = G->Scene; | |||
Picking *pik; | Picking *pik; | |||
unsigned int *lowBitVLA = NULL, *highBitVLA = NULL; | unsigned int *lowBitVLA = NULL, *highBitVLA = NULL; | |||
int high, low; | int high, low; | |||
unsigned int lastIndex = 0; | unsigned int lastIndex = 0; | |||
unsigned int index; | unsigned int index; | |||
void *lastPtr = NULL; | void *lastPtr = NULL; | |||
int nPick; | int nPick; | |||
int nHighBits, nLowBits; | int nHighBits = 0, nLowBits; | |||
bool bits32 = SceneHas32BitColor(G); | bool bits32 = SceneHas32BitColor(G); | |||
SceneGLClearColor(0.0, 0.0, 0.0, 0.0); | SceneGLClearColor(0.0, 0.0, 0.0, 0.0); | |||
if (!I->pickVLA){ | if (I->pickVLA.empty()){ | |||
I->pickVLA = VLACalloc(Picking, 5000); | I->pickVLA.resize(5000); | |||
} | } | |||
if(I->grid.active) | if(I->grid.active) | |||
GridGetGLViewport(G, &I->grid); | GridGetGLViewport(G, &I->grid); | |||
// two passes in 16bit picking mode, if needed | // two passes in 16bit picking mode, if needed | |||
for (int pass = 0;; ++pass) { | for (int pass = 0;; ++pass) { | |||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |||
if (I->invPick || !SettingGetGlobal_b(G, cSetting_use_shaders)){ | if (I->invPick || !SettingGetGlobal_b(G, cSetting_use_shaders)){ | |||
I->pickVLA[0].src.index = 0; | I->pickVLA.begin()->src.index = 0; | |||
I->pickVLA[0].src.bond = 2 + pass; | I->pickVLA.begin()->src.bond = 2 + pass; | |||
} else { | } else { | |||
I->pickVLA[0].src.bond = 0 + pass; | I->pickVLA.begin()->src.bond = 0 + pass; | |||
} | } | |||
{ | { | |||
int slot; | int slot; | |||
for(slot = 0; slot <= I->grid.last_slot; slot++) { | for(slot = 0; slot <= I->grid.last_slot; slot++) { | |||
if(I->grid.active) { | if(I->grid.active) { | |||
GridSetGLViewport(&I->grid, slot); | GridSetGLViewport(&I->grid, slot); | |||
} | } | |||
SceneRenderAll(G, context, NULL, &I->pickVLA, 0, true, 0.0F, &I->grid, 0 , 0, bits32); | SceneRenderAll(G, context, NULL, std::addressof(I->pickVLA), 0, true, 0. 0F, &I->grid, 0, 0, bits32); | |||
} | } | |||
} | } | |||
if (pass == 1) { | if (pass == 1) { | |||
highBitVLA = SceneReadTriplets(G, smp->x, smp->y, smp->w, smp->h, render_b uffer, false); | highBitVLA = SceneReadTriplets(G, smp->x, smp->y, smp->w, smp->h, render_b uffer, false); | |||
nHighBits = VLAGetSize(highBitVLA); | nHighBits = VLAGetSize(highBitVLA); | |||
break; | break; | |||
} | } | |||
lowBitVLA = SceneReadTriplets(G, smp->x, smp->y, smp->w, smp->h, render_buff er, bits32); | lowBitVLA = SceneReadTriplets(G, smp->x, smp->y, smp->w, smp->h, render_buff er, bits32); | |||
nLowBits = VLAGetSize(lowBitVLA); | nLowBits = VLAGetSize(lowBitVLA); | |||
if (bits32 || I->pickVLA[0].src.index < (1 << 12)) { | if (bits32 || I->pickVLA.begin()->src.index < (1 << 12)) { | |||
// no need for a second pass | // no need for a second pass | |||
bits32 = true; // continue like with 32bit picking | bits32 = true; // continue like with 32bit picking | |||
break; | break; | |||
} | } | |||
} | } | |||
if(I->grid.active) | if(I->grid.active) | |||
GridSetGLViewport(&I->grid, -1); | GridSetGLViewport(&I->grid, -1); | |||
/* need to scissor this */ | /* need to scissor this */ | |||
skipping to change at line 464 | skipping to change at line 464 | |||
low = 0; | low = 0; | |||
high = 0; | high = 0; | |||
while((low < nLowBits) && (bits32 || high < nHighBits)) { | while((low < nLowBits) && (bits32 || high < nHighBits)) { | |||
if(bits32 || lowBitVLA[low + 1] == highBitVLA[high + 1]) { | if(bits32 || lowBitVLA[low + 1] == highBitVLA[high + 1]) { | |||
if (bits32){ | if (bits32){ | |||
// 32bit picking | // 32bit picking | |||
index = lowBitVLA[low]; | index = lowBitVLA[low]; | |||
} else { | } else { | |||
index = lowBitVLA[low] + (highBitVLA[high] << 12); | index = lowBitVLA[low] + (highBitVLA[high] << 12); | |||
} | } | |||
if(index && (index <= I->pickVLA[0].src.index)) { | if(index && (index <= I->pickVLA.begin()->src.index)) { | |||
pik = I->pickVLA + index; /* just using as a tmp */ | pik = I->pickVLA.data() + index; /* just using as a tmp */ | |||
if((pik->src.index != lastIndex) || (pik->context.object != lastPtr)) { | if((pik->src.index != lastIndex) || (pik->context.object != lastPtr)) { | |||
if(((CObject *) pik->context.object)->type == cObjectMolecule) { | if(((CObject *) pik->context.object)->type == cObjectMolecule) { | |||
nPick++; /* start from 1 */ | nPick++; /* start from 1 */ | |||
VLACheck(smp->picked, Picking, nPick); | VLACheck(smp->picked, Picking, nPick); | |||
smp->picked[nPick] = *pik; /* return atom/object info -- will be redundant */ | smp->picked[nPick] = *pik; /* return atom/object info -- will be redundant */ | |||
} | } | |||
lastIndex = pik->src.index; | lastIndex = pik->src.index; | |||
lastPtr = pik->context.object; | lastPtr = pik->context.object; | |||
} | } | |||
} | } | |||
skipping to change at line 513 | skipping to change at line 513 | |||
render_buffer = G->DRAW_BUFFER0; | render_buffer = G->DRAW_BUFFER0; | |||
} | } | |||
SceneSetupGLPicking(G); | SceneSetupGLPicking(G); | |||
if (!stereo_double_pump_mono){ | if (!stereo_double_pump_mono){ | |||
switch (stereo_mode) { | switch (stereo_mode) { | |||
case cStereo_crosseye: | case cStereo_crosseye: | |||
case cStereo_walleye: | case cStereo_walleye: | |||
case cStereo_sidebyside: | case cStereo_sidebyside: | |||
glViewport(I->Block->rect.left, I->Block->rect.bottom, I->Width / 2, I->He ight); | glViewport(I->rect.left, I->rect.bottom, I->Width / 2, I->Height); | |||
break; | break; | |||
case cStereo_geowall: | case cStereo_geowall: | |||
*click_side = OrthoGetWrapClickSide(G); | *click_side = OrthoGetWrapClickSide(G); | |||
break; | break; | |||
} | } | |||
} | } | |||
#ifndef PURE_OPENGL_ES_2 | #ifndef PURE_OPENGL_ES_2 | |||
glPushMatrix(); /* 1 */ | glPushMatrix(); /* 1 */ | |||
#endif | #endif | |||
End of changes. 15 change blocks. | ||||
20 lines changed or deleted | 20 lines changed or added |