void Select_RotateAxis( int axis, float deg, bool bPaint, bool bMouse ) { edVec3_c temp; int i, j; vec_t c, s; if ( deg == 0 ) { //Sys_Printf("0 deg\n"); return; } if ( bMouse ) { select_origin = g_pParentWnd->ActiveXY()->RotateOrigin(); } else { Select_GetMid( select_origin ); } select_fliporder = false; if ( deg == 90 ) { for ( i = 0 ; i < 3 ; i++ ) { select_matrix[i].clear(); select_matrix[i][i] = 1; } i = ( axis + 1 ) % 3; j = ( axis + 2 ) % 3; temp = select_matrix[i]; select_matrix[i] = select_matrix[j]; select_matrix[j] = -temp; } else { deg = -deg; if ( deg == -180.0 ) { c = -1; s = 0; } else if ( deg == -270.0 ) { c = 0; s = -1; } else { c = cos( DEG2RAD( deg ) ); s = sin( DEG2RAD( deg ) ); } for ( i = 0 ; i < 3 ; i++ ) { select_matrix[i].clear(); select_matrix[i][i] = 1; } switch ( axis ) { case 0: select_matrix[1][1] = c; select_matrix[1][2] = -s; select_matrix[2][1] = s; select_matrix[2][2] = c; break; case 1: select_matrix[0][0] = c; select_matrix[0][2] = s; select_matrix[2][0] = -s; select_matrix[2][2] = c; break; case 2: select_matrix[0][0] = c; select_matrix[0][1] = -s; select_matrix[1][0] = s; select_matrix[1][1] = c; break; } } if ( g_PrefsDlg.m_bRotateLock ) RotateTextures( axis, deg, select_origin ); Select_ApplyMatrix( !bMouse, true, axis, deg ); if ( bPaint ) Sys_UpdateWindows( W_ALL ); }
void Select_RotateAxis (int axis, float deg, bool bPaint, bool bMouse) { vec3_t temp; int i, j; vec_t c, s; if (deg == 0) { //Sys_Printf("0 deg\n"); return; } if (bMouse) { VectorCopy(g_pParentWnd->ActiveXY()->RotateOrigin(), select_origin); } else { Select_GetMid (select_origin); } select_fliporder = false; if (deg == 90) { for (i=0 ; i<3 ; i++) { VectorCopy (vec3_origin, select_matrix[i]); select_matrix[i][i] = 1; } i = (axis+1)%3; j = (axis+2)%3; VectorCopy (select_matrix[i], temp); VectorCopy (select_matrix[j], select_matrix[i]); VectorSubtract (vec3_origin, temp, select_matrix[j]); } else { deg = -deg; if (deg == -180.0) { c = -1; s = 0; } else if (deg == -270.0) { c = 0; s = -1; } else { c = cos(deg * Q_PI / 180.0); s = sin(deg * Q_PI / 180.0); } for (i=0 ; i<3 ; i++) { VectorCopy (vec3_origin, select_matrix[i]); select_matrix[i][i] = 1; } switch (axis) { case 0: select_matrix[1][1] = c; select_matrix[1][2] = -s; select_matrix[2][1] = s; select_matrix[2][2] = c; break; case 1: select_matrix[0][0] = c; select_matrix[0][2] = s; select_matrix[2][0] = -s; select_matrix[2][2] = c; break; case 2: select_matrix[0][0] = c; select_matrix[0][1] = -s; select_matrix[1][0] = s; select_matrix[1][1] = c; break; } } if (g_PrefsDlg.m_bRotateLock) RotateTextures(axis, deg, select_origin); Select_AplyMatrix(!bMouse); if (bPaint) Sys_UpdateWindows (W_ALL); }