--- ray/src/common/mesh.h 2003/09/18 16:53:53 2.11 +++ ray/src/common/mesh.h 2011/05/20 02:06:38 2.14 @@ -1,4 +1,4 @@ -/* RCSid $Id: mesh.h,v 2.11 2003/09/18 16:53:53 greg Exp $ */ +/* RCSid $Id: mesh.h,v 2.14 2011/05/20 02:06:38 greg Exp $ */ /* * Header for compact triangle mesh geometry * @@ -13,8 +13,8 @@ extern "C" { #endif -#ifndef BYTE -#define BYTE unsigned char +#ifndef uby8 +#define uby8 unsigned char #endif /* @@ -30,10 +30,10 @@ extern "C" { * * Vertex ID's are encoded using the bottom 8 bits of a 4-byte integer * to index a vertex in a patch indicated by the 22 bits above (8-29). - * For triangle ID's, the top 22 bits (10-31) indicate the patch, and - * the bit 9 (0x200) indicates whether the triangle joins patches. + * For triangle ID's, the top 22 bits (10-31) indicate the parent patch, + * and the 10th bit (0x200) indicates whether the triangle joins patches. * If not, then the bottom 9 bits index into the local PTri array. - * If it's a joiner, then the 8th bit indicates whether the triangle joins + * If it's a joiner, then the 9th bit indicates whether the triangle joins * two patches, in which case the bottom 8 bits index the PJoin2 array. * Otherwise, the bottom 8 bits index the PJoin1 array. * @@ -43,28 +43,29 @@ extern "C" { * a lot of effort, but it can reduce mesh storage by a factor of 3 * or more. This is important, as the whole point is to model very * complicated geometry with this structure, and memory is the main - * limitation. + * limitation. (This representation is so efficient, that the octree + * structure ends up dominating memory for most compiled meshes.) */ /* A triangle mesh patch */ typedef struct { uint32 (*xyz)[3]; /* up to 256 patch vertices */ int32 *norm; /* vertex normals */ - uint16 (*uv)[2]; /* vertex local coordinates */ + uint32 (*uv)[2]; /* vertex local coordinates */ struct PTri { - BYTE v1, v2, v3; /* local vertices */ + uby8 v1, v2, v3; /* local vertices */ } *tri; /* local triangles */ short solemat; /* sole material */ int16 *trimat; /* or local material indices */ struct PJoin1 { int32 v1j; /* non-local vertex */ int16 mat; /* material index */ - BYTE v2, v3; /* local vertices */ + uby8 v2, v3; /* local vertices */ } *j1tri; /* joiner triangles */ struct PJoin2 { int32 v1j, v2j; /* non-local vertices */ int16 mat; /* material index */ - BYTE v3; /* local vertex */ + uby8 v3; /* local vertex */ } *j2tri; /* double joiner triangles */ short nverts; /* vertex count */ short ntris; /* local triangle count */ @@ -81,7 +82,7 @@ typedef struct mesh { RREAL uvlim[2][2]; /* local coordinate extrema */ OBJECT mat0; /* base material index */ OBJECT nmats; /* number of materials */ - MESHPATCH *patch; /* mesh patch list */ + MESHPATCH *patch; /* allocated mesh patch array */ int npatches; /* number of mesh patches */ OBJREC *pseudo; /* mesh pseudo objects */ LUTAB lut; /* vertex lookup table */ @@ -111,7 +112,7 @@ typedef struct { /* mesh format identifier */ #define MESHFMT "Radiance_tmesh" /* magic number for mesh files */ -#define MESHMAGIC ( 2 *MAXOBJSIZ+311) /* increment first value */ +#define MESHMAGIC ( 1 *MAXOBJSIZ+311) /* increment first value */ extern MESH *getmesh(char *mname, int flags); @@ -136,4 +137,3 @@ extern void writemesh(MESH *mp, FILE *fp); } #endif #endif /* _RAD_MESH_H_ */ -