static bool IsQuadrangle(cv::Point2f p1, cv::Point2f p2, cv::Point2f p3, cv::Point2f p4) { cv::Point2d pi1((int)p1.x, (int)p1.y); cv::Point2d pi2((int)p2.x, (int)p2.y); cv::Point2d pi3((int)p3.x, (int)p3.y); cv::Point2d pi4((int)p4.x, (int)p4.y); return !(IsOverlapped(pi1, pi2) || IsOverlapped(pi1, pi3) || IsOverlapped(pi1, pi4) || IsOverlapped(pi2, pi3) || IsOverlapped(pi2, pi4) || IsOverlapped(pi3, pi4) || IsLine(pi1, pi2, pi3) || IsLine(pi1, pi2, pi4) || IsLine(pi2, pi3, pi4)); }
void Ork::Process() { Enemy::Process(); int posx = pixel_x() / 32; int posy = pixel_y() / 32; auto n = (*GetMap())[posx][posy]; if (n != nullptr && n->IsLine()) { n->Hit(1); } }
void GBlend::ReadPathStart1() { if ( ILength1==0 ) Type1 = PT_END ; else if ( IsLine(Type1=*ITypes1) ) { ITypes1++ ; P13 = *IPoints1++ ; ILength1-- ; } else /* Curve */ { ITypes1+=3 ; P11 = *IPoints1++ ; P12 = *IPoints1++ ; P13 = *IPoints1++ ; ILength1-=3 ; } }
void GBlend::ReadPathStart0() { if ( ILength0==0 ) Type0 = PT_END ; else if ( IsLine(Type0=*ITypes0) ) { ITypes0++ ; P03 = *IPoints0++ ; ILength0-- ; } else /* Curve */ { ITypes0+=3 ; P01 = *IPoints0++ ; P02 = *IPoints0++ ; P03 = *IPoints0++ ; ILength0-=3 ; } }
BOOL GBlend::CalcPathLengths( PPOINT Points, PBYTE Types, UINT32 Length, PUINT32 Buffer, UINT32 BufferLength, PUINT32 &BufferEnd ) { UINT32 TotalLength = 0 ; BufferEnd = Buffer ; UINT32 i = 1 ; while ( i<Length ) { if ( IsLine(Types[i]) ) { *BufferEnd = length( Points[i-1],Points[i] ) ; i++ ; } else /* Curve */ { *BufferEnd = BezierLength( Points[i-1],Points[i],Points[i+1],Points[i+2] ) ; i+=3 ; } TotalLength += *BufferEnd++ ; } PUINT32 P = Buffer ; UINT32 Total = 0 ; while ( P<BufferEnd ) { *P = ScaledDiv( *P, TotalLength ) ; Total += *P++ ; } if ( Total != 0x10000000 ) { while ( *(--P)+0x10000000 <= Total ) { } *P -= Total-0x10000000 ; } return TRUE ; }
size_t FuzzyClip( PPOINT IPoints, PBYTE ITypes, size_t ILength, BOOL IsClosed, RECT *InnerRect, RECT *OuterRect, PPOINT pOPoints, PBYTE pOTypes, size_t pOMaxLength ) { IRect = (GRECT*) InnerRect ; ORect = (GRECT*) OuterRect ; OPoints = pOPoints ; OTypes = pOTypes ; OMaxLength = pOMaxLength ; OLength = 0 ; if ( ILength <= 0 ) return 0 ; try { Index = 0 ; while ( Index<ILength ) { OFirstPoint = TRUE ; POINT StartPoint = IPoints[Index++] ; LastSector = GetSector( StartPoint ) ; LastPoint = StartPoint ; while ( Index<ILength && (IsLine(ITypes[Index]) || IsCurve(ITypes[Index])) ) { if ( IsLine(ITypes[Index]) ) { ClipLine( LastPoint,IPoints[Index] ) ; LastPoint = IPoints[Index++] ; } else { ClipCurve( LastPoint,IPoints[Index],IPoints[Index+1],IPoints[Index+2] ) ; LastPoint = IPoints[Index+2] ; Index += 3 ; } } if ( IsClosed || (ITypes[Index-1] & PT_CLOSEFIGURE) ) { ClipLine( LastPoint,StartPoint ) ; if ( !OFirstPoint ) *(OTypes-1) |= PT_CLOSEFIGURE ; } if ( !OFirstPoint && IsMove(*(OTypes-1)) ) { OTypes-- ; OPoints-- ; OLength-- ; } } } catch ( INT32 ) { OLength = (size_t)-1 ; } return OLength ; }