Permalink
Browse files

renderer2: hello foliage vbo/ibo refs #552

  • Loading branch information...
IR4T4 committed Jan 11, 2018
1 parent 13a0549 commit 1f1f49019e914bd96e6122a71476122f725112a3
Showing with 55 additions and 2 deletions.
  1. +37 −1 src/renderer2/tr_bsp.c
  2. +6 −1 src/renderer2/tr_local.h
  3. +12 −0 src/renderer2/tr_surface.c
View
@@ -1039,7 +1039,7 @@ static void R_LoadVisibility(lump_t *l)
Ren_Developer("...loading visibility\n");
len = (s_worldData.numClusters + 63) & ~63;
len = PAD(s_worldData.numClusters, 64);
s_worldData.novis = (byte *)ri.Hunk_Alloc(len, h_low);
Com_Memset(s_worldData.novis, 0xff, len);
@@ -3183,6 +3183,8 @@ static void R_CreateClusters()
/**
* @brief R_CreateWorldVBO
*
* @todo FIXME: adjust for foliage (consider foliage instances/triangles. adjust positions)
*/
static void R_CreateWorldVBO()
{
@@ -3243,6 +3245,15 @@ static void R_CreateWorldVBO()
numTriangles += tri->numTriangles;
}
}
else if (*surface->data == SF_FOLIAGE)
{
srfFoliage_t *fol = (srfFoliage_t *) surface->data;
if (fol->numVerts)
{
numVerts += fol->numVerts;
}
}
}
if (!numVerts || !numTriangles)
@@ -3395,6 +3406,24 @@ static void R_CreateWorldVBO()
CopyVert(&srf->verts[i], &verts[numVerts + i]);
}
numVerts += srf->numVerts;
}
}
else if (*surface->data == SF_FOLIAGE)
{
srfFoliage_t *srf = (srfFoliage_t *) surface->data;
//srf->firstVert = numVerts;
// FIXME: 'instances are just additional drawverts' see ParseFoliage
if (srf->numVerts)
{
//for (i = 0; i < srf->numVerts; i++)
//{
// CopyVert(&srf->verts[i], &verts[numVerts + i]);
//}
numVerts += srf->numVerts;
}
}
@@ -3460,6 +3489,13 @@ static void R_CreateWorldVBO()
//srf->ibo = R_CreateIBO2(va("staticBspModel0_triangleSurface_IBO %i", k), srf->numTriangles, triangles + srf->firstTriangle, VBO_USAGE_STATIC);
}
}
else if (*surface->data == SF_FOLIAGE)
{
srfFoliage_t *srf = (srfFoliage_t *) surface->data;
srf->vbo = s_worldData.vbo;
srf->ibo = s_worldData.ibo;
}
}
// FIXME move this to somewhere else?
View
@@ -2439,13 +2439,14 @@ typedef struct
cplane_t plane;
// dynamic lighting information
int dlightBits;
//int dlightBits;
// triangle definitions
int numIndexes;
glIndex_t *indexes;
int numVerts;
// srfVert_t *verts;
vec4_t *xyz;
vec4_t *normal;
vec2_t *texCoords;
@@ -2454,6 +2455,10 @@ typedef struct
// origins
int numInstances;
foliageInstance_t *instances;
// static render data
VBO_t *vbo;
IBO_t *ibo;
} srfFoliage_t;
/**
View
@@ -1261,6 +1261,18 @@ static void Tess_SurfaceFoliage(srfFoliage_t *srf)
// int dlightBits;
foliageInstance_t *instance;
// FIXME: r_vboFoliage ?
if (srf->vbo && srf->ibo && !ShaderRequiresCPUDeforms(tess.surfaceShader))
{
Tess_DrawCurrent();
R_BindVBO(srf->vbo);
R_BindIBO(srf->ibo);
tess.multiDrawPrimitives++;
return;
}
// calculate distance vector
VectorSubtract(backEnd.orientation.origin, backEnd.viewParms.orientation.origin, local);
distanceVector[0] = -backEnd.orientation.transformMatrix[2];

0 comments on commit 1f1f490

Please sign in to comment.