This BSP split and simplify thing is stupid, but a hard-coded limit

on the number of pieces that we know how to reassemble is even
stupider. Now dynamically allocated.

[git-p4: depot-paths = "//depot/solvespace/": change = 1837]
solver
Jonathan Westhues 2008-07-13 04:58:52 -08:00
parent 88fc69116f
commit f70bbb3e7f
3 changed files with 9 additions and 4 deletions

View File

@ -51,15 +51,14 @@ void SMesh::GetBounding(Vector *vmax, Vector *vmin) {
}
void SMesh::Simplify(int start) {
#define MAX_TRIANGLES 2000
if(l.n - start > MAX_TRIANGLES) oops();
int maxTriangles = (l.n - start) + 10;
STriMeta meta = l.elem[start].meta;
STriangle tout[MAX_TRIANGLES];
STriangle *tout = (STriangle *)AllocTemporary(maxTriangles*sizeof(*tout));
int toutc = 0;
Vector n, conv[MAX_TRIANGLES*3];
Vector n, *conv = (Vector *)AllocTemporary(maxTriangles*3*sizeof(*conv));
int convc = 0;
int start0 = start;
@ -181,6 +180,8 @@ void SMesh::Simplify(int start) {
for(i = 0; i < toutc; i++) {
AddTriangle(&(tout[i]));
}
FreeTemporary(tout);
FreeTemporary(conv);
}
void SMesh::AddAgainstBsp(SMesh *srcm, SBsp3 *bsp3) {

View File

@ -101,6 +101,7 @@ DWORD CnfThawDWORD(DWORD v, char *name);
float CnfThawFloat(float v, char *name);
void *AllocTemporary(int n);
void FreeTemporary(void *p);
void FreeAllTemporary(void);
void *MemRealloc(void *p, int n);
void *MemAlloc(int n);

View File

@ -120,6 +120,9 @@ void *AllocTemporary(int n)
if(!v) oops();
return v;
}
void FreeTemporary(void *p) {
HeapFree(Temp, HEAP_NO_SERIALIZE, p);
}
void FreeAllTemporary(void)
{
if(Temp) HeapDestroy(Temp);