Improve angle constraint rendering.

This commit is contained in:
Paddle
2023-11-24 09:42:28 +01:00
parent 05c382f6d9
commit 74dd736e3c
3 changed files with 52 additions and 24 deletions

View File

@@ -91,6 +91,8 @@ SoDatumLabel::SoDatumLabel()
SO_NODE_ADD_FIELD(param1, (0.f));
SO_NODE_ADD_FIELD(param2, (0.f));
SO_NODE_ADD_FIELD(param4, (0.f));
SO_NODE_ADD_FIELD(param5, (0.f));
useAntialiasing = true;
@@ -1061,11 +1063,17 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
// Only the angle intersection point is needed
SbVec3f p0 = points[0];
float margin = this->imgHeight / 4.0;
// Load the Parameters
float length = this->param1.getValue();
float startangle = this->param2.getValue();
float range = this->param3.getValue();
float endangle = startangle + range;
float endLineLength1 = std::max(this->param4.getValue(), margin);
float endLineLength2 = std::max(this->param5.getValue(), margin);
float endLineLength12 = std::max(- this->param4.getValue(), margin);
float endLineLength22 = std::max(- this->param5.getValue(), margin);
float r = 2*length;
@@ -1089,7 +1097,6 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
textOffset = p0 + v0 * r;
float margin = this->imgHeight / 4.0;
// Draw
glBegin(GL_LINE_STRIP);
@@ -1113,10 +1120,10 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
SbVec3f v1(cos(startangle),sin(startangle),0);
SbVec3f v2(cos(endangle),sin(endangle),0);
SbVec3f pnt1 = p0+(r-margin)*v1;
SbVec3f pnt2 = p0+(r+margin)*v1;
SbVec3f pnt3 = p0+(r-margin)*v2;
SbVec3f pnt4 = p0+(r+margin)*v2;
SbVec3f pnt1 = p0 + (r - endLineLength1) * v1;
SbVec3f pnt2 = p0 + (r + endLineLength12) * v1;
SbVec3f pnt3 = p0 + (r - endLineLength2) * v2;
SbVec3f pnt4 = p0 + (r + endLineLength22) * v2;
glBegin(GL_LINES);
glVertex2f(pnt1[0],pnt1[1]);