Skip to content

Commit bce63b4

Browse files
committed
GPU Display: Add option to rotate model instaed of camera
1 parent b16ec19 commit bce63b4

6 files changed

Lines changed: 51 additions & 15 deletions

File tree

GPU/GPUTracking/display/GPUDisplay.cxx

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ void GPUDisplay::ReSizeGLScene(int width, int height, bool init)
590590
if (init) {
591591
mResetScene = 1;
592592
mViewMatrix = MY_HMM_IDENTITY;
593+
mModelMatrix = MY_HMM_IDENTITY;
593594
}
594595
}
595596

@@ -1350,6 +1351,8 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
13501351
mBackend->mMouseWheel = 0;
13511352
bool lookOrigin = mCamLookOrigin ^ mBackend->mKeys[mBackend->KEY_ALT];
13521353
bool yUp = mCamYUp ^ mBackend->mKeys[mBackend->KEY_CTRL] ^ lookOrigin;
1354+
bool rotateModel = mBackend->mKeys[mBackend->KEY_RCTRL] || mBackend->mKeys[mBackend->KEY_RALT];
1355+
bool rotateModelTPC = mBackend->mKeys[mBackend->KEY_RALT];
13531356

13541357
// Calculate rotation / translation scaling factors
13551358
float scalefactor = mBackend->mKeys[mBackend->KEY_SHIFT] ? 0.2 : 1.0;
@@ -1465,6 +1468,8 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
14651468
}
14661469
} else if (mResetScene) {
14671470
nextViewMatrix = nextViewMatrix * HMM_Translate({0, 0, param().par.ContinuousTracking ? (-mMaxClusterZ / GL_SCALE_FACTOR - 8) : -8});
1471+
mViewMatrix = MY_HMM_IDENTITY;
1472+
mModelMatrix = MY_HMM_IDENTITY;
14681473

14691474
mCfg.pointSize = 2.0;
14701475
mCfg.drawSlice = -1;
@@ -1548,22 +1553,37 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
15481553
nextViewMatrix = nextViewMatrix * HMM_LookAt({mXYZ[0], mXYZ[1], mXYZ[2]}, {0, 0, 0}, {0, 1, 0});
15491554
} else {
15501555
nextViewMatrix = nextViewMatrix * HMM_Translate({moveX, moveY, moveZ});
1551-
if (rotYaw != 0.f) {
1552-
nextViewMatrix = nextViewMatrix * HMM_Rotate(rotYaw, {0, 1, 0});
1553-
}
1554-
if (rotPitch != 0.f) {
1555-
nextViewMatrix = nextViewMatrix * HMM_Rotate(rotPitch, {1, 0, 0});
1556-
}
1557-
if (!yUp && rotRoll != 0.f) {
1558-
nextViewMatrix = nextViewMatrix * HMM_Rotate(rotRoll, {0, 0, 1});
1556+
if (!rotateModel) {
1557+
if (rotYaw != 0.f) {
1558+
nextViewMatrix = nextViewMatrix * HMM_Rotate(rotYaw, {0, 1, 0});
1559+
}
1560+
if (rotPitch != 0.f) {
1561+
nextViewMatrix = nextViewMatrix * HMM_Rotate(rotPitch, {1, 0, 0});
1562+
}
1563+
if (!yUp && rotRoll != 0.f) {
1564+
nextViewMatrix = nextViewMatrix * HMM_Rotate(rotRoll, {0, 0, 1});
1565+
}
15591566
}
1560-
15611567
nextViewMatrix = nextViewMatrix * mViewMatrix; // Apply previous translation / rotation
1562-
15631568
if (yUp) {
15641569
calcXYZ(&nextViewMatrix.Elements[0][0]);
15651570
nextViewMatrix = HMM_Rotate(mAngle[2] * 180.f / M_PI, {0, 0, 1}) * nextViewMatrix;
15661571
}
1572+
if (rotateModel) {
1573+
if (rotYaw != 0.f) {
1574+
mModelMatrix = HMM_Rotate(rotYaw, {nextViewMatrix.Elements[0][1], nextViewMatrix.Elements[1][1], nextViewMatrix.Elements[2][1]}) * mModelMatrix;
1575+
}
1576+
if (rotPitch != 0.f) {
1577+
mModelMatrix = HMM_Rotate(rotPitch, {nextViewMatrix.Elements[0][0], nextViewMatrix.Elements[1][0], nextViewMatrix.Elements[2][0]}) * mModelMatrix;
1578+
}
1579+
if (rotRoll != 0.f) {
1580+
if (rotateModelTPC) {
1581+
mModelMatrix = HMM_Rotate(-rotRoll, {0, 0, 1}) * mModelMatrix;
1582+
} else {
1583+
mModelMatrix = HMM_Rotate(-rotRoll, {nextViewMatrix.Elements[0][2], nextViewMatrix.Elements[1][2], nextViewMatrix.Elements[2][2]}) * mModelMatrix;
1584+
}
1585+
}
1586+
}
15671587
}
15681588

15691589
// Graphichs Options
@@ -1835,6 +1855,7 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
18351855
{
18361856
const float zFar = ((param().par.ContinuousTracking ? (mMaxClusterZ / GL_SCALE_FACTOR) : 8.f) + 50.f) * 2.f;
18371857
const hmm_mat4 proj = HMM_Perspective(mFOV, (GLfloat)mScreenwidth / (GLfloat)mScreenheight, 0.1f, zFar);
1858+
nextViewMatrix = nextViewMatrix * mModelMatrix;
18381859
#ifndef GPUCA_DISPLAY_OPENGL_CORE
18391860
CHKERR(glMatrixMode(GL_PROJECTION));
18401861
CHKERR(glLoadMatrixf(&proj.Elements[0][0]));

GPU/GPUTracking/display/GPUDisplay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class GPUDisplay
307307
bool mSeparateGlobalTracks = 0;
308308
bool mPropagateLoopers = 0;
309309

310-
hmm_mat4 mViewMatrix;
310+
hmm_mat4 mViewMatrix, mModelMatrix;
311311
float* const mViewMatrixP = &mViewMatrix.Elements[0][0];
312312
float mXYZ[3];
313313
float mAngle[3];

GPU/GPUTracking/display/GPUDisplayBackend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ class GPUDisplayBackend
6464
static constexpr int KEY_SPACE = 7;
6565
static constexpr int KEY_SHIFT = 8;
6666
static constexpr int KEY_ALT = 9;
67+
static constexpr int KEY_RALT = 29;
6768
static constexpr int KEY_CTRL = 10;
69+
static constexpr int KEY_RCTRL = 28;
6870
static constexpr int KEY_F1 = 11;
6971
static constexpr int KEY_F2 = 12;
7072
static constexpr int KEY_F3 = 26;

GPU/GPUTracking/display/GPUDisplayBackendGlfw.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,18 @@ int GPUDisplayBackendGlfw::GetKey(int key)
5454
if (key == GLFW_KEY_LEFT_SHIFT || key == GLFW_KEY_RIGHT_SHIFT) {
5555
return (KEY_SHIFT);
5656
}
57-
if (key == GLFW_KEY_LEFT_ALT || key == GLFW_KEY_RIGHT_ALT) {
57+
if (key == GLFW_KEY_LEFT_ALT) {
5858
return (KEY_ALT);
5959
}
60-
if (key == GLFW_KEY_LEFT_CONTROL || key == GLFW_KEY_RIGHT_CONTROL) {
60+
if (key == GLFW_KEY_RIGHT_ALT) {
61+
return (KEY_RALT);
62+
}
63+
if (key == GLFW_KEY_LEFT_CONTROL) {
6164
return (KEY_CTRL);
6265
}
66+
if (key == GLFW_KEY_RIGHT_CONTROL) {
67+
return (KEY_RCTRL);
68+
}
6369
if (key == GLFW_KEY_UP) {
6470
return (KEY_UP);
6571
}

GPU/GPUTracking/display/GPUDisplayBackendX11.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ int GPUDisplayBackendX11::GetKey(int key)
3636
if (key == 65505 || key == 65506) {
3737
return (KEY_SHIFT);
3838
}
39-
if (key == 65513 || key == 65027 || key == 65511) {
39+
if (key == 65513 || key == 65511) {
4040
return (KEY_ALT);
4141
}
42-
if (key == 65507 || key == 65508) {
42+
if (key == 65027) {
43+
return (KEY_RALT);
44+
}
45+
if (key == 65507) {
4346
return (KEY_CTRL);
4447
}
48+
if (key == 65508) {
49+
return (KEY_RCTRL);
50+
}
4551
if (key == 65362) {
4652
return (KEY_UP);
4753
}

GPU/GPUTracking/display/GPUDisplayKeys.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const char* HelpText[] = {
5757
"[MOUSE 1+2] Zoom / Rotate",
5858
"[SHIFT] Slow Zoom / Move / Rotate",
5959
"[ALT] / [CTRL] / [m] Focus camera on origin / orient y-axis upwards (combine with [SHIFT] to lock) / Cycle through modes",
60+
"[RCTRL] / [RALT] Rotate model instead of camera / rotate TPC around beamline",
6061
"[1] ... [8] / [N] Enable display of clusters, preseeds, seeds, starthits, tracklets, tracks, global tracks, merged tracks / Show assigned clusters in colors"
6162
"[F1] / [F2] Enable / disable drawing of TPC / TRD"
6263
// FREE: none

0 commit comments

Comments
 (0)