添加注释

dev-VirtualTexture
yang.yongquan 2023-01-23 23:16:44 +08:00
parent 4f9720ba89
commit da2cda55e5
3 changed files with 12 additions and 6 deletions

View File

@ -14,6 +14,8 @@ Line::Line(vector<Point> Vp) {
vX.push_back(now.x);
vY.push_back(now.y);
}
if (*vY.rbegin() < vY[0]) leftType = 0;
else leftType = 1;
}
int Line::size() {
@ -127,11 +129,12 @@ Point Line::getMinDistancePointOnSide(double xy, double l, double r, bool isY) {
}
int Line::getPointSideOfLine(Point p) {
// 1 为左侧, 2 为右侧
double z = (p.x - vX[0]) * (*vY.rbegin() - vY[0]) - (p.y - vY[0]) * (*vX.rbegin() - vX[0]);
if (z == 0) return 0;
else if(z>0) return 1;
else return 2;
//0 为在线上, 1 为左侧, 2 为右侧
double t = findTByValue(p.y, true);
double x = getLineValueByT(t, false);
if (fabs(x - p.x) <= eps) return 0;
else if (x < p.x) return 1 + (leftType == 1);
else return 1 + (leftType == 0);
}
bool Line::judgeOneSideIntersectionWithWidth(double xy, double l, double r, bool isY, double width, int type) {

View File

@ -35,9 +35,10 @@ namespace Renderer
class Line
{
// leftType 为 1 左侧向右有一个交点, 0 没有交点
protected:
std::vector<double> vX, vY;
int siz;
int siz, leftType;
public:
typedef std::shared_ptr<Line> LinePtr;
Line() :siz(0) {}
@ -52,6 +53,7 @@ namespace Renderer
virtual int judgeOneSideIntersection(double xy, double l, double r, bool isY) = 0;
virtual double getMinDistanceFromPoint(Point p) = 0;
bool judgeOneSideIntersectionWithWidth(double xy, double l, double r, bool isY, double width, int type);
virtual double findTByValue(double value, bool isY) = 0;
bool judgeIntersectionWithWidth(QVector4D bound, double width, int type);
bool judgeIntersection(QVector4D bound);
int getPointSideOfLine(Point p);

View File

@ -218,6 +218,7 @@ void LineTree::spliteToLineTree() {
}
void LineTree::buildLineTree(std::vector<PointVector>& lineSet, double width, int type) {
// lineTpye 为 0 两侧, 1 为逆时针方向左侧, 2 为逆时针右侧
init();
lineWidth = width;
lineType = type;