Back to index

radiance  4R0+20100331
Functions | Variables
o_instance.c File Reference
#include "standard.h"
#include "object.h"
#include "octree.h"
#include "instance.h"
#include "mesh.h"
#include "plocate.h"

Go to the source code of this file.

Functions

static int o_cube (CUBE *cu1, FULLXF *fxf, CUBE *cu)
int o_instance (OBJREC *o, CUBE *cu)
int o_mesh (OBJREC *o, CUBE *cu)

Variables

static const char RCSid [] = "$Id: o_instance.c,v 2.6 2004/03/30 16:13:00 schorsch Exp $"

Function Documentation

static int o_cube ( CUBE cu1,
FULLXF fxf,
CUBE cu 
) [static]

Definition at line 47 of file o_instance.c.

{
       static int  vstart[4] = {0, 3, 5, 6};
       FVECT  cumin, cumax;
       FVECT  vert[8];
       FVECT  v1, v2;
       int  vloc, vout;
       register int  i, j;
                                   /* check if cube vertex in octree */
       for (j = 0; j < 3; j++)
              cumax[j] = (cumin[j] = cu1->cuorg[j]) + cu1->cusize;
       vloc = ABOVE | BELOW;
       vout = 0;
       for (i = 0; i < 8; i++) {
              for (j = 0; j < 3; j++) {
                     v1[j] = cu->cuorg[j];
                     if (i & 1<<j)
                            v1[j] += cu->cusize;
              }
              multp3(v2, v1, fxf->b.xfm);
              if ( (j = plocate(v2, cumin, cumax)) )
                     vout++;
              vloc &= j;
       }
       if (vout == 0)                     /* all inside */
              return(O_IN);
       if (vout < 8)               /* some inside */
              return(O_HIT);
       if (vloc)                   /* all to one side */
              return(O_MISS);
                                   /* octree vertices in cube? */
       for (j = 0; j < 3; j++)
              cumax[j] = (cumin[j] = cu->cuorg[j]) + cu->cusize;
       vloc = ABOVE | BELOW;
       for (i = 0; i < 8; i++) {
              for (j = 0; j < 3; j++) {
                     v1[j] = cu1->cuorg[j];
                     if (i & 1<<j)
                            v1[j] += cu1->cusize;
              }
              multp3(vert[i], v1, fxf->f.xfm);
              if ( (j = plocate(vert[i], cumin, cumax)) )
                     vloc &= j;
              else
                     return(O_HIT);       /* vertex inside */
       }
       if (vloc)                   /* all to one side */
              return(O_MISS);
                                   /* check edges */
       for (i = 0; i < 4; i++)
              for (j = 0; j < 3; j++) {
                                          /* clip modifies vertices! */
                     VCOPY(v1, vert[vstart[i]]);
                     VCOPY(v2, vert[vstart[i] ^ 1<<j]);
                     if (clip(v1, v2, cumin, cumax))
                            return(O_HIT);              /* edge inside */
              }

       return(O_MISS);                    /* no intersection */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int o_instance ( OBJREC o,
CUBE cu 
)

Definition at line 114 of file o_instance.c.

{
       INSTANCE  *ins;
                                   /* get octree bounds */
       ins = getinstance(o, IO_BOUNDS);
                                   /* call o_cube to do the work */
       return(o_cube(&ins->obj->scube, &ins->x, cu));
}

Here is the call graph for this function:

int o_mesh ( OBJREC o,
CUBE cu 
)

Definition at line 128 of file o_instance.c.

{
       MESHINST      *mip;
                                   /* get mesh bounds */
       mip = getmeshinst(o, IO_BOUNDS);
                                   /* call o_cube to do the work */
       return(o_cube(&mip->msh->mcube, &mip->x, cu));
}

Here is the call graph for this function:


Variable Documentation

const char RCSid[] = "$Id: o_instance.c,v 2.6 2004/03/30 16:13:00 schorsch Exp $" [static]

Definition at line 2 of file o_instance.c.