| 132 | } |
| 133 | |
| 134 | void Primitives::drawArc( const Vector2f& p, const Float& radius, Uint32 segmentsCount, |
| 135 | const Float& arcAngle, const Float& arcStartAngle ) { |
| 136 | if ( segmentsCount < 6 ) |
| 137 | segmentsCount = 6; |
| 138 | segmentsCount = segmentsCount > 360 ? 360 : segmentsCount; |
| 139 | |
| 140 | Float angleShift = 360 / static_cast<Float>( segmentsCount ); |
| 141 | Float arcAngleA = arcAngle > 360 ? arcAngle - 360 * std::floor( arcAngle / 360 ) : arcAngle; |
| 142 | auto sBR = GlobalBatchRenderer::instance(); |
| 143 | |
| 144 | sBR->setTexture( NULL ); |
| 145 | |
| 146 | switch ( mFillMode ) { |
| 147 | case DRAW_LINE: { |
| 148 | sBR->setLineWidth( mLineWidth ); |
| 149 | |
| 150 | segmentsCount = Uint32( (Float)segmentsCount * (Float)eeabs( arcAngleA ) / 360 ); |
| 151 | Float startAngle = Math::radians( arcStartAngle ); |
| 152 | Float theta = Math::radians( arcAngleA ) / Float( segmentsCount - 1 ); |
| 153 | Float tangentialFactor = eetan( theta ); |
| 154 | Float radialFactor = eecos( theta ); |
| 155 | Float x = radius * eecos( startAngle ); |
| 156 | Float y = radius * eesin( startAngle ); |
| 157 | |
| 158 | sBR->lineStripBegin(); |
| 159 | sBR->lineStripSetColor( mColor ); |
| 160 | |
| 161 | for ( Uint32 ii = 0; ii < segmentsCount; ii++ ) { |
| 162 | sBR->batchLineStrip( x + p.x, y + p.y ); |
| 163 | |
| 164 | Float tx = -y; |
| 165 | Float ty = x; |
| 166 | |
| 167 | x += tx * tangentialFactor; |
| 168 | y += ty * tangentialFactor; |
| 169 | |
| 170 | x *= radialFactor; |
| 171 | y *= radialFactor; |
| 172 | } |
| 173 | |
| 174 | break; |
| 175 | } |
| 176 | case DRAW_FILL: { |
| 177 | sBR->triangleFanBegin(); |
| 178 | sBR->triangleFanSetColor( mColor ); |
| 179 | |
| 180 | for ( Float i = 0; i < arcAngleA; i += angleShift ) { |
| 181 | Float startAngle = arcStartAngle + i; |
| 182 | |
| 183 | sBR->batchTriangleFan( p.x, p.y, p.x + radius * Math::sinAng( startAngle ), |
| 184 | p.y + radius * Math::cosAng( startAngle ), |
| 185 | p.x + radius * Math::sinAng( startAngle + angleShift ), |
| 186 | p.y + radius * Math::cosAng( startAngle + angleShift ) ); |
| 187 | } |
| 188 | |
| 189 | break; |
| 190 | } |
| 191 | } |
nothing calls this directly
no test coverage detected