diff --git a/ArchitectureColoredPainting/CubicBezier.cpp b/ArchitectureColoredPainting/CubicBezier.cpp index 99b3277..3385ee6 100644 --- a/ArchitectureColoredPainting/CubicBezier.cpp +++ b/ArchitectureColoredPainting/CubicBezier.cpp @@ -20,9 +20,9 @@ Point CubicBezier::calculateControlPoint(Point a, Point b) { } void CubicBezier::findPointsOfDivison(vector &p, vector& res) { - double a = -3 * p[0] + 9 * p[1] - 9 * p[2] + 3 * p[3]; - double b = 6 * p[0] - 12 * p[1] + 6 * p[2]; - double c = -3 * p[0] + 3 * p[1]; + double a = -3 * p[0] + 3 * p[1] - 3 * p[2] + 3 * p[3]; + double b = 6 * p[0] - 4 * p[1] + 2 * p[2]; + double c = -3 * p[0] + p[1]; double deta = b * b - 4 * a * c, t = 0; if (fabs(a) > eps) { if (deta < eps) return; @@ -112,7 +112,7 @@ int CubicBezier::judgeBoundIntersection(double xy, double l, double r, bool isY) be = *vY.begin(); en = *vY.rbegin(); } - if ((be - xy) * (en - xy) > eps) return 0; + if ((be - xy) * (en - xy) >= eps) return 0; double t = findTByValue(xy, isY); double value = getLineValueByT(t, !isY); if (l <= value && value <= r && fabs(t) > eps && fabs(1 - t) > eps) { diff --git a/ArchitectureColoredPainting/RendererWidget.cpp b/ArchitectureColoredPainting/RendererWidget.cpp index b3220d7..b034184 100644 --- a/ArchitectureColoredPainting/RendererWidget.cpp +++ b/ArchitectureColoredPainting/RendererWidget.cpp @@ -309,10 +309,10 @@ void RendererWidget::paintGL() depthMipmapProgramPtr->bind(); for (int i = 0; i <= 3; i++) glBindImageTexture(i, gbuffers[7], i, GL_FALSE, 0, GL_READ_WRITE, GL_R32F); - glDispatchCompute(ceil(depthWidth / 2 / 8.), ceil(depthHeight / 2 / 8.), 1); + glDispatchCompute(ceil(depthWidth / 2. / 8.), ceil(depthHeight / 2. / 8.), 1); for (int i = 0; i <= 3; i++) glBindImageTexture(i, gbuffers[7], i + 3, GL_FALSE, 0, GL_READ_WRITE, GL_R32F); - glDispatchCompute(ceil(depthWidth / 2 / 8 / 8.), ceil(depthHeight / 2 / 8 / 8.), 1); + glDispatchCompute(ceil(depthWidth / 2. / 8. / 8.), ceil(depthHeight / 2. / 8. / 8.), 1); depthMipmapProgramPtr->release(); shadowMappingProgramPtr->bind(); diff --git a/ArchitectureColoredPainting/StraightLine.cpp b/ArchitectureColoredPainting/StraightLine.cpp index e738bd1..f7ad846 100644 --- a/ArchitectureColoredPainting/StraightLine.cpp +++ b/ArchitectureColoredPainting/StraightLine.cpp @@ -31,7 +31,7 @@ int StraightLine::judgeBoundIntersection(double xy, double l, double r, bool isY swap(be.x, be.y); swap(en.x, en.y); } - if ((be.x - xy) * (en.x - xy) > eps) return 0; + if ((be.x - xy) * (en.x - xy) >= eps) return 0; if (direction(isY)) { float t = findTByValue(xy, isY); float value = getLineValueByT(t, !isY); diff --git a/ArchitectureColoredPainting/SvgParser.cpp b/ArchitectureColoredPainting/SvgParser.cpp index 399eb97..ac0819e 100644 --- a/ArchitectureColoredPainting/SvgParser.cpp +++ b/ArchitectureColoredPainting/SvgParser.cpp @@ -4,7 +4,7 @@ vector> SvgParser::parse(const std::string path, float width, float height) { std::string tmp; - vector point; + vector point; vector line; vector> lines; for (char c : path.substr(1)) @@ -18,11 +18,11 @@ vector> SvgParser::parse(const std::string path, float width, floa { if (tmp != "") { - point.push_back(std::stof(tmp)); + point.push_back(std::stod(tmp)); tmp = ""; if (point.size() == 2) { - line.push_back(Point{ std::clamp(point[0] / width * 2 - 1, -1.f, 1.f) , std::clamp(1 - point[1] / height * 2 , -1.f, 1.f)}); + line.push_back(Point{ std::clamp(point[0] / width * 2 - 1, -1., 1.) , std::clamp(1 - point[1] / height * 2 , -1., 1.)}); point.clear(); } }