--- ray/src/ot/wfconv.c 2014/06/11 00:08:30 2.14 +++ ray/src/ot/wfconv.c 2021/03/11 17:00:58 2.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: wfconv.c,v 2.14 2014/06/11 00:08:30 greg Exp $"; +static const char RCSid[] = "$Id: wfconv.c,v 2.17 2021/03/11 17:00:58 greg Exp $"; #endif /* * Load Wavefront .OBJ file and convert to triangles with mesh info. @@ -261,7 +261,7 @@ dominant_axis(char *v1, char *v2, char *v3) for (i = imax = 2; i--; ) if (vn[i]*vn[i] > vn[imax]*vn[imax]) imax = i; - return(vn[imax]*vn[imax] > FTINY*FTINY ? imax : -1); + return(vn[imax]*vn[imax] > FTINY*FTINY*FTINY*FTINY ? imax : -1); } /* callback for triangle output from polygon */ @@ -279,17 +279,18 @@ putface( /* put out an N-sided polygon */ char **av ) { - Vert2_list *poly = polyAlloc(ac); + Vert2_list *poly; int i, ax, ay; - if (poly == NULL) - return(0); - poly->p = (void *)av; for (i = ac-3; i >= 0; i--) /* identify dominant axis */ if ((ax = dominant_axis(av[i], av[i+1], av[i+2])) >= 0) break; if (ax < 0) return(1); /* ignore degenerate face */ + poly = polyAlloc(ac); + if (poly == NULL) + return(0); + poly->p = (void *)av; if (++ax >= 3) ax = 0; ay = ax; if (++ay >= 3) ay = 0; @@ -468,7 +469,7 @@ syntax( /* report syntax error and exit */ char *er ) { - sprintf(errmsg, "%s: Wavefront syntax error near line %d: %s\n", + sprintf(errmsg, "%s: Wavefront syntax error near line %d: %s", inpfile, lineno, er); error(USER, errmsg); }