Add a workaround for OpenGL, which likes to tesselate with
zero-area triangles, apparently. And make the number of line segments used to approximate a triangle depend on its scale on screen. [git-p4: depot-paths = "//depot/solvespace/": change = 1738]
This commit is contained in:
parent
70ccbebc8f
commit
097d0ddfa9
|
@ -746,6 +746,7 @@ void Entity::DrawOrGetDistance(int order) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CIRCLE_SIDES(r) (7 + (int)(10*((sqrt(r))*SS.GW.scale)/20))
|
||||||
case ARC_OF_CIRCLE: {
|
case ARC_OF_CIRCLE: {
|
||||||
if(order >= 0 && order != 1) break;
|
if(order >= 0 && order != 1) break;
|
||||||
Vector c = SS.GetEntity(point[0])->PointGetNum();
|
Vector c = SS.GetEntity(point[0])->PointGetNum();
|
||||||
|
@ -760,7 +761,7 @@ void Entity::DrawOrGetDistance(int order) {
|
||||||
double thetaa, thetab, dtheta;
|
double thetaa, thetab, dtheta;
|
||||||
ArcGetAngles(&thetaa, &thetab, &dtheta);
|
ArcGetAngles(&thetaa, &thetab, &dtheta);
|
||||||
|
|
||||||
int i, n = (int)((20*dtheta)/(2*PI));
|
int i, n = 3 + (int)(CIRCLE_SIDES(ra)*dtheta/(2*PI));
|
||||||
Vector prev = pa;
|
Vector prev = pa;
|
||||||
for(i = 1; i <= n; i++) {
|
for(i = 1; i <= n; i++) {
|
||||||
double theta = thetaa + (dtheta*i)/n;
|
double theta = thetaa + (dtheta*i)/n;
|
||||||
|
@ -781,7 +782,7 @@ void Entity::DrawOrGetDistance(int order) {
|
||||||
Vector center = SS.GetEntity(point[0])->PointGetNum();
|
Vector center = SS.GetEntity(point[0])->PointGetNum();
|
||||||
Vector u = q.RotationU(), v = q.RotationV();
|
Vector u = q.RotationU(), v = q.RotationV();
|
||||||
|
|
||||||
int i, c = 20;
|
int i, c = CIRCLE_SIDES(r);
|
||||||
Vector prev = u.ScaledBy(r).Plus(center);
|
Vector prev = u.ScaledBy(r).Plus(center);
|
||||||
for(i = 1; i <= c; i++) {
|
for(i = 1; i <= c; i++) {
|
||||||
double phi = (2*PI*i)/c;
|
double phi = (2*PI*i)/c;
|
||||||
|
|
|
@ -1203,7 +1203,7 @@ void GraphicsWindow::Paint(int w, int h) {
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glxLockColorTo(0, 1, 0);
|
glxLockColorTo(0, 1, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
// glxDebugMesh(&br);
|
glxDebugMesh(&br);
|
||||||
|
|
||||||
br.Clear();
|
br.Clear();
|
||||||
FreeAllTemporary();
|
FreeAllTemporary();
|
||||||
|
|
4
mesh.cpp
4
mesh.cpp
|
@ -7,6 +7,10 @@ void SMesh::Clear(void) {
|
||||||
void SMesh::AddTriangle(Vector n, Vector a, Vector b, Vector c) {
|
void SMesh::AddTriangle(Vector n, Vector a, Vector b, Vector c) {
|
||||||
Vector ab = b.Minus(a), bc = c.Minus(b);
|
Vector ab = b.Minus(a), bc = c.Minus(b);
|
||||||
Vector np = ab.Cross(bc);
|
Vector np = ab.Cross(bc);
|
||||||
|
if(np.Magnitude() < 1e-10) {
|
||||||
|
// ugh; gl sometimes tesselates to collinear triangles
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(np.Dot(n) > 0) {
|
if(np.Dot(n) > 0) {
|
||||||
AddTriangle(a, b, c);
|
AddTriangle(a, b, c);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user