@@ -409,10 +409,6 @@ class CSkyboxView : public CRendering3dView
409409 void Enable3dSkyboxFog ( void );
410410 void DrawInternal ( view_id_t iSkyBoxViewID, bool bInvokePreAndPostRender, ITexture *pRenderTarget, ITexture *pDepthTarget );
411411
412- #ifdef MAPBASE
413- void CalculateSkyAngles ( const QAngle &angAngles );
414- #endif
415-
416412 sky3dparams_t * PreRender3dSkyboxWorld ( SkyboxVisibility_t nSkyboxVisible );
417413
418414 sky3dparams_t *m_pSky3dParams;
@@ -5400,21 +5396,33 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
54005396 // Re-use the x coordinate to determine if we shuld do this with angles
54015397 if (m_pSky3dParams->angles .GetX () != 0 )
54025398 {
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 );
54045408 }
5405-
5406- VectorAdd ( origin, m_pSky3dParams->skycamera ->GetAbsOrigin (), origin );
54075409 }
54085410 else
54095411 {
54105412 if (m_pSky3dParams->angles .GetX () != 0 ||
54115413 m_pSky3dParams->angles .GetY () != 0 ||
54125414 m_pSky3dParams->angles .GetZ () != 0 )
54135415 {
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 );
54155425 }
5416-
5417- VectorAdd ( origin, m_pSky3dParams->origin , origin );
54185426 }
54195427#else
54205428 VectorAdd ( origin, m_pSky3dParams->origin , origin );
@@ -5531,55 +5539,6 @@ void CSkyboxView::DrawInternal( view_id_t iSkyBoxViewID, bool bInvokePreAndPostR
55315539#endif
55325540}
55335541
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-
55835542// -----------------------------------------------------------------------------
55845543//
55855544// -----------------------------------------------------------------------------
0 commit comments