diff --git a/ArchitectureColoredPainting/Shaders/painting.comp b/ArchitectureColoredPainting/Shaders/painting.comp index 84fd5a6..5c5a82a 100644 --- a/ArchitectureColoredPainting/Shaders/painting.comp +++ b/ArchitectureColoredPainting/Shaders/painting.comp @@ -1209,14 +1209,15 @@ void main() { uint zIndex = bvhChildren[index].y >> 18; bvec2 flip = bvec2(bvhChildren[index].y & (1<<16), bvhChildren[index].y & (1<<17)); - float angle = (float(bvhChildren[index].y) / 65535.0 - zIndex) * 2 * PI; + float angle = (float(bvhChildren[index].y&((1<<16)-1)) / 65535.0) * 2 * PI; mat2 rotation = {{cos(angle), -sin(angle)}, {sin(angle), cos(angle)}}; vec2 localUV = uv - (bound.xy + bound.zw) / 2; localUV = rotation * localUV; localUV /= (bound.zw - bound.xy) / 2; if (all(lessThan(vec2(-1), localUV)) && all(lessThan(localUV, vec2(1))) && zIndex>color.w) { - if (any(greaterThan(bound.xy+vec2(0.005), uv)) || any(greaterThan(uv, bound.zw-vec2(0.005)))) + //if (any(greaterThan(bound.xy+vec2(0.005), uv)) || any(greaterThan(uv, bound.zw-vec2(0.005)))) + if (any(greaterThan(vec2(-1)+vec2(0.005), localUV)) || any(greaterThan(localUV, vec2(1)-vec2(0.005)))) debugBVH.g += 0.3; //uint elementIndex = leftChild - bvhLength; //debugBVH.bg += 0.5 * (localUV + vec2(1)); @@ -1257,7 +1258,7 @@ void main() imageStore(gBaseColor, pixelLocation, vec4(color.rgb,1)); imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1)); - return; + //return; if (/*color.a!=-1&&*/debugBVH==vec3(0)) { //imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1)); diff --git a/ArchitectureColoredPainting/src/Renderer/Model.cpp b/ArchitectureColoredPainting/src/Renderer/Model.cpp index 68ff7e9..9ca01c8 100644 --- a/ArchitectureColoredPainting/src/Renderer/Model.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Model.cpp @@ -411,7 +411,7 @@ GLuint Renderer::Model::loadPainting(std::string path) // //rootBvhTreeData.push_back(BvhTreeData(QVector4D(x, y, z, w), 0, encodeZIndexAngle(1, (float)rand() / RAND_MAX * 360))); // painting.addElement(element[i%3], QVector4D(x, y, z, w), (float)rand() / RAND_MAX * 360, 1); //} - painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.5,-0.45), glm::vec2(0.6,0.7), 0, glm::bvec2(true, false), 0 }); + painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.5,-0.45), glm::vec2(0.6,0.7), 45, glm::bvec2(true, false), 0 }); painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.45,0.45), glm::vec2(0.5,0.5), 0, glm::bvec2(false), 0 }); painting.addElement(*element[2], ElementTransform{ glm::vec2(0.5,-0.45), glm::vec2(0.6,0.7), 0, glm::bvec2(false), 0 }); diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/LineTree.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/LineTree.cpp index c45897f..736b55e 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/LineTree.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Painting/LineTree.cpp @@ -251,7 +251,7 @@ vector LineTree::getPointLineAndBvhTree(vector& resPoints, v for (auto& nowTreeNode : restOfTreeNodes) { BvhTreeData oneData; oneData.leftSon = resLines.size(); - //oneData.rightSon = rightSon; + oneData.rightSon = 0; oneData.bound = nowTreeNode.bound; std::cout << nowTreeNode.lineSet.size() << ' '; resLines.push_back(nowTreeNode.lineSet.size()); diff --git a/UnitTest/ElementRendererTest.cpp b/UnitTest/ElementRendererTest.cpp index 711a18f..6688750 100644 --- a/UnitTest/ElementRendererTest.cpp +++ b/UnitTest/ElementRendererTest.cpp @@ -70,7 +70,7 @@ namespace UnitTest {1.00, Material{QColor(255,255,0)}}, }; return { BaseStyle(std::make_shared(), - std::make_shared(4, StrokeType::kLeftSide, StrokeEndType::kRound, + std::make_shared(30, StrokeType::kLeftSide, StrokeEndType::kRound, std::make_shared(materialMap, true))) }; } } style; diff --git a/UnitTest/ElementRendererTest.h b/UnitTest/ElementRendererTest.h index 4ddb3c0..a61fa93 100644 --- a/UnitTest/ElementRendererTest.h +++ b/UnitTest/ElementRendererTest.h @@ -29,15 +29,15 @@ namespace UnitTest glClear(GL_COLOR_BUFFER_BIT); QPainterPath path; QQuickSvgParser::parsePathDataFast("M100,100C-.5,100,0,100.5,0,0L40,.07C40,59.5,39.5,60,100,60Z", path); - /*QTransform transform; - transform.scale(10, 10); - transform.map(path);*/ - float pixelRatio = 30; + QTransform transform; + transform.scale(5, 5); + path = transform.map(path); + float pixelRatio = devicePixelRatioF(); auto [img, pos] = renderer.drawElement(path, style, pixelRatio, false); QPainter painter(this); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setRenderHint(QPainter::HighQualityAntialiasing); - painter.drawImage(QRectF(QPointF(0, 0), img.size()/devicePixelRatioF()), img); + painter.drawImage(QRectF(QPointF(0, 0), img.size()/pixelRatio), img); }; void resizeGL(int w, int h) override {}; };