]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_brush.h
surfvertex_t is gone, in it's place are non-interleaved arrays, which keeps things...
[xonotic/darkplaces.git] / model_brush.h
index fc79e4c0c6b3bd0b5188549b09a431b2c8cf5f80..36d0a605c10540ca983fc6565c4832076b098a16 100644 (file)
@@ -18,6 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */
 
+#ifndef MODEL_BRUSH_H
+#define MODEL_BRUSH_H
+
 /*
 ==============================================================================
 
@@ -54,28 +57,38 @@ mplane_t;
 
 typedef struct texture_s
 {
-       char                            name[16];
-       unsigned                        width, height;
-       int                                     flags;                          // LordHavoc: SURF_ flags
-
-       rtexture_t                      *texture;
-       rtexture_t                      *glowtexture;
-       rtexture_t                      *fogtexture;            // alpha-only version of main texture
-
-       int                                     anim_total;                     // total frames in sequence (< 2 = not animated)
-       struct texture_s        *anim_frames[10];       // LordHavoc: direct pointers to each of the frames in the sequence
-       struct texture_s        *alternate_anims;       // bmodels in frame 1 use these
+       // name
+       char name[16];
+       // size
+       unsigned int width, height;
+       // SURF_ flags
+       unsigned int flags;
+
+       // base texture without fullbrights, never NULL
+       rtexture_t *texture;
+       // fullbrights texture, NULL if no fullbrights used
+       rtexture_t *glowtexture;
+       // alpha texture (used for fogging), NULL if opaque
+       rtexture_t *fogtexture;
+       // detail texture (usually not used if transparent)
+       rtexture_t *detailtexture;
+
+       // total frames in sequence and alternate sequence
+       int anim_total[2];
+       // direct pointers to each of the frames in the sequences
+       // (indexed as [alternate][frame])
+       struct texture_s *anim_frames[2][10];
+       // set if animated or there is an alternate frame set
+       // (this is an optimization in the renderer)
+       int animated;
 }
 texture_t;
 
 
 #define        SURF_PLANEBACK          2
 #define        SURF_DRAWSKY            4
-//#define SURF_DRAWSPRITE              8
 #define SURF_DRAWTURB          0x10
 #define SURF_LIGHTMAP          0x20
-//#define SURF_DRAWBACKGROUND  0x40
-//#define SURF_UNDERWATER              0x80
 #define SURF_DRAWNOALPHA       0x100
 #define SURF_DRAWFULLBRIGHT    0x200
 #define SURF_LIGHTBOTHSIDES    0x400
@@ -95,25 +108,18 @@ typedef struct
 }
 mtexinfo_t;
 
-typedef struct surfvertex_s
-{
-       // position
-       float v[3];
-       // offset into lightmap (used by vertex lighting)
-       int lightmapoffset;
-       // texture coordinates
-       float st[2];
-       // lightmap coordinates
-       float uv[2];
-}
-surfvertex_t;
-
 // LordHavoc: replaces glpoly, triangle mesh
 typedef struct surfmesh_s
 {
+       // can be multiple meshs per surface
+       struct surfmesh_s *chain;
        int numverts;
        int numtriangles;
-       surfvertex_t *vertex;
+       float *verts;
+       int *lightmapoffsets;
+       float *st;
+       float *uv;
+       float *ab;
        int *index;
 }
 surfmesh_t;
@@ -122,6 +128,10 @@ typedef struct msurface_s
 {
        // should be drawn if visframe == r_framecount (set by WorldNode functions)
        int                     visframe;
+       // should be drawn if onscreen and not a backface (used for setting visframe)
+       int                     pvsframe;
+       // chain of surfaces marked visible by pvs
+       struct msurface_s       *pvschain;
 
        // the node plane this is on, backwards if SURF_PLANEBACK flag set
        mplane_t        *plane;
@@ -141,9 +151,11 @@ typedef struct msurface_s
        texture_t       *currenttexture; // updated (animated) during early surface processing each frame
 
        // index into d_lightstylevalue array, 255 means not used (black)
-       byte            styles[MAXLIGHTMAPS];
+       qbyte           styles[MAXLIGHTMAPS];
        // RGB lighting data [numstyles][height][width][3]
-       byte            *samples;
+       qbyte           *samples;
+       // stain to apply on lightmap (soot/dirt/blood/whatever)
+       qbyte           *stainsamples;
 
        // these fields are generated during model loading
        // the lightmap texture fragment to use on the surface
@@ -151,12 +163,14 @@ typedef struct msurface_s
        // the stride when building lightmaps to comply with fragment update
        int                     lightmaptexturestride;
        // mesh for rendering
-       surfmesh_t      mesh;
+       surfmesh_t      *mesh;
 
        // these are just 3D points defining the outline of the polygon,
        // no texcoord info (that can be generated from these)
        int                     poly_numverts;
        float           *poly_verts;
+       // bounding box for onscreen checks, and center for sorting
+       vec3_t          poly_mins, poly_maxs, poly_center;
 
        // these are regenerated every frame
        // lighting info
@@ -166,15 +180,13 @@ typedef struct msurface_s
        int                     lightframe;
        // only render each surface once
        int                     worldnodeframe;
-       // marked when surface is prepared for the frame
-       int                     insertframe;
 
        // these cause lightmap updates if regenerated
        // values currently used in lightmap
        unsigned short cached_light[MAXLIGHTMAPS];
        // if lightmap was lit by dynamic lights, force update on next frame
        short           cached_dlight;
-       // to cause lightmap to be rerendered when lighthalf changes
+       // to cause lightmap to be rerendered when v_overbrightbits changes
        short           cached_lightscalebit;
        // rerender lightmaps when r_ambient changes
        float           cached_ambient;
@@ -183,13 +195,13 @@ msurface_t;
 
 #define SHADERSTAGE_SKY 0
 #define SHADERSTAGE_NORMAL 1
-#define SHADERSTAGE_FOG 2
-#define SHADERSTAGE_COUNT 3
+#define SHADERSTAGE_COUNT 2
 
+struct entity_render_s;
 // change this stuff when real shaders are added
 typedef struct Cshader_s
 {
-       int (*shaderfunc[SHADERSTAGE_COUNT])(int stage, msurface_t *s);
+       void (*shaderfunc[SHADERSTAGE_COUNT])(const struct entity_render_s *ent, const msurface_t *firstsurf);
        // list of surfaces using this shader (used during surface rendering)
        msurface_t *chain;
 }
@@ -236,19 +248,15 @@ typedef struct mleaf_s
        vec3_t                          maxs;
 
 // leaf specific
-       int                                     visframe;               // visible if current (r_framecount)
+       int                                     pvsframe;               // potentially visible if current (r_pvsframecount)
        int                                     worldnodeframe; // used by certain worldnode variants to avoid processing the same leaf twice in a frame
        int                                     portalmarkid;   // used by polygon-through-portals visibility checker
 
-       // LordHavoc: leaf based dynamic lighting
-       int                                     dlightbits[8];
-       int                                     dlightframe;
-
-       byte                            *compressed_vis;
+       qbyte                           *compressed_vis;
 
        msurface_t                      **firstmarksurface;
        int                                     nummarksurfaces;
-       byte                            ambient_sound_level[NUM_AMBIENTS];
+       qbyte                           ambient_sound_level[NUM_AMBIENTS];
 }
 mleaf_t;
 
@@ -260,6 +268,7 @@ typedef struct
        int                     lastclipnode;
        vec3_t          clip_mins;
        vec3_t          clip_maxs;
+       vec3_t          clip_size;
 }
 hull_t;
 
@@ -275,10 +284,31 @@ typedef struct mportal_s
 }
 mportal_t;
 
+typedef struct mlight_s
+{
+       vec3_t origin;
+       float falloff;
+       vec3_t light;
+       float subtract;
+       vec3_t spotdir;
+       float spotcone; // cosine of spotlight cone angle (or 0 if not a spotlight)
+       float distbias;
+       int style;
+       int numleafs; // used only for loading calculations, number of leafs this shines on
+}
+mlight_t;
+
 extern rtexture_t *r_notexture;
 extern texture_t r_notexture_mip;
 
 struct model_s;
 void Mod_LoadBrushModel (struct model_s *mod, void *buffer);
 void Mod_BrushInit(void);
+
 void Mod_FindNonSolidLocation(vec3_t pos, struct model_s *mod);
+mleaf_t *Mod_PointInLeaf (const float *p, struct model_s *model);
+int Mod_PointContents (const float *p, struct model_s *model);
+qbyte *Mod_LeafPVS (mleaf_t *leaf, struct model_s *model);
+
+#endif
+