Add a function to combine vertices while tesselating the polygon,
so that OpenGL can fill self-intersecting polygons. [git-p4: depot-paths = "//depot/solvespace/": change = 1688]
This commit is contained in:
parent
ebdef1818c
commit
c934737d9e
3
expr.h
3
expr.h
|
@ -53,6 +53,9 @@ public:
|
||||||
char c;
|
char c;
|
||||||
} x;
|
} x;
|
||||||
|
|
||||||
|
static inline Expr *AllocExpr(void)
|
||||||
|
{ return (Expr *)AllocTemporary(sizeof(Expr)); }
|
||||||
|
|
||||||
static Expr *FromParam(hParam p);
|
static Expr *FromParam(hParam p);
|
||||||
static Expr *FromConstant(double v);
|
static Expr *FromConstant(double v);
|
||||||
|
|
||||||
|
|
11
glhelper.cpp
11
glhelper.cpp
|
@ -82,6 +82,16 @@ void glxColor4d(double r, double g, double b, double a)
|
||||||
static void __stdcall Vertex(Vector *p) {
|
static void __stdcall Vertex(Vector *p) {
|
||||||
glxVertex3v(*p);
|
glxVertex3v(*p);
|
||||||
}
|
}
|
||||||
|
static void __stdcall Combine(double coords[3], void *vertexData[4],
|
||||||
|
float weight[4], void **outData)
|
||||||
|
{
|
||||||
|
Vector *n = (Vector *)AllocTemporary(sizeof(Vector));
|
||||||
|
n->x = coords[0];
|
||||||
|
n->y = coords[1];
|
||||||
|
n->z = coords[2];
|
||||||
|
|
||||||
|
*outData = n;
|
||||||
|
}
|
||||||
void glxFillPolygon(SPolygon *p)
|
void glxFillPolygon(SPolygon *p)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -91,6 +101,7 @@ void glxFillPolygon(SPolygon *p)
|
||||||
gluTessCallback(gt, GLU_TESS_BEGIN, (cf *)glBegin);
|
gluTessCallback(gt, GLU_TESS_BEGIN, (cf *)glBegin);
|
||||||
gluTessCallback(gt, GLU_TESS_END, (cf *)glEnd);
|
gluTessCallback(gt, GLU_TESS_END, (cf *)glEnd);
|
||||||
gluTessCallback(gt, GLU_TESS_VERTEX, (cf *)Vertex);
|
gluTessCallback(gt, GLU_TESS_VERTEX, (cf *)Vertex);
|
||||||
|
gluTessCallback(gt, GLU_TESS_COMBINE, (cf *)Combine);
|
||||||
gluTessProperty(gt, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
|
gluTessProperty(gt, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
|
||||||
|
|
||||||
gluTessBeginPolygon(gt, NULL);
|
gluTessBeginPolygon(gt, NULL);
|
||||||
|
|
|
@ -102,7 +102,7 @@ bool SolveSpace::SolveGroup(hGroup hg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool r = sys.Solve();
|
bool r = sys.Solve();
|
||||||
FreeAllExprs();
|
FreeAllTemporary();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ void PaintGraphics(void);
|
||||||
void dbp(char *str, ...);
|
void dbp(char *str, ...);
|
||||||
void Error(char *str, ...);
|
void Error(char *str, ...);
|
||||||
|
|
||||||
Expr *AllocExpr(void);
|
void *AllocTemporary(int n);
|
||||||
void FreeAllExprs(void);
|
void FreeAllTemporary(void);
|
||||||
void *MemRealloc(void *p, int n);
|
void *MemRealloc(void *p, int n);
|
||||||
void *MemAlloc(int n);
|
void *MemAlloc(int n);
|
||||||
void MemFree(void *p);
|
void MemFree(void *p);
|
||||||
|
|
|
@ -69,15 +69,14 @@ void Error(char *str, ...)
|
||||||
// at the end.
|
// at the end.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static HANDLE Heap;
|
static HANDLE Heap;
|
||||||
Expr *AllocExpr(void)
|
void *AllocTemporary(int n)
|
||||||
{
|
{
|
||||||
Expr *v = (Expr *)HeapAlloc(Heap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY,
|
Expr *v = (Expr *)HeapAlloc(Heap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, n);
|
||||||
sizeof(Expr));
|
|
||||||
if(!v) oops();
|
if(!v) oops();
|
||||||
memset(v, 0, sizeof(*v));
|
memset(v, 0, n);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
void FreeAllExprs(void)
|
void FreeAllTemporary(void)
|
||||||
{
|
{
|
||||||
if(Heap) HeapDestroy(Heap);
|
if(Heap) HeapDestroy(Heap);
|
||||||
Heap = HeapCreate(HEAP_NO_SERIALIZE, 1024*1024*20, 0);
|
Heap = HeapCreate(HEAP_NO_SERIALIZE, 1024*1024*20, 0);
|
||||||
|
@ -735,8 +734,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
ThawWindowPos(TextWnd);
|
ThawWindowPos(TextWnd);
|
||||||
ThawWindowPos(GraphicsWnd);
|
ThawWindowPos(GraphicsWnd);
|
||||||
|
|
||||||
// Create the heap that we use to store Exprs.
|
// Create the heap that we use to store Exprs and other temp stuff.
|
||||||
FreeAllExprs();
|
FreeAllTemporary();
|
||||||
|
|
||||||
// Call in to the platform-independent code, and let them do their init
|
// Call in to the platform-independent code, and let them do their init
|
||||||
SS.Init(lpCmdLine);
|
SS.Init(lpCmdLine);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user