ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/objutil.c
(Generate patch)

Comparing ray/src/common/objutil.c (file contents):
Revision 2.4 by greg, Fri May 1 18:55:34 2020 UTC vs.
Revision 2.5 by greg, Sat May 2 00:12:45 2020 UTC

# Line 599 | Line 599 | newScene(void)
599          return(sc);
600   }
601  
602 < /* Add a vertex to our scene */
602 > /* Add a vertex to a scene */
603   int
604   addVertex(Scene *sc, double x, double y, double z)
605   {
# Line 611 | Line 611 | addVertex(Scene *sc, double x, double y, double z)
611          return(sc->nverts++);
612   }
613  
614 < /* Add a texture coordinate to our scene */
614 > /* Add a texture coordinate to a scene */
615   int
616   addTexture(Scene *sc, double u, double v)
617   {
# Line 621 | Line 621 | addTexture(Scene *sc, double u, double v)
621          return(sc->ntex++);
622   }
623  
624 < /* Add a surface normal to our scene */
624 > /* Add a surface normal to a scene */
625   int
626   addNormal(Scene *sc, double xn, double yn, double zn)
627   {
# Line 655 | Line 655 | setMaterial(Scene *sc, const char *nm)
655                  return;
656          sc->matname = chunk_alloc(char *, sc->matname, sc->nmats);
657          sc->matname[sc->lastmat=sc->nmats++] = savqstr((char *)nm);
658 + }
659 +
660 + /* Add new face to a scene */
661 + Face *
662 + addFace(Scene *sc, VNDX vid[], int nv)
663 + {
664 +        Face    *f;
665 +        int     i;
666 +        
667 +        if (nv < 3)
668 +                return(NULL);
669 +        f = (Face *)emalloc(sizeof(Face)+sizeof(VertEnt)*(nv-3));
670 +        f->flags = 0;
671 +        f->nv = nv;
672 +        f->grp = sc->lastgrp;
673 +        f->mat = sc->lastmat;
674 +        for (i = 0; i < nv; i++) {              /* add each vertex */
675 +                int     j;
676 +                f->v[i].vid = vid[i][0];
677 +                f->v[i].tid = vid[i][1];
678 +                f->v[i].nid = vid[i][2];
679 +                f->v[i].fnext = NULL;
680 +                for (j = i; j-- > 0; )
681 +                        if (f->v[j].vid == vid[i][0])
682 +                                break;
683 +                if (j < 0) {                    /* first occurrence? */
684 +                        f->v[i].fnext = sc->vert[vid[i][0]].vflist;
685 +                        sc->vert[vid[i][0]].vflist = f;
686 +                } else if (nv == 3)             /* degenerate triangle? */
687 +                        f->flags |= FACE_DEGENERATE;
688 +        }
689 +        f->next = sc->flist;                    /* push onto face list */
690 +        sc->flist = f;
691 +        sc->nfaces++;
692 +                                                /* check face area */
693 +        if (!(f->flags & FACE_DEGENERATE) && faceArea(sc, f, NULL) <= FTINY)
694 +                f->flags |= FACE_DEGENERATE;
695 +        return(f);
696   }
697  
698   /* Duplicate a scene */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines