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.9 by greg, Wed Jun 24 01:16:09 2020 UTC

# Line 19 | Line 19 | static const char RCSid[] = "$Id$";
19   int
20   findName(const char *nm, const char **nmlist, int n)
21   {
22 <        register int    i;
22 >        int    i;
23          
24          for (i = n; i-- > 0; )
25                  if (!strcmp(nmlist[i], nm))
# Line 322 | Line 322 | replace_vertex(Scene *sc, int prev, int repl, double e
322                          goto linkerr;
323                  /* XXX doesn't allow for multiple references to prev in face */
324                  f->v[j].vid = repl;     /* replace vertex itself */
325 <                if (faceArea(sc, f, NULL) <= FTINY)
325 >                if (faceArea(sc, f, NULL) <= FTINY*FTINY)
326                          f->flags |= FACE_DEGENERATE;
327                  if (f->v[j].tid >= 0)   /* replace texture if appropriate */
328                          for (i = 0; repl_tex[i] >= 0; i++) {
# Line 547 | Line 547 | addComment(Scene *sc, const char *comment)
547          sc->descr[sc->ndescr++] = savqstr((char *)comment);
548   }
549  
550 + /* Find index for comment containing the given string (starting from n) */
551 + int
552 + findComment(Scene *sc, const char *match, int n)
553 + {
554 +        if (n >= sc->ndescr)
555 +                return(-1);
556 +        n *= (n > 0);
557 +        while (n < sc->ndescr)
558 +                if (strstr(sc->descr[n], match) != NULL)
559 +                        return(n);
560 +        return(-1);
561 + }
562 +
563   /* Clear comments */
564   void
565   clearComments(Scene *sc)
# Line 599 | Line 612 | newScene(void)
612          return(sc);
613   }
614  
615 < /* Add a vertex to our scene */
615 > /* Add a vertex to a scene */
616   int
617   addVertex(Scene *sc, double x, double y, double z)
618   {
# Line 611 | Line 624 | addVertex(Scene *sc, double x, double y, double z)
624          return(sc->nverts++);
625   }
626  
627 < /* Add a texture coordinate to our scene */
627 > /* Add a texture coordinate to a scene */
628   int
629   addTexture(Scene *sc, double u, double v)
630   {
# Line 621 | Line 634 | addTexture(Scene *sc, double u, double v)
634          return(sc->ntex++);
635   }
636  
637 < /* Add a surface normal to our scene */
637 > /* Add a surface normal to a scene */
638   int
639   addNormal(Scene *sc, double xn, double yn, double zn)
640   {
# Line 657 | Line 670 | setMaterial(Scene *sc, const char *nm)
670          sc->matname[sc->lastmat=sc->nmats++] = savqstr((char *)nm);
671   }
672  
673 + /* Add new face to a scene */
674 + Face *
675 + addFace(Scene *sc, VNDX vid[], int nv)
676 + {
677 +        Face    *f;
678 +        int     i;
679 +        
680 +        if (nv < 3)
681 +                return(NULL);
682 +        f = (Face *)emalloc(sizeof(Face)+sizeof(VertEnt)*(nv-3));
683 +        f->flags = 0;
684 +        f->nv = nv;
685 +        f->grp = sc->lastgrp;
686 +        f->mat = sc->lastmat;
687 +        for (i = 0; i < nv; i++) {              /* add each vertex */
688 +                int     j;
689 +                f->v[i].vid = vid[i][0];
690 +                f->v[i].tid = vid[i][1];
691 +                f->v[i].nid = vid[i][2];
692 +                f->v[i].fnext = NULL;
693 +                for (j = i; j-- > 0; )
694 +                        if (f->v[j].vid == vid[i][0])
695 +                                break;
696 +                if (j < 0) {                    /* first occurrence? */
697 +                        f->v[i].fnext = sc->vert[vid[i][0]].vflist;
698 +                        sc->vert[vid[i][0]].vflist = f;
699 +                } else if (nv == 3)             /* degenerate triangle? */
700 +                        f->flags |= FACE_DEGENERATE;
701 +        }
702 +        f->next = sc->flist;                    /* push onto face list */
703 +        sc->flist = f;
704 +        sc->nfaces++;
705 +                                                /* check face area */
706 +        if (!(f->flags & FACE_DEGENERATE) && faceArea(sc, f, NULL) <= FTINY*FTINY)
707 +                f->flags |= FACE_DEGENERATE;
708 +        return(f);
709 + }
710 +
711   /* Duplicate a scene */
712   Scene *
713   dupScene(const Scene *osc)
# Line 722 | Line 773 | dupScene(const Scene *osc)
773          return(sc);
774   }
775  
776 + #define MAXAC   100
777 +
778   /* Transform entire scene */
779   int
780   xfScene(Scene *sc, int xac, char *xav[])
781   {
782 +        char    comm[24+MAXAC*8];
783 +        char    *cp;
784          XF      myxf;
785          FVECT   vec;
786          int     i;
# Line 748 | Line 803 | xfScene(Scene *sc, int xac, char *xav[])
803                  vec[0] /= myxf.sca; vec[1] /= myxf.sca; vec[2] /= myxf.sca;
804                  VCOPY(sc->norm[i], vec);
805          }
806 +                                        /* add comment */
807 +        cp = strcpy(comm, "Transformed by:");
808 +        for (i = 0; i < xac; i++) {
809 +                while (*cp) cp++;
810 +                *cp++ = ' ';
811 +                strcpy(cp, xav[i]);
812 +        }
813 +        addComment(sc, comm);
814          return(xac);                    /* all done */
815   }
816  
817   /* Ditto, using transform string rather than pre-parsed words */
755 #define MAXAC   100
818   int
819   xfmScene(Scene *sc, const char *xfm)
820   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines