29 #define GRASS_MARK -956
31 #define TRIS_PER_CLUMP 10
32 #define MAX_CLUMPS 2046
34 #define MAX_CLUMP_TRIS (TRIS_PER_CLUMP * MAX_CLUMPS)
126 sprrot[0] =
frand() * 360;
127 sprrot[1] =
frand() * 60 + 15;
157 VectorMA(ptr + 3, 48, sdir, ptr + 6);
161 VectorMA(ptr + 6, -32, tdir, ptr + 15);
201 const Clump* pa = static_cast <
const Clump*>(a);
202 const Clump* pb = static_cast <
const Clump*>(b);
204 if (pa->
level != pb->level)
205 return pa->
level - pb->level;
215 int lastLevel = 0,
i;
217 while (lastLevel < clumps[
i].
level) {
230 float density = 1.0f;
245 for (
int j = 0; j < header->
numfaces; j++) {
259 if (plane->
normal[2] < 0.5f)
263 double surfArea = 0.0;
267 const int indo = bspModel->
indexes[vofs] & 0xffff;
268 const int inda = bspModel->
indexes[vofs + 1] & 0xffff;
269 const int indb = bspModel->
indexes[vofs + 2] & 0xffff;
291 Com_Printf(
"Total grassy area is %7.0f units (%i cells)\n", area / 2, (
int)(area / 2048));
294 if (areaPerClump < 2048 / (density * density))
295 areaPerClump = 2048 / (density * density);
299 double clumpsToPlant = 0.0;
314 if (!
i || ((1 << level) &
i))
317 for (
int j = 0; j < header->
numfaces; j++) {
329 const int indo = bspModel->
indexes[vofs] & 0xffff;
330 const int inda = bspModel->
indexes[vofs + 1] & 0xffff;
331 const int indb = bspModel->
indexes[vofs + 2] & 0xffff;
344 while (clumpsToPlant >= 1.0) {
364 clumpsToPlant -= 1.0;
383 int lastClumpCount = 0;
388 const Clump& clump = clumps[lastClumpCount - 1];
392 Com_Printf(
"%i triangles for level %i (%i clumps)\n", triangles, i + 1, lastClumpCount);
396 Com_Printf(
"Planted %i clumps of grass\n", planted);
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
static int clumpsForLevel[PATHFINDING_HEIGHT]
#define VectorCopy(src, dest)
#define VectorSet(v, x, y, z)
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb)
static void R_OrganizeClumps()
static int clumpTrianglesForLevel[PATHFINDING_HEIGHT]
static int ClumpOrder(const void *a, const void *b)
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
model_t * r_mapTiles[MAX_MAPTILES]
The world model(s)
void R_EnableAlphaTest(bool enable)
#define LEVEL_LASTVISIBLE
void VectorInverse(vec3_t v)
Inverse a vector.
unsigned int numTriangles
void CrossProduct(const vec3_t v1, const vec3_t v2, vec3_t cross)
binary operation on vectors in a three-dimensional space
local graphics definitions
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
Rotate a point around a given vector.
void Com_Printf(const char *const fmt,...)
void VectorNormalizeFast(vec3_t v)
fast vector normalize routine that does not check to make sure that length != 0, nor does it return l...
static vec2_t gfv_texcoord[MAX_CLUMP_TRIS *3]
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
glElementIndex_t * indexes
static void R_AddClump(const vec3_t pos, const vec3_t normal, int level)
#define Vector2Set(v, x, y)
void PolarToVec(const vec2_t a, vec3_t v)
Converts longitude and latitude to a 3D vector in Euclidean coordinates.
static vec3_t gfv_pos[MAX_CLUMP_TRIS *3]
void R_BindDefaultArray(GLenum target)
Binds the appropriate shared vertex array to the specified target.
static void R_PlantGrass(Clump &clump)
static int clumpTriangleCount
Pseudoinstanced grass generation and rendering.
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
float frand(void)
Return random values between 0 and 1.
void VectorRotate(vec3_t m[3], const vec3_t va, vec3_t vb)
Rotate a vector with a rotation matrix.
QGL_EXTERN int GLboolean GLfloat * v
#define VectorSubtract(a, b, dest)
#define R_BindTexture(tn)
static Clump clumps[MAX_CLUMPS]
void R_BindArray(GLenum target, GLenum type, const void *array)