@@ -701,6 +701,38 @@ TEX COORDS
701701====================================================================
702702*/
703703
704+ static inline void Mat3x2MultiplyScale ( matrix_t m, const float x, const float y ) {
705+ m[0 ] *= x;
706+ m[4 ] *= y;
707+ m[1 ] *= x;
708+ m[5 ] *= y;
709+ }
710+
711+ static inline void Mat3x2MultiplyTranslation ( matrix_t m, const float x, const float y ) {
712+ m[12 ] += m[0 ] * x + m[4 ] * y;
713+ m[13 ] += m[1 ] * x + m[5 ] * y;
714+ }
715+
716+ static inline void Mat3x2MultiplyZRotation ( matrix_t m, const float degrees ) {
717+ float angle = DEG2RAD ( degrees );
718+ float s = sinf ( angle );
719+ float c = cosf ( angle );
720+
721+ const float tmp[] = { m[0 ], m[1 ], m[4 ], m[5 ] };
722+ m[0 ] = tmp[0 ] * c + tmp[2 ] * s;
723+ m[1 ] = tmp[1 ] * c + tmp[3 ] * s;
724+ m[4 ] = tmp[0 ] * -s + tmp[2 ] * c;
725+ m[5 ] = tmp[1 ] * -s + tmp[3 ] * c;
726+ }
727+
728+ static inline void Mat3x2MultiplyShear ( matrix_t m, const float x, const float y ) {
729+ const float tmp[] = { m[0 ], m[1 ] };
730+ m[0 ] += m[4 ] * y;
731+ m[1 ] += m[5 ] * y;
732+ m[4 ] += tmp[0 ] * x;
733+ m[5 ] += tmp[1 ] * x;
734+ }
735+
704736static inline void ComputeTextureWrapModifer ( const matrix_t matrix, const vec2_t scroll, vec2_t modifier ) {
705737 const float xDiv = ( matrix[0 ] * scroll[0 ] + matrix[4 ] * scroll[1 ] );
706738 const float yDiv = ( matrix[1 ] * scroll[0 ] + matrix[5 ] * scroll[1 ] );
@@ -739,15 +771,15 @@ void RB_CalcTexMatrix( const textureBundle_t *bundle, matrix_t matrix )
739771 float x = ( 1 .0f / 4 .0f );
740772 float y = ( wf->phase + backEnd.refdef .floatTime * wf->frequency );
741773
742- MatrixMultiplyScale ( matrix, 1 .0f + ( wf->amplitude * sinf ( y ) + wf->base ) * x,
743- 1 .0f + ( wf->amplitude * sinf ( y + 0 .25f ) + wf->base ) * x, 0.0 );
774+ Mat3x2MultiplyScale ( matrix, 1 .0f + ( wf->amplitude * sinf ( y ) + wf->base ) * x,
775+ 1 .0f + ( wf->amplitude * sinf ( y + 0 .25f ) + wf->base ) * x );
744776 break ;
745777 }
746778
747779 case texMod_t::TMOD_ENTITY_TRANSLATE:
748780 {
749- float x = backEnd.currentEntity ->e .shaderTexCoord [ 0 ] * backEnd. refdef . floatTime ;
750- float y = backEnd.currentEntity ->e .shaderTexCoord [ 1 ] * backEnd. refdef . floatTime ;
781+ float x = backEnd.currentEntity ->e .shaderTexCoord [ 0 ];
782+ float y = backEnd.currentEntity ->e .shaderTexCoord [ 1 ];
751783
752784 // clamp so coordinates don't continuously get larger, causing problems
753785 // with hardware limits
@@ -777,17 +809,17 @@ void RB_CalcTexMatrix( const textureBundle_t *bundle, matrix_t matrix )
777809 float x = texMod->scale [ 0 ];
778810 float y = texMod->scale [ 1 ];
779811
780- MatrixMultiplyScale ( matrix, x, y, 0.0 );
812+ Mat3x2MultiplyScale ( matrix, x, y );
781813 break ;
782814 }
783815
784816 case texMod_t::TMOD_STRETCH:
785817 {
786818 float p = 1 .0f / RB_EvalWaveForm ( &texMod->wave );
787819
788- MatrixMultiplyTranslation ( matrix, 0.5 , 0.5 , 0.0 );
789- MatrixMultiplyScale ( matrix, p, p, 0.0 );
790- MatrixMultiplyTranslation ( matrix, -0.5 , -0.5 , 0.0 );
820+ Mat3x2MultiplyTranslation ( matrix, 0.5 , 0.5 );
821+ Mat3x2MultiplyScale ( matrix, p, p );
822+ Mat3x2MultiplyTranslation ( matrix, -0.5 , -0.5 );
791823 break ;
792824 }
793825
@@ -801,9 +833,9 @@ void RB_CalcTexMatrix( const textureBundle_t *bundle, matrix_t matrix )
801833 {
802834 float x = -texMod->rotateSpeed * backEnd.refdef .floatTime ;
803835
804- MatrixMultiplyTranslation ( matrix, 0.5 , 0.5 , 0.0 );
805- MatrixMultiplyZRotation ( matrix, x );
806- MatrixMultiplyTranslation ( matrix, -0.5 , -0.5 , 0.0 );
836+ Mat3x2MultiplyTranslation ( matrix, 0.5 , 0.5 );
837+ Mat3x2MultiplyZRotation ( matrix, x );
838+ Mat3x2MultiplyTranslation ( matrix, -0.5 , -0.5 );
807839 break ;
808840 }
809841
@@ -828,7 +860,7 @@ void RB_CalcTexMatrix( const textureBundle_t *bundle, matrix_t matrix )
828860 float x = RB_EvalExpression ( &texMod->sExp , 0 );
829861 float y = RB_EvalExpression ( &texMod->tExp , 0 );
830862
831- MatrixMultiplyScale ( matrix, x, y, 0.0 );
863+ Mat3x2MultiplyScale ( matrix, x, y );
832864 break ;
833865 }
834866
@@ -837,30 +869,30 @@ void RB_CalcTexMatrix( const textureBundle_t *bundle, matrix_t matrix )
837869 float x = RB_EvalExpression ( &texMod->sExp , 0 );
838870 float y = RB_EvalExpression ( &texMod->tExp , 0 );
839871
840- MatrixMultiplyTranslation ( matrix, 0.5 , 0.5 , 0.0 );
841- MatrixMultiplyScale ( matrix, x, y, 0.0 );
842- MatrixMultiplyTranslation ( matrix, -0.5 , -0.5 , 0.0 );
872+ Mat3x2MultiplyTranslation ( matrix, 0.5 , 0.5 );
873+ Mat3x2MultiplyScale ( matrix, x, y );
874+ Mat3x2MultiplyTranslation ( matrix, -0.5 , -0.5 );
843875 break ;
844876 }
845877
846878 case texMod_t::TMOD_SHEAR:
847879 {
848- float x = RB_EvalExpression ( &texMod->sExp , 0 );
849- float y = RB_EvalExpression ( &texMod->tExp , 0 );
880+ const float x = RB_EvalExpression ( &texMod->sExp , 0 );
881+ const float y = RB_EvalExpression ( &texMod->tExp , 0 );
850882
851- MatrixMultiplyTranslation ( matrix, 0.5 , 0.5 , 0.0 );
852- MatrixMultiplyShear ( matrix, x, y );
853- MatrixMultiplyTranslation ( matrix, -0.5 , -0.5 , 0.0 );
883+ Mat3x2MultiplyTranslation ( matrix, 0.5 , 0.5 );
884+ Mat3x2MultiplyShear ( matrix, x, y );
885+ Mat3x2MultiplyTranslation ( matrix, -0.5 , -0.5 );
854886 break ;
855887 }
856888
857889 case texMod_t::TMOD_ROTATE2:
858890 {
859891 float x = RB_EvalExpression ( &texMod->rExp , 0 );
860892
861- MatrixMultiplyTranslation ( matrix, 0.5 , 0.5 , 0.0 );
862- MatrixMultiplyZRotation ( matrix, x );
863- MatrixMultiplyTranslation ( matrix, -0.5 , -0.5 , 0.0 );
893+ Mat3x2MultiplyTranslation ( matrix, 0.5 , 0.5 );
894+ Mat3x2MultiplyZRotation ( matrix, x );
895+ Mat3x2MultiplyTranslation ( matrix, -0.5 , -0.5 );
864896 break ;
865897 }
866898
0 commit comments