调试LineTree
parent
3f1421a1bd
commit
2cf45455ba
|
@ -1145,15 +1145,15 @@ bool drawElement(uint elementIndex, vec2 localUV, vec2 scale, out vec3 color, ou
|
||||||
p2Last = p[2];
|
p2Last = p[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(minDistance<=0.001)
|
if(minDistance<=0.001)
|
||||||
// {
|
{
|
||||||
// hitElement = true;
|
hitElement = true;
|
||||||
// elementColor = vec4(0,0,0,1);
|
elementColor = vec4(0,0,0,1);
|
||||||
// if(debugBegin==1)
|
if(debugBegin==1)
|
||||||
// elementColor = vec4(1,1,0,1);
|
elementColor = vec4(1,1,0,1);
|
||||||
// else if(debugBegin==2)
|
else if(debugBegin==2)
|
||||||
// elementColor = vec4(0,1,0,1);
|
elementColor = vec4(0,1,0,1);
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,7 +1262,7 @@ void main()
|
||||||
|
|
||||||
imageStore(gBaseColor, pixelLocation, vec4(color.rgb,1));
|
imageStore(gBaseColor, pixelLocation, vec4(color.rgb,1));
|
||||||
imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1));
|
imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1));
|
||||||
return;
|
//return;
|
||||||
if (/*color.a!=-1&&*/debugBVH==vec3(0))
|
if (/*color.a!=-1&&*/debugBVH==vec3(0))
|
||||||
{
|
{
|
||||||
//imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1));
|
//imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1));
|
||||||
|
|
|
@ -158,7 +158,7 @@ std::unique_ptr<Drawable> Model::processMesh(aiMesh* mesh, const aiScene* scene,
|
||||||
{
|
{
|
||||||
//qDebug() << v.TexCoords.x << v.TexCoords.y;
|
//qDebug() << v.TexCoords.x << v.TexCoords.y;
|
||||||
v.TexCoords = (v.TexCoords - leftBottom) / (rightTop - leftBottom);
|
v.TexCoords = (v.TexCoords - leftBottom) / (rightTop - leftBottom);
|
||||||
qDebug() << v.TexCoords.x << v.TexCoords.y;
|
//qDebug() << v.TexCoords.x << v.TexCoords.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh->vertices = vertices;
|
mesh->vertices = vertices;
|
||||||
|
@ -254,21 +254,21 @@ GLuint Renderer::Model::loadPainting(std::string path)
|
||||||
|
|
||||||
vector<std::shared_ptr<ElementStyle>> style = {
|
vector<std::shared_ptr<ElementStyle>> style = {
|
||||||
std::make_shared<ElementStyleFillDemo>(),
|
std::make_shared<ElementStyleFillDemo>(),
|
||||||
std::make_shared<ElementStyleStrokeDemo>(0.02),
|
std::make_shared<ElementStyleStrokeDemo>(0.06),
|
||||||
std::make_shared<ElementStyleStrokeRadialGradientDemo>(0.2)
|
std::make_shared<ElementStyleStrokeRadialGradientDemo>(0.06)
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<std::shared_ptr<Element>> element = {
|
vector<std::shared_ptr<Element>> element = {
|
||||||
std::make_shared<Element>(Element{ contours[0].first, style[0], contours[0].second}),
|
std::make_shared<Element>(Element{ contours[0].first, style[0], contours[0].second}),
|
||||||
std::make_shared<Element>(Element{ contours[1].first, style[2], contours[1].second}),
|
std::make_shared<Element>(Element{ contours[1].first, style[2], contours[1].second}),
|
||||||
std::make_shared<Element>(Element{ contours[2].first, style[0], contours[2].second}),
|
std::make_shared<Element>(Element{ contours[2].first, style[1], contours[2].second}),
|
||||||
};
|
};
|
||||||
Painting painting;
|
Painting painting;
|
||||||
|
|
||||||
if (path == "0.json")
|
if (path == "0.json")
|
||||||
{
|
{
|
||||||
painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.45,-0.45), glm::vec2(0.5,0.5) / 2.f, 0, glm::bvec2(false), 0 });
|
painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.45,-0.45), glm::vec2(0.5,0.5) / 2.f, 0, glm::bvec2(false), 0 });
|
||||||
painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.45, 0.45), glm::vec2(0.5,0.5) / 2.f, 0, glm::bvec2(false), 0 });
|
//painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.45, 0.45), glm::vec2(0.5,0.5) / 2.f, 0, glm::bvec2(false), 0 });
|
||||||
painting.addElement(*element[2], ElementTransform{ glm::vec2(0.50,-0.45), glm::vec2(0.6,0.7) / 2.f, 0, glm::bvec2(false), 0 });
|
painting.addElement(*element[2], ElementTransform{ glm::vec2(0.50,-0.45), glm::vec2(0.6,0.7) / 2.f, 0, glm::bvec2(false), 0 });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Line.h"
|
#include "Line.h"
|
||||||
#include <glm/detail/func_packing.hpp>
|
#include <glm/detail/func_packing.hpp>
|
||||||
|
#include <qDebug>
|
||||||
using namespace Renderer;
|
using namespace Renderer;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
@ -121,9 +122,10 @@ Point Line::getMinDistancePointOnSide(double xy, double l, double r, bool isY) {
|
||||||
swap(pMidr.x, pMidr.y);
|
swap(pMidr.x, pMidr.y);
|
||||||
}
|
}
|
||||||
double mid, midr;
|
double mid, midr;
|
||||||
|
//qDebug() << "Start" << xy << l << r << isY;
|
||||||
while (fabs(r - l) > eps) {
|
while (fabs(r - l) > eps) {
|
||||||
mid = (l + r) / 2;
|
mid = l + (r - l) / 3;
|
||||||
midr = (mid + r) / 2;
|
midr = r - (r - l) / 3;
|
||||||
if (isY) {
|
if (isY) {
|
||||||
pMid.x = mid;
|
pMid.x = mid;
|
||||||
pMidr.x = midr;
|
pMidr.x = midr;
|
||||||
|
@ -139,6 +141,7 @@ Point Line::getMinDistancePointOnSide(double xy, double l, double r, bool isY) {
|
||||||
r = midr;
|
r = midr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//qDebug() << " End" << xy << l << r << isY;
|
||||||
Point ans = { xy, l };
|
Point ans = { xy, l };
|
||||||
if (isY) swap(ans.x, ans.y);
|
if (isY) swap(ans.x, ans.y);
|
||||||
return ans;
|
return ans;
|
||||||
|
@ -155,9 +158,9 @@ int Line::getPointSideOfLine(Point p) {
|
||||||
|
|
||||||
bool Line::judgeOneSideIntersectionWithWidth(double xy, double l, double r, bool isY, double width, int type) {
|
bool Line::judgeOneSideIntersectionWithWidth(double xy, double l, double r, bool isY, double width, int type) {
|
||||||
Point p = getMinDistancePointOnSide(xy, l, r, isY);
|
Point p = getMinDistancePointOnSide(xy, l, r, isY);
|
||||||
if (type && getPointSideOfLine(p) != type) {
|
//if (type && getPointSideOfLine(p) != type) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
return getMinDistanceFromPoint(p) <= width;
|
return getMinDistanceFromPoint(p) <= width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <qDebug>
|
||||||
|
|
||||||
using namespace Renderer;
|
using namespace Renderer;
|
||||||
using std::set;
|
using std::set;
|
||||||
|
@ -96,6 +97,7 @@ void LineTree::monotonization(vector<PointVector>& inLines, vector<std::shared_p
|
||||||
}
|
}
|
||||||
// 防止在首尾直线在与 X 轴平行上
|
// 防止在首尾直线在与 X 轴平行上
|
||||||
int siz = outLines.size();
|
int siz = outLines.size();
|
||||||
|
qWarning() << outLines.size();
|
||||||
if (!(outLines[0]->getBegin() == outLines[siz - 1]->getEnd()))
|
if (!(outLines[0]->getBegin() == outLines[siz - 1]->getEnd()))
|
||||||
return;
|
return;
|
||||||
if (isOffset) {
|
if (isOffset) {
|
||||||
|
@ -141,12 +143,12 @@ bool LineTree::handleShortCutNode(LineTreeNode& fa, LineTreeNode& nowTreeNode, d
|
||||||
nowTreeNode.lineSet.push_back(lineIndex);
|
nowTreeNode.lineSet.push_back(lineIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nowTreeNode.lineSet.size() <= requiredLineMin) {
|
if (nowTreeNode.lineSet.size() <= requiredLineMin || (nowTreeNode.bound.z()-nowTreeNode.bound.x()) *sqrt(2) <= lineWidth) {
|
||||||
if (nowTreeNode.lineSet.empty())
|
if (nowTreeNode.lineSet.empty())
|
||||||
return false;
|
return false;
|
||||||
restOfTreeNodes.push_back(nowTreeNode);
|
restOfTreeNodes.push_back(nowTreeNode);
|
||||||
nowTreeNode.divided = false;
|
nowTreeNode.divided = false;
|
||||||
v.push_back(nowTreeNode);
|
//v.push_back(nowTreeNode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -268,7 +270,7 @@ vector<BvhTreeData> LineTree::getPointLineAndBvhTree(vector<float>& resPoints, v
|
||||||
oneData.leftSon = resLines.size();
|
oneData.leftSon = resLines.size();
|
||||||
oneData.rightSon = 0;
|
oneData.rightSon = 0;
|
||||||
oneData.bound = nowTreeNode.bound;
|
oneData.bound = nowTreeNode.bound;
|
||||||
//std::cout << nowTreeNode.lineSet.size() << ' ';
|
qDebug() << nowTreeNode.bound << nowTreeNode.lineSet.size() << ' ';
|
||||||
resLines.push_back(nowTreeNode.lineSet.size());
|
resLines.push_back(nowTreeNode.lineSet.size());
|
||||||
for (auto& lineIndex : nowTreeNode.lineSet) {
|
for (auto& lineIndex : nowTreeNode.lineSet) {
|
||||||
resLines.push_back(lineIndex);
|
resLines.push_back(lineIndex);
|
||||||
|
|
Loading…
Reference in New Issue