mirror of
https://github.com/schrodinger/pymol-open-source.git
synced 2026-06-03 19:54:24 +08:00
Allow atom selection via VR controllers (#399)
This commit is contained in:
committed by
GitHub
parent
17c6cbd96d
commit
c208c62c21
@@ -37,6 +37,7 @@ SOFTWARE.
|
||||
// system headers
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include "os_std.h"
|
||||
#include "os_gl.h"
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ SOFTWARE.
|
||||
#include "Feedback.h"
|
||||
#include "Matrix.h"
|
||||
#include "Ortho.h"
|
||||
#include "Scene.h"
|
||||
#include "SceneMouse.h"
|
||||
#include "ButMode.h"
|
||||
|
||||
// local headers
|
||||
#include "OpenVRUtils.h"
|
||||
@@ -727,11 +730,12 @@ void OpenVRGetPickingProjection(PyMOLGlobals * G, float near_plane, float far_p
|
||||
|
||||
// take avarage projection params from eyes
|
||||
float left, right, top, bottom;
|
||||
float vertical_offset = 0.45;
|
||||
CEye &LEye = I->Left, &REye = I->Right;
|
||||
left = (LEye.Left + REye.Left) * 0.5f;
|
||||
right = (LEye.Right + REye.Right) * 0.5f;
|
||||
top = (LEye.Top + REye.Top) * 0.5f;
|
||||
bottom = (LEye.Bottom + REye.Bottom) * 0.5f;
|
||||
top = (LEye.Top + REye.Top + vertical_offset) * 0.5f;
|
||||
bottom = (LEye.Bottom + REye.Bottom + vertical_offset) * 0.5f;
|
||||
OpenVRGetProjection(left, right, top, bottom, near_plane, far_plane, matrix);
|
||||
return;
|
||||
}
|
||||
@@ -1031,7 +1035,6 @@ void HandleLaser(PyMOLGlobals * G, int centerX, int centerY, CMouseEvent const&
|
||||
}
|
||||
|
||||
bool menuHit = false;
|
||||
|
||||
if (laserSource) {
|
||||
I->Picker.Activate(laserSource->GetLaserDeviceIndex(), centerX, centerY);
|
||||
|
||||
@@ -1054,14 +1057,38 @@ void HandleLaser(PyMOLGlobals * G, int centerX, int centerY, CMouseEvent const&
|
||||
}
|
||||
}
|
||||
|
||||
// laser missed
|
||||
float missedColor[4] = {1.0f, 1.0f, 0.0f, 0.5f};
|
||||
if (!laserTarget) {
|
||||
laserTarget = &I->Picker;
|
||||
if (!SettingGetGlobal_b(G, cSetting_openvr_cut_laser)) {
|
||||
laserSource->SetLaserLength(0.0f);
|
||||
|
||||
CScene *Scene = G->Scene;
|
||||
if (SettingGetGlobal_b(G, cSetting_openvr_cut_laser) && OpenVRIsScenePickerActive(G)) {
|
||||
float atomWorldPos[3];
|
||||
ScenePickAtomInWorld(G, centerX, centerY, atomWorldPos);
|
||||
OpenVRUpdateScenePickerLength(G, atomWorldPos);
|
||||
}
|
||||
|
||||
// check if we hit an atom
|
||||
if (Scene->LastPicked.context.object != NULL) {
|
||||
float atomHitColor[4] = {1.0f, 0.0f, 1.0f, 0.5f};
|
||||
laserSource->SetLaserColor(atomHitColor);
|
||||
|
||||
if(Actions->Action1->WasPressed()) {
|
||||
if(ButModeTranslate(G, P_GLUT_SINGLE_LEFT, 0) == cButModePickAtom) {
|
||||
// select atom
|
||||
SceneClickObject(G, Scene->LastPicked.context.object, Scene->LastPicked, cButModeSeleToggle, "");
|
||||
} else {
|
||||
// select residue
|
||||
SceneClickObject(G, Scene->LastPicked.context.object, Scene->LastPicked, cButModeSeleToggle, "byres");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// laser missed
|
||||
float missedColor[4] = {1.0f, 1.0f, 0.0f, 0.5f};
|
||||
if (!SettingGetGlobal_b(G, cSetting_openvr_cut_laser)) {
|
||||
laserSource->SetLaserLength(0.0f);
|
||||
}
|
||||
laserSource->SetLaserColor(missedColor);
|
||||
}
|
||||
laserSource->SetLaserColor(missedColor);
|
||||
}
|
||||
|
||||
if (mouseEvent.deviceIndex == laserSource->GetLaserDeviceIndex()) {
|
||||
|
||||
Reference in New Issue
Block a user