diff options
| author | 2016-05-22 20:06:00 +0200 | |
|---|---|---|
| committer | 2016-05-22 20:54:31 +0200 | |
| commit | 052fd0c608e8a4bb0ed300e4ac95638963127043 (patch) | |
| tree | fbe6e94537cce505778cc2a49443d461070130b0 /src/emu/rendutil.cpp | |
| parent | 92c2bdf9170662274f0c2ca1e3a30357f02ca977 (diff) | |
Moved extension of vector lines to where it belongs (nw)
Diffstat (limited to 'src/emu/rendutil.cpp')
| -rw-r--r-- | src/emu/rendutil.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/emu/rendutil.cpp b/src/emu/rendutil.cpp index fefb23935fd..ee78ad5125d 100644 --- a/src/emu/rendutil.cpp +++ b/src/emu/rendutil.cpp @@ -429,10 +429,9 @@ int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_qu width to four points -------------------------------------------------*/ -void render_line_to_quad(const render_bounds *bounds, float width, render_bounds *bounds0, render_bounds *bounds1) +void render_line_to_quad(const render_bounds *bounds, float width, float length_extension, render_bounds *bounds0, render_bounds *bounds1) { render_bounds modbounds = *bounds; - float unitx, unity; /* High-level logic -- due to math optimizations, this info is lost below. @@ -480,27 +479,46 @@ void render_line_to_quad(const render_bounds *bounds, float width, render_bounds */ /* we only care about the half-width */ - width *= 0.5f; + float half_width = width * 0.5f; /* compute a vector from point 0 to point 1 */ - unitx = modbounds.x1 - modbounds.x0; - unity = modbounds.y1 - modbounds.y0; + float unitx = modbounds.x1 - modbounds.x0; + float unity = modbounds.y1 - modbounds.y0; /* points just use a +1/+1 unit vector; this gives a nice diamond pattern */ if (unitx == 0 && unity == 0) { - unitx = unity = 0.70710678f * width; - modbounds.x0 -= 0.5f * unitx; - modbounds.y0 -= 0.5f * unity; - modbounds.x1 += 0.5f * unitx; - modbounds.y1 += 0.5f * unity; + /* length of a unit vector (1,1) */ + float unit_length = 0.70710678f; + + unitx = unity = unit_length * half_width; + modbounds.x0 -= unitx; + modbounds.y0 -= unity; + modbounds.x1 += unitx; + modbounds.y1 += unity; } /* lines need to be divided by their length */ else { + float length = sqrtf(unitx * unitx + unity * unity); + + /* extend line length */ + if (length_extension > 0.0f) + { + float half_length_extension = length_extension *0.5f; + + float directionx = unitx / length; + float directiony = unity / length; + + modbounds.x0 -= directionx * half_length_extension; + modbounds.y0 -= directiony * half_length_extension; + modbounds.x1 += directionx * half_length_extension; + modbounds.y1 += directiony * half_length_extension; + } + /* prescale unitx and unity by the half-width */ - float invlength = width / sqrtf(unitx * unitx + unity * unity); + float invlength = half_width / length; unitx *= invlength; unity *= invlength; } |
