void FlareLine(const Vec2s & pos0, const Vec2s & pos1, Entity * io) { Vec2f tmpPos0 = Vec2f(pos0); Vec2f tmpPos1 = Vec2f(pos1); Vec2f d = tmpPos1 - tmpPos0; Vec2f ad = glm::abs(d); if(ad.x > ad.y) { if(tmpPos0.x > tmpPos1.x) { std::swap(tmpPos0, tmpPos1); } float m = d.y / d.x; long i = tmpPos0.x; while(i < tmpPos1.x) { long z = rnd() * FLARELINERND; z += FLARELINESTEP; if(!io) { z *= g_sizeRatio.y; } i += z; tmpPos0.y += m * z; AddLFlare(Vec2s(i, tmpPos0.y), io); } } else { if(tmpPos0.y > tmpPos1.y) { std::swap(tmpPos0, tmpPos1); } float m = d.x / d.y; long i = tmpPos0.y; while(i < tmpPos1.y) { long z = rnd() * FLARELINERND; z += FLARELINESTEP; if(!io) { z *= g_sizeRatio.y; } i += z; tmpPos0.x += m * z; AddLFlare(Vec2s(tmpPos0.x, i), io); } } }
void FlareLine(Vec2f tmpPos0, Vec2f tmpPos1, Entity * io) { static const int FLARELINESTEP = 7; static const int FLARELINERND = 6; Vec2f d = tmpPos1 - tmpPos0; Vec2f ad = glm::abs(d); if(ad.x > ad.y) { if(tmpPos0.x > tmpPos1.x) { std::swap(tmpPos0, tmpPos1); } float m = d.y / d.x; float i = tmpPos0.x; while(i < tmpPos1.x) { long z = Random::get(0, FLARELINERND); z += FLARELINESTEP; if(!io) { z = long(z * g_sizeRatio.y); } i += z; tmpPos0.y += m * z; AddLFlare(Vec2f(i, tmpPos0.y), io); } } else { if(tmpPos0.y > tmpPos1.y) { std::swap(tmpPos0, tmpPos1); } float m = d.x / d.y; float i = tmpPos0.y; while(i < tmpPos1.y) { long z = Random::get(0, FLARELINERND); z += FLARELINESTEP; if(!io) { z = long(z * g_sizeRatio.y); } i += z; tmpPos0.x += m * z; AddLFlare(Vec2f(tmpPos0.x, i), io); } } }
void FlareLine(const Vec2s & pos0, const Vec2s & pos1, Entity * io) { float m; long i; long z; float x0 = pos0.x; float x1 = pos1.x; float y0 = pos0.y; float y1 = pos1.y; float dx = (x1 - x0); float adx = glm::abs(dx); float dy = (y1 - y0); float ady = glm::abs(dy); if(adx > ady) { if(x0 > x1) { z = x1; x1 = x0; x0 = z; z = y1; y0 = z; } if(x0 < x1) { m = dy / dx; i = x0; while(i < x1) { z = rnd() * FLARELINERND; z += FLARELINESTEP; i += z; y0 += m * z; AddLFlare(Vec2s(i, y0), io); } } else { m = dy / dx; i = x1; while(i < x0) { z = rnd() * FLARELINERND; z += FLARELINESTEP; i += z; y0 += m * z; AddLFlare(Vec2s(i, y0), io); } } } else { if(y0 > y1) { z = x1; x0 = z; z = y1; y1 = y0; y0 = z; } if(y0 < y1) { m = dx / dy; i = y0; while(i < y1) { z = rnd() * FLARELINERND; z += FLARELINESTEP; i += z; x0 += m * z; AddLFlare(Vec2s(x0, i), io); } } else { m = dx / dy; i = y1; while(i < y0) { z = rnd() * FLARELINERND; z += FLARELINESTEP; i += z; x0 += m * z; AddLFlare(Vec2s(x0, i), io); } } } }