mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
vector: avoid adding too close points
Rendering a very thick arc caused some glitches. This change should mitigate this issue.
This commit is contained in:
parent
6f7b1a81d7
commit
fa942c824f
@ -31,6 +31,13 @@ const (
|
||||
CounterClockwise
|
||||
)
|
||||
|
||||
func abs(x float32) float32 {
|
||||
if x < 0 {
|
||||
return -x
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
type point struct {
|
||||
x float32
|
||||
y float32
|
||||
@ -63,9 +70,13 @@ func (s *subpath) appendPoint(pt point) {
|
||||
if s.closed {
|
||||
panic("vector: a closed subpathment cannot append a new point")
|
||||
}
|
||||
if s.lastPoint() == pt {
|
||||
|
||||
// Do not add a too close point to the last point.
|
||||
// This can cause unexpected rendering results.
|
||||
if lp := s.lastPoint(); abs(lp.x-pt.x) < 1e-2 && abs(lp.y-pt.y) < 1e-2 {
|
||||
return
|
||||
}
|
||||
|
||||
s.points = append(s.points, pt)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user