]> git.xonotic.org Git - xonotic/darkplaces.git/blob - curves.h
.gitignore: add kdevelop files
[xonotic/darkplaces.git] / curves.h
1 #ifndef CURVES_H
2 #define CURVES_H
3
4 #define PATCH_LODS_NUM 2
5 #define PATCH_LOD_COLLISION 0
6 #define PATCH_LOD_VISUAL 1
7
8 typedef struct patchinfo_s
9 {
10         int xsize, ysize;
11         struct {
12                 int xtess, ytess;
13         } lods[PATCH_LODS_NUM];
14 } patchinfo_t;
15
16 // Calculate number of resulting vertex rows/columns by given patch size and tesselation factor
17 // When tess=0 it means that we reduce detalization of base 3x3 patches by removing middle row and column
18 // "DimForTess" is "DIMension FOR TESSelation factor"
19 int Q3PatchDimForTess(int size, int tess);
20
21 // usage:
22 // to expand a 5x5 patch to 21x21 vertices (4x4 tesselation), one might use this call:
23 // Q3PatchSubdivideFloat(3, sizeof(float[3]), outvertices, 5, 5, sizeof(float[3]), patchvertices, 4, 4);
24 void Q3PatchTesselateFloat(int numcomponents, int outputstride, float *outputvertices, int patchwidth, int patchheight, int inputstride, float *patchvertices, int tesselationwidth, int tesselationheight);
25 // returns how much tesselation of each segment is needed to remain under tolerance
26 int Q3PatchTesselationOnX(int patchwidth, int patchheight, int components, const float *in, float tolerance);
27 // returns how much tesselation of each segment is needed to remain under tolerance
28 int Q3PatchTesselationOnY(int patchwidth, int patchheight, int components, const float *in, float tolerance);
29 // calculates elements for a grid of vertices
30 // (such as those produced by Q3PatchTesselate)
31 // (note: width and height are the actual vertex size, this produces
32 //  (width-1)*(height-1)*2 triangles, 3 elements each)
33 void Q3PatchTriangleElements(int *elements, int width, int height, int firstvertex);
34
35 int Q3PatchAdjustTesselation(int numcomponents, patchinfo_t *patch1, float *patchvertices1, patchinfo_t *patch2, float *patchvertices2);
36
37 #endif
38