@@ -409,10 +409,6 @@ class CSkyboxView : public CRendering3dView
409
409
void Enable3dSkyboxFog ( void );
410
410
void DrawInternal ( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget, ITexture *pDepthTarget );
411
411
412
- #ifdef MAPBASE
413
- void CalculateSkyAngles ( const QAngle &angAngles );
414
- #endif
415
-
416
412
sky3dparams_t * PreRender3dSkyboxWorld ( SkyboxVisibility_t nSkyboxVisible );
417
413
418
414
sky3dparams_t *m_pSky3dParams;
@@ -5400,21 +5396,33 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
5400
5396
// Re-use the x coordinate to determine if we shuld do this with angles
5401
5397
if (m_pSky3dParams->angles .GetX () != 0 )
5402
5398
{
5403
- CalculateSkyAngles ( m_pSky3dParams->skycamera ->GetAbsAngles () );
5399
+ const matrix3x4_t &matSky = m_pSky3dParams->skycamera ->EntityToWorldTransform ();
5400
+ matrix3x4_t matView;
5401
+ AngleMatrix ( angles, origin, matView );
5402
+ ConcatTransforms ( matSky, matView, matView );
5403
+ MatrixAngles ( matView, angles, origin );
5404
+ }
5405
+ else
5406
+ {
5407
+ VectorAdd ( origin, m_pSky3dParams->skycamera ->GetAbsOrigin (), origin );
5404
5408
}
5405
-
5406
- VectorAdd ( origin, m_pSky3dParams->skycamera ->GetAbsOrigin (), origin );
5407
5409
}
5408
5410
else
5409
5411
{
5410
5412
if (m_pSky3dParams->angles .GetX () != 0 ||
5411
5413
m_pSky3dParams->angles .GetY () != 0 ||
5412
5414
m_pSky3dParams->angles .GetZ () != 0 )
5413
5415
{
5414
- CalculateSkyAngles ( m_pSky3dParams->angles .Get () );
5416
+ matrix3x4_t matSky, matView;
5417
+ AngleMatrix ( m_pSky3dParams->angles , m_pSky3dParams->origin , matSky );
5418
+ AngleMatrix ( angles, origin, matView );
5419
+ ConcatTransforms ( matSky, matView, matView );
5420
+ MatrixAngles ( matView, angles, origin );
5421
+ }
5422
+ else
5423
+ {
5424
+ VectorAdd ( origin, m_pSky3dParams->origin , origin );
5415
5425
}
5416
-
5417
- VectorAdd ( origin, m_pSky3dParams->origin , origin );
5418
5426
}
5419
5427
#else
5420
5428
VectorAdd ( origin, m_pSky3dParams->origin , origin );
@@ -5531,55 +5539,6 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
5531
5539
#endif
5532
5540
}
5533
5541
5534
- #ifdef MAPBASE
5535
- // -----------------------------------------------------------------------------
5536
- //
5537
- // -----------------------------------------------------------------------------
5538
- void CSkyboxView::CalculateSkyAngles ( const QAngle &angAngles )
5539
- {
5540
- // Unfortunately, it's not as simple as "angles += m_pSky3dParams->angles".
5541
- // This stuff took a long time to figure out. I'm glad I got it working.
5542
-
5543
- // First, create a matrix for the sky's angles.
5544
- matrix3x4_t matSkyAngles;
5545
- AngleMatrix ( angAngles, matSkyAngles );
5546
-
5547
- // The code in between the lines below was mostly lifted from projected texture screenspace code and was a huge lifesaver.
5548
- // The comments are my attempt at explaining the little I understand of what's going on here.
5549
- // ----------------------------------------------------------------------
5550
-
5551
- // These are the vectors that would eventually become our final angle directions.
5552
- Vector vecSkyForward, vecSkyRight, vecSkyUp;
5553
-
5554
- // Get vectors from our original angles.
5555
- Vector vPlayerForward, vPlayerRight, vPlayerUp;
5556
- AngleVectors ( angles, &vPlayerForward, &vPlayerRight, &vPlayerUp );
5557
-
5558
- // Transform them from our sky angles matrix and put the results in those vectors we declared earlier.
5559
- VectorTransform ( vPlayerForward, matSkyAngles, vecSkyForward );
5560
- VectorTransform ( vPlayerRight, matSkyAngles, vecSkyRight );
5561
- VectorTransform ( vPlayerUp, matSkyAngles, vecSkyUp );
5562
-
5563
- // Normalize them.
5564
- VectorNormalize ( vecSkyForward );
5565
- VectorNormalize ( vecSkyRight );
5566
- VectorNormalize ( vecSkyUp );
5567
-
5568
- // Now do a bit of quaternion magic and apply that to our original angles.
5569
- // This works perfectly, so I'm not gonna touch it.
5570
- Quaternion quat;
5571
- BasisToQuaternion ( vecSkyForward, vecSkyRight, vecSkyUp, quat );
5572
- QuaternionAngles ( quat, angles );
5573
-
5574
- // End of code mostly lifted from projected texture screenspace stuff
5575
- // ----------------------------------------------------------------------
5576
-
5577
- // Now just rotate our origin with that matrix.
5578
- // We create a copy of the origin since VectorRotate doesn't want in1 to be the same variable as the destination.
5579
- VectorRotate (Vector (origin), matSkyAngles, origin);
5580
- }
5581
- #endif
5582
-
5583
5542
// -----------------------------------------------------------------------------
5584
5543
//
5585
5544
// -----------------------------------------------------------------------------
0 commit comments