|
|
@ -41,22 +41,31 @@ All rights reserved. |
|
|
|
|
|
|
|
|
|
|
|
INCLUDE_game |
|
|
|
INCLUDE_game |
|
|
|
|
|
|
|
|
|
|
|
Arc::Arc(const vf2d pos,const float pointingAngle,const float sweepAngle) |
|
|
|
Arc::Arc(const vf2d pos,const float radius,const float pointingAngle,const float sweepAngle) |
|
|
|
:pos(pos),pointingAngle(pointingAngle),sweepAngle(sweepAngle){ |
|
|
|
:pos(pos),radius(radius),pointingAngle(pointingAngle),sweepAngle(sweepAngle){ |
|
|
|
|
|
|
|
if(sweepAngle<0.f)ERR(std::format("WARNING! Sweep angle must be greater than or equal to 0! Provided Sweep Angle: {}",sweepAngle)); |
|
|
|
//Use cut-off point between two angles
|
|
|
|
//Use cut-off point between two angles
|
|
|
|
poly.pos.emplace_back(vf2d{}); //Always add 0,0
|
|
|
|
poly.pos.emplace_back(pos); //Always add 0,0
|
|
|
|
int startInd{int(std::fmod(util::radToDeg(pointingAngle-sweepAngle)/4,90))}; |
|
|
|
float smallestAng{util::radToDeg(pointingAngle-sweepAngle)+90}; |
|
|
|
int endInd{int(std::fmod(util::radToDeg(pointingAngle+sweepAngle)/4,90))}; |
|
|
|
float largestAng{util::radToDeg(pointingAngle+sweepAngle)+90}; |
|
|
|
if(startInd>endInd)std::swap(startInd,endInd); |
|
|
|
while(smallestAng<0.f)smallestAng+=360; |
|
|
|
for(int i=startInd;i<endInd;i++){ |
|
|
|
while(largestAng<0.f)largestAng+=360; |
|
|
|
poly.pos.emplace_back(game->circleCooldownPoints[i]); |
|
|
|
int startInd{int(std::fmod(smallestAng/4+1,90))}; |
|
|
|
|
|
|
|
int endInd{int(std::fmod(largestAng/4+1,90))}; |
|
|
|
|
|
|
|
if(startInd>endInd){ |
|
|
|
|
|
|
|
startInd=(startInd+3)%90; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
endInd=(endInd+3)%90; |
|
|
|
} |
|
|
|
} |
|
|
|
poly.pos.emplace_back(vf2d{}); //Connect back to itself.
|
|
|
|
for(int i=startInd;i!=endInd;i=(i+1)%game->circleCooldownPoints.size()){ |
|
|
|
|
|
|
|
poly.pos.emplace_back(pos+game->circleCooldownPoints[i]*radius); |
|
|
|
} |
|
|
|
} |
|
|
|
void Arc::Draw(AiL*game,const vf2d pos,const float pointingAngle,const float sweepAngle,const Pixel col){ |
|
|
|
poly.pos.emplace_back(pos); //Connect back to itself.
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void Arc::Draw(AiL*game,const Pixel col){ |
|
|
|
game->SetDecalStructure(DecalStructure::FAN); |
|
|
|
game->SetDecalStructure(DecalStructure::FAN); |
|
|
|
game->view.DrawPolygonDecal(nullptr,poly.pos,poly.pos,col); |
|
|
|
game->view.DrawPolygonDecal(nullptr,poly.pos,poly.pos,col); |
|
|
|
} |
|
|
|
} |
|
|
|
const bool Arc::overlaps(const vf2d checkPos)const{ |
|
|
|
const bool Arc::overlaps(const vf2d checkPos)const{ |
|
|
|
|
|
|
|
return geom2d::overlaps(checkPos,poly); |
|
|
|
} |
|
|
|
} |