1616#include " frontend/GPUDisplayInfo.inc"
1717
1818#include " GPUTPCDef.h"
19+ #include " HandMadeMath.h"
1920
2021#include < vector>
2122#include < memory>
@@ -60,6 +61,8 @@ const GPUSettingsProcessing& GPUDisplay::GetProcessingConfig(GPUChainTracking* c
6061
6162GPUDisplay::GPUDisplay (GPUDisplayFrontend* frontend, GPUChainTracking* chain, GPUQA * qa, const GPUParam* param, const GPUCalibObjectsConst* calib, const GPUSettingsDisplay* config, const GPUSettingsProcessing* proc) : GPUDisplayInterface(), mFrontend(frontend), mChain(chain), mConfig(config ? *config : GetConfig(chain)), mProcessingSettings(proc ? *proc : GetProcessingConfig(chain)), mQA(qa)
6263{
64+ mViewMatrix = std::make_unique<hmm_mat4>();
65+ mModelMatrix = std::make_unique<hmm_mat4>();
6366 mParam = param ? param : &mChain ->GetParam ();
6467 mCalib = calib;
6568 mCfgL = mConfig .light ;
@@ -146,8 +149,8 @@ void GPUDisplay::ResizeScene(int32_t width, int32_t height, bool init)
146149
147150 if (init) {
148151 mResetScene = true ;
149- mViewMatrix = MY_HMM_IDENTITY ;
150- mModelMatrix = MY_HMM_IDENTITY ;
152+ * mViewMatrix = MY_HMM_IDENTITY ;
153+ * mModelMatrix = MY_HMM_IDENTITY ;
151154 }
152155}
153156
@@ -251,6 +254,7 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla
251254 if (mCfgL .drawSector != -1 ) {
252255 scalefactor *= 0 .2f ;
253256 }
257+ float * const mViewMatrixP = &mViewMatrix ->Elements [0 ][0 ];
254258 float sqrdist = sqrtf (sqrtf (mViewMatrixP [12 ] * mViewMatrixP [12 ] + mViewMatrixP [13 ] * mViewMatrixP [13 ] + mViewMatrixP [14 ] * mViewMatrixP [14 ]) * GL_SCALE_FACTOR ) * 0 .8f ;
255259 if (sqrdist < 0 .2f ) {
256260 sqrdist = 0 .2f ;
@@ -267,8 +271,8 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla
267271 } else if (mResetScene ) {
268272 const float initialZpos = mCfgH .projectXY ? 16 : (mParam ->par .continuousTracking ? (mMaxClusterZ * GL_SCALE_FACTOR + 8 ) : 8 );
269273 nextViewMatrix = nextViewMatrix * HMM_Translate ({{0 , 0 , -initialZpos}});
270- mViewMatrix = MY_HMM_IDENTITY ;
271- mModelMatrix = MY_HMM_IDENTITY ;
274+ * mViewMatrix = MY_HMM_IDENTITY ;
275+ * mModelMatrix = MY_HMM_IDENTITY ;
272276
273277 mCfgL .pointSize = 2 .0f ;
274278 mCfgL .lineWidth = 1 .4f ;
@@ -367,23 +371,23 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla
367371 nextViewMatrix = nextViewMatrix * HMM_Rotate (rotRoll * mYFactor , {{0 , 0 , 1 }});
368372 }
369373 }
370- nextViewMatrix = nextViewMatrix * mViewMatrix ; // Apply previous translation / rotation
374+ nextViewMatrix = nextViewMatrix * * mViewMatrix ; // Apply previous translation / rotation
371375 if (yUp) {
372376 calcXYZ (&nextViewMatrix.Elements [0 ][0 ]);
373377 nextViewMatrix = HMM_Rotate (mAngle [2 ] * 180 .f / CAMath::Pi (), {{0 , 0 , 1 }}) * nextViewMatrix;
374378 }
375379 if (rotateModel) {
376380 if (rotYaw != 0 .f ) {
377- mModelMatrix = HMM_Rotate (rotYaw, {{nextViewMatrix.Elements [0 ][1 ], nextViewMatrix.Elements [1 ][1 ], nextViewMatrix.Elements [2 ][1 ]}}) * mModelMatrix ;
381+ * mModelMatrix = HMM_Rotate (rotYaw, {{nextViewMatrix.Elements [0 ][1 ], nextViewMatrix.Elements [1 ][1 ], nextViewMatrix.Elements [2 ][1 ]}}) * * mModelMatrix ;
378382 }
379383 if (rotPitch != 0 .f ) {
380- mModelMatrix = HMM_Rotate (rotPitch, {{nextViewMatrix.Elements [0 ][0 ], nextViewMatrix.Elements [1 ][0 ], nextViewMatrix.Elements [2 ][0 ]}}) * mModelMatrix ;
384+ * mModelMatrix = HMM_Rotate (rotPitch, {{nextViewMatrix.Elements [0 ][0 ], nextViewMatrix.Elements [1 ][0 ], nextViewMatrix.Elements [2 ][0 ]}}) * * mModelMatrix ;
381385 }
382386 if (rotRoll != 0 .f ) {
383387 if (rotateModelTPC) {
384- mModelMatrix = HMM_Rotate (-rotRoll, {{0 , 0 , 1 }}) * mModelMatrix ;
388+ * mModelMatrix = HMM_Rotate (-rotRoll, {{0 , 0 , 1 }}) * * mModelMatrix ;
385389 } else {
386- mModelMatrix = HMM_Rotate (-rotRoll, {{nextViewMatrix.Elements [0 ][2 ], nextViewMatrix.Elements [1 ][2 ], nextViewMatrix.Elements [2 ][2 ]}}) * mModelMatrix ;
390+ * mModelMatrix = HMM_Rotate (-rotRoll, {{nextViewMatrix.Elements [0 ][2 ], nextViewMatrix.Elements [1 ][2 ], nextViewMatrix.Elements [2 ][2 ]}}) * * mModelMatrix ;
387391 }
388392 }
389393 }
@@ -414,8 +418,8 @@ void GPUDisplay::DrawGLScene_cameraAndAnimation(float animateTime, float& mixSla
414418
415419 // Store position
416420 if (animateTime < 0 ) {
417- mViewMatrix = nextViewMatrix;
418- calcXYZ (mViewMatrixP );
421+ * mViewMatrix = nextViewMatrix;
422+ calcXYZ (& mViewMatrix -> Elements [ 0 ][ 0 ] );
419423 }
420424
421425 if (mFrontend ->mMouseDn || mFrontend ->mMouseDnR ) {
@@ -659,7 +663,7 @@ void GPUDisplay::DrawGLScene_internal(float animateTime, bool renderToMixBuffer)
659663 }
660664
661665 // Draw Event
662- nextViewMatrix = nextViewMatrix * mModelMatrix ;
666+ nextViewMatrix = nextViewMatrix * * mModelMatrix ;
663667 const float zFar = ((mParam ->par .continuousTracking ? (mMaxClusterZ * GL_SCALE_FACTOR ) : 8 .f ) + 50 .f ) * 2 .f ;
664668 const hmm_mat4 proj = HMM_Perspective (mCfgR .fov , (float )mBackend ->mRenderWidth / (float )mBackend ->mRenderHeight , 0 .1f , zFar);
665669 mBackend ->prepareDraw (proj, nextViewMatrix, doScreenshot || mRequestScreenshot , renderToMixBuffer, mixSlaveImage);
0 commit comments