123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- #pragma hdrstop
- #include "../idlib/precompiled.h"
- #include "tr_local.h"
- void idScreenRect::Clear() {
- x1 = y1 = 32000;
- x2 = y2 = -32000;
- zmin = 0.0f;
- zmax = 1.0f;
- }
- void idScreenRect::AddPoint( float x, float y ) {
- int ix = idMath::Ftoi( x );
- int iy = idMath::Ftoi( y );
- if ( ix < x1 ) {
- x1 = ix;
- }
- if ( ix > x2 ) {
- x2 = ix;
- }
- if ( iy < y1 ) {
- y1 = iy;
- }
- if ( iy > y2 ) {
- y2 = iy;
- }
- }
- void idScreenRect::Expand() {
- x1--;
- y1--;
- x2++;
- y2++;
- }
- void idScreenRect::Intersect( const idScreenRect &rect ) {
- if ( rect.x1 > x1 ) {
- x1 = rect.x1;
- }
- if ( rect.x2 < x2 ) {
- x2 = rect.x2;
- }
- if ( rect.y1 > y1 ) {
- y1 = rect.y1;
- }
- if ( rect.y2 < y2 ) {
- y2 = rect.y2;
- }
- }
- void idScreenRect::Union( const idScreenRect &rect ) {
- if ( rect.x1 < x1 ) {
- x1 = rect.x1;
- }
- if ( rect.x2 > x2 ) {
- x2 = rect.x2;
- }
- if ( rect.y1 < y1 ) {
- y1 = rect.y1;
- }
- if ( rect.y2 > y2 ) {
- y2 = rect.y2;
- }
- }
- bool idScreenRect::Equals( const idScreenRect &rect ) const {
- return ( x1 == rect.x1 && x2 == rect.x2 && y1 == rect.y1 && y2 == rect.y2 );
- }
- bool idScreenRect::IsEmpty() const {
- return ( x1 > x2 || y1 > y2 );
- }
- void R_ShowColoredScreenRect( const idScreenRect &rect, int colorIndex ) {
- if ( !rect.IsEmpty() ) {
- static idVec4 colors[] = { colorRed, colorGreen, colorBlue, colorYellow, colorMagenta, colorCyan, colorWhite, colorPurple };
- tr.viewDef->renderWorld->DebugScreenRect( colors[colorIndex & 7], rect, tr.viewDef );
- }
- }
|