--- ray/src/common/face.c 1989/02/21 14:39:54 1.2 +++ ray/src/common/face.c 1991/08/02 10:29:42 1.5 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -51,6 +51,8 @@ OBJREC *o; if (o->oargs.nfargs < 9 || o->oargs.nfargs % 3) objerror(o, USER, "bad # arguments"); + o->os = (char *)f; /* save face */ + f->va = o->oargs.farg; f->nv = o->oargs.nfargs / 3; /* compute area and normal */ @@ -82,7 +84,7 @@ OBJREC *o; badvert += fabs(d1 - f->offset/i) > VERTEPS; f->offset += d1; } - f->offset /= f->nv; + f->offset /= (double)f->nv; if (badvert) objerror(o, WARNING, "non-planar vertex"); /* find axis */ @@ -90,7 +92,6 @@ OBJREC *o; if (fabs(f->norm[2]) > fabs(f->norm[f->ax])) f->ax = 2; - o->os = (char *)f; /* save face */ return(f); } @@ -98,6 +99,8 @@ OBJREC *o; freeface(o) /* free memory associated with face */ OBJREC *o; { + if (o->os == NULL) + return; free(o->os); o->os = NULL; }