]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_poly.h
lighthalf related transpoly cleanup
[xonotic/darkplaces.git] / gl_poly.h
index b25a1b3f7acb396779215e27c43b610258fc2423..53d6d81327bbf1b0efdbc32ac63f087e5a3198b3 100644 (file)
--- a/gl_poly.h
+++ b/gl_poly.h
@@ -18,8 +18,8 @@ extern void skypolyend();
 
 #define MAX_TRANSPOLYS 8192
 #define MAX_TRANSVERTS (MAX_TRANSPOLYS*4)
-#define MAX_WALLPOLYS 16384
-#define MAX_WALLVERTS (MAX_WALLPOLYS*4)
+#define MAX_WALLPOLYS 65536
+#define MAX_WALLVERTS (MAX_WALLPOLYS*3)
 #define MAX_SKYPOLYS 2048
 #define MAX_SKYVERTS (MAX_SKYPOLYS*4)
 
@@ -32,8 +32,8 @@ typedef struct
 
 typedef struct
 {
-       vec_t mindistance, maxdistance; // closest and farthest distance along v_forward
-       vec_t distance; // distance to center
+//     vec_t mindistance, maxdistance; // closest and farthest distance along v_forward
+//     vec_t distance; // distance to center
 //     vec3_t n; // normal
 //     vec_t ndist; // distance from origin along that normal
        unsigned short texnum;
@@ -48,13 +48,15 @@ typedef struct
 {
        vec3_t vert;
        vec_t s, t, u, v;
+       byte r,g,b,a;
 } wallvert_t;
 
 typedef struct
 {
        unsigned short texnum, lighttexnum, glowtexnum;
        unsigned short firstvert;
-       unsigned short verts;
+       unsigned short numverts;
+       unsigned short lit; // doesn't need to be an unsigned short, but to keep the structure consistent...
 } wallpoly_t;
 
 typedef struct
@@ -83,15 +85,37 @@ extern unsigned short currentwallvert;
 extern unsigned short currentskypoly;
 extern unsigned short currentskyvert;
 
+#define transpolybegin(ttexnum, tglowtexnum, tfogtexnum, ttranspolytype)\
+{\
+       if (currenttranspoly < MAX_TRANSPOLYS && currenttransvert < MAX_TRANSVERTS)\
+       {\
+               transpoly[currenttranspoly].texnum = (unsigned short) (ttexnum);\
+               transpoly[currenttranspoly].glowtexnum = (unsigned short) (tglowtexnum);\
+               transpoly[currenttranspoly].fogtexnum = (unsigned short) (tfogtexnum);\
+               transpoly[currenttranspoly].transpolytype = (unsigned short) (ttranspolytype);\
+               transpoly[currenttranspoly].firstvert = currenttransvert;\
+               transpoly[currenttranspoly].verts = 0;\
+       }\
+}
+
 #define transpolyvert(vx,vy,vz,vs,vt,vr,vg,vb,va) \
 {\
        if (currenttranspoly < MAX_TRANSPOLYS && currenttransvert < MAX_TRANSVERTS)\
        {\
                transvert[currenttransvert].s = (vs);\
                transvert[currenttransvert].t = (vt);\
-               transvert[currenttransvert].r = (byte) (bound(0, (int) (vr), 255));\
-               transvert[currenttransvert].g = (byte) (bound(0, (int) (vg), 255));\
-               transvert[currenttransvert].b = (byte) (bound(0, (int) (vb), 255));\
+               if (lighthalf)\
+               {\
+                       transvert[currenttransvert].r = (byte) (bound(0, (int) (vr) >> 1, 255));\
+                       transvert[currenttransvert].g = (byte) (bound(0, (int) (vg) >> 1, 255));\
+                       transvert[currenttransvert].b = (byte) (bound(0, (int) (vb) >> 1, 255));\
+               }\
+               else\
+               {\
+                       transvert[currenttransvert].r = (byte) (bound(0, (int) (vr), 255));\
+                       transvert[currenttransvert].g = (byte) (bound(0, (int) (vg), 255));\
+                       transvert[currenttransvert].b = (byte) (bound(0, (int) (vb), 255));\
+               }\
                transvert[currenttransvert].a = (byte) (bound(0, (int) (va), 255));\
                transvert[currenttransvert].v[0] = (vx);\
                transvert[currenttransvert].v[1] = (vy);\