mirror of
https://github.com/holub/mame
synced 2025-04-19 23:12:11 +03:00
Moved extension of vector lines to where it belongs (nw)
This commit is contained in:
parent
92c2bdf917
commit
052fd0c608
@ -27,6 +27,18 @@
|
||||
* added two new tables Tinten and Tmerge (for 256 color support)
|
||||
* added find_color routine to build above tables .ac
|
||||
*
|
||||
* Vector Team
|
||||
*
|
||||
* Brad Oliver
|
||||
* Aaron Giles
|
||||
* Bernd Wiebelt
|
||||
* Allard van der Bas
|
||||
* Al Kossow (VECSIM)
|
||||
* Hedley Rainnie (VECSIM)
|
||||
* Eric Smith (VECSIM)
|
||||
* Neil Bradley (technical advice)
|
||||
* Andrew Caldwell (anti-aliasing)
|
||||
*
|
||||
**************************************************************************** */
|
||||
|
||||
#include "emu.h"
|
||||
@ -35,25 +47,10 @@
|
||||
#include "vector.h"
|
||||
|
||||
|
||||
#define FLT_EPSILON 1E-5
|
||||
|
||||
#define VECTOR_WIDTH_DENOM 512
|
||||
|
||||
#define MAX_POINTS 10000
|
||||
|
||||
#define VECTOR_TEAM \
|
||||
"-* Vector Heads *-\n" \
|
||||
"Brad Oliver\n" \
|
||||
"Aaron Giles\n" \
|
||||
"Bernd Wiebelt\n" \
|
||||
"Allard van der Bas\n" \
|
||||
"Al Kossow (VECSIM)\n" \
|
||||
"Hedley Rainnie (VECSIM)\n" \
|
||||
"Eric Smith (VECSIM)\n" \
|
||||
"Neil Bradley (technical advice)\n" \
|
||||
"Andrew Caldwell (anti-aliasing)\n" \
|
||||
"- *** -\n"
|
||||
|
||||
float vector_options::s_flicker = 0.0f;
|
||||
float vector_options::s_beam_width_min = 0.0f;
|
||||
float vector_options::s_beam_width_max = 0.0f;
|
||||
@ -154,10 +151,6 @@ UINT32 vector_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
|
||||
float yscale = 1.0f / (65536 * visarea.height());
|
||||
float xoffs = (float)visarea.min_x;
|
||||
float yoffs = (float)visarea.min_y;
|
||||
float xratio = xscale / yscale;
|
||||
float yratio = yscale / xscale;
|
||||
xratio = (xratio < 1.0f) ? xratio : 1.0f;
|
||||
yratio = (yratio < 1.0f) ? yratio : 1.0f;
|
||||
|
||||
point *curpoint;
|
||||
int lastx = 0;
|
||||
@ -188,31 +181,6 @@ UINT32 vector_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
|
||||
coords.x1 = ((float)curpoint->x - xoffs) * xscale;
|
||||
coords.y1 = ((float)curpoint->y - yoffs) * yscale;
|
||||
|
||||
float xdistance = coords.x0 - coords.x1;
|
||||
float ydistance = coords.y0 - coords.y1;
|
||||
|
||||
// extend zero-length vector line (vector point) by 3/8 beam_width on both sides
|
||||
if (fabs(xdistance) < FLT_EPSILON &&
|
||||
fabs(ydistance) < FLT_EPSILON)
|
||||
{
|
||||
coords.x0 += xratio * beam_width * 0.375f;
|
||||
coords.y0 += yratio * beam_width * 0.375f;
|
||||
coords.x1 -= xratio * beam_width * 0.375f;
|
||||
coords.y1 -= yratio * beam_width * 0.375f;
|
||||
}
|
||||
// extend vector line by 3/8 beam_width on both sides
|
||||
else
|
||||
{
|
||||
float length = sqrt(xdistance * xdistance + ydistance * ydistance);
|
||||
float xdirection = xdistance / length;
|
||||
float ydirection = ydistance / length;
|
||||
|
||||
coords.x0 += xratio * beam_width * 0.375f * (xdirection / xratio);
|
||||
coords.y0 += yratio * beam_width * 0.375f * (ydirection / yratio);
|
||||
coords.x1 -= xratio * beam_width * 0.375f * (xdirection / xratio);
|
||||
coords.y1 -= yratio * beam_width * 0.375f * (ydirection / yratio);
|
||||
}
|
||||
|
||||
if (curpoint->intensity != 0)
|
||||
{
|
||||
screen.container().add_line(
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
void render_resample_argb_bitmap_hq(bitmap_argb32 &dest, bitmap_argb32 &source, const render_color &color, bool force = false);
|
||||
int render_clip_line(render_bounds *bounds, const render_bounds *clip);
|
||||
int render_clip_quad(render_bounds *bounds, const render_bounds *clip, render_quad_texuv *texcoords);
|
||||
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);
|
||||
void render_load_jpeg(bitmap_argb32 &bitmap, emu_file &file, const char *dirname, const char *filename);
|
||||
bool render_load_png(bitmap_argb32 &bitmap, emu_file &file, const char *dirname, const char *filename, bool load_as_alpha_to_existing = false);
|
||||
|
||||
|
@ -1557,7 +1557,7 @@ void renderer_d3d9::batch_vector(const render_primitive &prim, float line_time)
|
||||
|
||||
// determine the bounds of a quad to draw this line
|
||||
render_bounds b0, b1;
|
||||
render_line_to_quad(&prim.bounds, effwidth, &b0, &b1);
|
||||
render_line_to_quad(&prim.bounds, effwidth, effwidth, &b0, &b1);
|
||||
|
||||
float dx = b1.x1 - b0.x1;
|
||||
float dy = b1.y1 - b0.y1;
|
||||
@ -1663,7 +1663,7 @@ void renderer_d3d9::draw_line(const render_primitive &prim)
|
||||
|
||||
// determine the bounds of a quad to draw this line
|
||||
render_bounds b0, b1;
|
||||
render_line_to_quad(&prim.bounds, effwidth, &b0, &b1);
|
||||
render_line_to_quad(&prim.bounds, effwidth, 0.0f, &b0, &b1);
|
||||
|
||||
// iterate over AA steps
|
||||
for (const line_aa_step *step = PRIMFLAG_GET_ANTIALIAS(prim.flags) ? line_aa_4step : line_aa_1step;
|
||||
|
@ -1239,7 +1239,7 @@ int renderer_ogl::draw(const int update)
|
||||
effwidth = 0.5f;
|
||||
|
||||
// determine the bounds of a quad to draw this line
|
||||
render_line_to_quad(&prim.bounds, effwidth, &b0, &b1);
|
||||
render_line_to_quad(&prim.bounds, effwidth, 0.0f, &b0, &b1);
|
||||
|
||||
// fix window position
|
||||
b0.x0 += hofs;
|
||||
|
Loading…
Reference in New Issue
Block a user