Skip to content

Commit

Permalink
fix: added handling of 32-bit RREAL
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Apr 16, 2021
1 parent 594127e commit f8335c5
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/common/convertobj.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: convertobj.c,v 2.4 2021/04/15 23:51:04 greg Exp $";
static const char RCSid[] = "$Id: convertobj.c,v 2.5 2021/04/16 15:18:33 greg Exp $";
#endif
/*
* convertobj.c
Expand Down Expand Up @@ -71,26 +71,32 @@ trismooth(Scene *sc, Face *f, void *ptr)
{
FILE *fp = (FILE *)ptr;
BARYCCM bcm;
RREAL ncoor[3][3];
FVECT coor[3];
int i;

if (f->nv != 3)
return(0); /* should never happen */
if (sizeof(sc->vert[0].p) != sizeof(FVECT))
error(INTERNAL, "Code error in trismooth()");
if (comp_baryc(&bcm, sc->vert[f->v[0].vid].p, sc->vert[f->v[1].vid].p,
sc->vert[f->v[2].vid].p) < 0)
#ifdef SMLFLT
for (i = 3; i--; ) {
double *v = sc->vert[f->v[i].vid].p;
VCOPY(coor[i], v);
}
if (comp_baryc(&bcm, coor[0], coor[1], coor[2]) < 0)
return(0); /* degenerate?? */

#else
if (comp_baryc(&bcm, sc->vert[f->v[0].vid].p,
sc->vert[f->v[1].vid].p, sc->vert[f->v[2].vid].p) < 0)
return(0); /* degenerate?? */
#endif
for (i = 3; i--; ) { /* assign BC normals */
float *tnrm = sc->norm[f->v[i].nid];
ncoor[0][i] = tnrm[0];
ncoor[1][i] = tnrm[1];
ncoor[2][i] = tnrm[2];
coor[0][i] = tnrm[0];
coor[1][i] = tnrm[1];
coor[2][i] = tnrm[2];
} /* print texture */
fprintf(fp, "\n%s texfunc %s\n4 dx dy dz %s\n0\n",
sc->matname[f->mat], TEXNAME, TCALNAME);
fput_baryc(&bcm, ncoor, 3, fp); /* with BC normals */
fput_baryc(&bcm, coor, 3, fp); /* with BC normals */
fprintf(fp, "\n%s polygon %s.%d\n0\n0\n9\n",
TEXNAME, sc->grpname[f->grp], ++fcnt);
for (i = 0; i < 3; i++) { /* then triangle */
Expand Down

0 comments on commit f8335c5

Please sign in to comment.