2021-02-01 20:05:04 +01:00
|
|
|
#include "vk_brush.h"
|
2021-01-24 04:38:00 +01:00
|
|
|
|
2021-01-23 19:54:44 +01:00
|
|
|
#include "vk_core.h"
|
2021-02-01 20:05:04 +01:00
|
|
|
#include "vk_const.h"
|
2021-01-23 19:54:44 +01:00
|
|
|
#include "vk_buffer.h"
|
2021-01-24 04:38:00 +01:00
|
|
|
#include "vk_pipeline.h"
|
|
|
|
#include "vk_framectl.h"
|
|
|
|
#include "vk_math.h"
|
2021-01-30 21:10:54 +01:00
|
|
|
#include "vk_textures.h"
|
2021-01-31 00:31:23 +01:00
|
|
|
#include "vk_lightmap.h"
|
2021-02-01 20:05:04 +01:00
|
|
|
#include "vk_scene.h"
|
2021-02-08 19:57:27 +01:00
|
|
|
#include "vk_render.h"
|
2022-07-09 21:31:46 +02:00
|
|
|
#include "vk_geometry.h"
|
2021-04-12 20:07:41 +02:00
|
|
|
#include "vk_light.h"
|
2021-11-27 08:59:48 +01:00
|
|
|
#include "vk_mapents.h"
|
2023-01-30 05:53:18 +01:00
|
|
|
#include "vk_previous_frame.h"
|
2021-01-24 04:38:00 +01:00
|
|
|
|
|
|
|
#include "ref_params.h"
|
|
|
|
#include "eiface.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <memory.h>
|
2021-01-23 19:54:44 +01:00
|
|
|
|
2022-02-03 06:32:10 +01:00
|
|
|
typedef struct vk_brush_model_s {
|
|
|
|
vk_render_model_t render_model;
|
|
|
|
int num_water_surfaces;
|
|
|
|
} vk_brush_model_t;
|
|
|
|
|
2021-01-23 19:54:44 +01:00
|
|
|
static struct {
|
2021-02-10 19:33:44 +01:00
|
|
|
struct {
|
|
|
|
int num_vertices, num_indices;
|
|
|
|
} stat;
|
2021-02-10 01:42:08 +01:00
|
|
|
|
|
|
|
int rtable[MOD_FRAMES][MOD_FRAMES];
|
2021-02-06 20:38:08 +01:00
|
|
|
} g_brush;
|
2021-01-23 19:54:44 +01:00
|
|
|
|
2021-02-10 01:42:08 +01:00
|
|
|
void VK_InitRandomTable( void )
|
|
|
|
{
|
|
|
|
int tu, tv;
|
|
|
|
|
|
|
|
// make random predictable
|
|
|
|
gEngine.COM_SetRandomSeed( 255 );
|
|
|
|
|
|
|
|
for( tu = 0; tu < MOD_FRAMES; tu++ )
|
|
|
|
{
|
|
|
|
for( tv = 0; tv < MOD_FRAMES; tv++ )
|
|
|
|
{
|
|
|
|
g_brush.rtable[tu][tv] = gEngine.COM_RandomLong( 0, 0x7FFF );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gEngine.COM_SetRandomSeed( 0 );
|
|
|
|
}
|
|
|
|
|
2021-02-01 20:05:04 +01:00
|
|
|
qboolean VK_BrushInit( void )
|
2021-01-23 19:54:44 +01:00
|
|
|
{
|
2021-02-10 01:42:08 +01:00
|
|
|
VK_InitRandomTable ();
|
|
|
|
|
2021-01-23 19:54:44 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-02-01 20:05:04 +01:00
|
|
|
void VK_BrushShutdown( void )
|
2021-01-23 19:54:44 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-14 18:19:21 +02:00
|
|
|
// speed up sin calculations
|
|
|
|
static const float r_turbsin[] =
|
|
|
|
{
|
|
|
|
#include "warpsin.h"
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SUBDIVIDE_SIZE 64
|
|
|
|
#define TURBSCALE ( 256.0f / ( M_PI2 ))
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
EmitWaterPolys
|
|
|
|
|
|
|
|
Does a water warp on the pre-fragmented glpoly_t chain
|
|
|
|
=============
|
|
|
|
*/
|
|
|
|
static void EmitWaterPolys( const cl_entity_t *ent, const msurface_t *warp, qboolean reverse )
|
|
|
|
{
|
2021-06-14 20:22:07 +02:00
|
|
|
const float time = gpGlobals->time;
|
2021-06-14 18:19:21 +02:00
|
|
|
float *v, nv, waveHeight;
|
2023-01-22 00:45:29 +01:00
|
|
|
float prev_nv, prev_time;
|
2021-06-14 18:19:21 +02:00
|
|
|
float s, t, os, ot;
|
|
|
|
glpoly_t *p;
|
|
|
|
int i;
|
|
|
|
int num_vertices = 0, num_indices = 0;
|
|
|
|
int vertex_offset = 0;
|
|
|
|
uint16_t *indices;
|
2022-05-04 18:23:37 +02:00
|
|
|
r_geometry_buffer_lock_t buffer;
|
2021-06-14 18:19:21 +02:00
|
|
|
|
2023-01-30 05:53:18 +01:00
|
|
|
prev_time = R_PrevFrame_Time(ent->index);
|
2023-01-22 00:45:29 +01:00
|
|
|
|
2021-06-14 20:22:07 +02:00
|
|
|
#define MAX_WATER_VERTICES 16
|
|
|
|
vk_vertex_t poly_vertices[MAX_WATER_VERTICES];
|
|
|
|
|
2021-06-14 18:19:21 +02:00
|
|
|
const qboolean useQuads = FBitSet( warp->flags, SURF_DRAWTURB_QUADS );
|
|
|
|
|
|
|
|
if( !warp->polys ) return;
|
|
|
|
|
|
|
|
// set the current waveheight
|
|
|
|
// FIXME VK if( warp->polys->verts[0][2] >= RI.vieworg[2] )
|
|
|
|
// waveHeight = -ent->curstate.scale;
|
|
|
|
// else
|
|
|
|
waveHeight = ent->curstate.scale;
|
|
|
|
|
|
|
|
// reset fog color for nonlightmapped water
|
|
|
|
// FIXME VK GL_ResetFogColor();
|
|
|
|
|
|
|
|
// Compute vertex count
|
|
|
|
for( p = warp->polys; p; p = p->next ) {
|
|
|
|
const int triangles = p->numverts - 2;
|
|
|
|
num_vertices += p->numverts;
|
|
|
|
num_indices += triangles * 3;
|
|
|
|
}
|
|
|
|
|
2022-05-14 22:36:33 +02:00
|
|
|
if (!R_GeometryBufferAllocAndLock( &buffer, num_vertices, num_indices, LifetimeSingleFrame )) {
|
2022-05-04 18:23:37 +02:00
|
|
|
gEngine.Con_Printf(S_ERROR "Cannot allocate geometry for %s\n", ent->model->name );
|
2021-06-14 18:19:21 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-04 18:23:37 +02:00
|
|
|
indices = buffer.indices.ptr;
|
2021-06-14 18:19:21 +02:00
|
|
|
|
|
|
|
for( p = warp->polys; p; p = p->next )
|
|
|
|
{
|
2021-06-14 20:22:07 +02:00
|
|
|
ASSERT(p->numverts <= MAX_WATER_VERTICES);
|
|
|
|
|
2021-06-14 18:19:21 +02:00
|
|
|
if( reverse )
|
|
|
|
v = p->verts[0] + ( p->numverts - 1 ) * VERTEXSIZE;
|
|
|
|
else v = p->verts[0];
|
|
|
|
|
|
|
|
for( i = 0; i < p->numverts; i++ )
|
|
|
|
{
|
|
|
|
if( waveHeight )
|
|
|
|
{
|
2021-06-14 20:22:07 +02:00
|
|
|
nv = r_turbsin[(int)(time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
|
|
|
|
nv = (r_turbsin[(int)(v[0] * 5.0f + time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + nv;
|
2021-06-14 18:19:21 +02:00
|
|
|
nv = nv * waveHeight + v[2];
|
2023-01-22 00:45:29 +01:00
|
|
|
|
|
|
|
prev_nv = r_turbsin[(int)(prev_time * 160.0f + v[1] + v[0]) & 255] + 8.0f;
|
|
|
|
prev_nv = (r_turbsin[(int)(v[0] * 5.0f + prev_time * 171.0f - v[1]) & 255] + 8.0f ) * 0.8f + prev_nv;
|
|
|
|
prev_nv = prev_nv * waveHeight + v[2];
|
2021-06-14 18:19:21 +02:00
|
|
|
}
|
|
|
|
else nv = v[2];
|
|
|
|
|
|
|
|
os = v[3];
|
|
|
|
ot = v[4];
|
|
|
|
|
|
|
|
s = os + r_turbsin[(int)((ot * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
|
|
|
|
s *= ( 1.0f / SUBDIVIDE_SIZE );
|
|
|
|
|
|
|
|
t = ot + r_turbsin[(int)((os * 0.125f + gpGlobals->time) * TURBSCALE) & 255];
|
|
|
|
t *= ( 1.0f / SUBDIVIDE_SIZE );
|
|
|
|
|
2021-06-14 20:22:07 +02:00
|
|
|
poly_vertices[i].pos[0] = v[0];
|
|
|
|
poly_vertices[i].pos[1] = v[1];
|
|
|
|
poly_vertices[i].pos[2] = nv;
|
2021-06-14 18:19:21 +02:00
|
|
|
|
2023-01-22 00:45:29 +01:00
|
|
|
poly_vertices[i].prev_pos[0] = v[0];
|
|
|
|
poly_vertices[i].prev_pos[1] = v[1];
|
|
|
|
poly_vertices[i].prev_pos[2] = prev_nv;
|
|
|
|
|
2021-06-14 20:22:07 +02:00
|
|
|
poly_vertices[i].gl_tc[0] = s;
|
|
|
|
poly_vertices[i].gl_tc[1] = t;
|
2021-06-14 18:19:21 +02:00
|
|
|
|
2021-06-14 20:22:07 +02:00
|
|
|
poly_vertices[i].lm_tc[0] = 0;
|
|
|
|
poly_vertices[i].lm_tc[1] = 0;
|
2021-06-14 18:19:21 +02:00
|
|
|
|
2021-06-14 20:22:07 +02:00
|
|
|
#define WATER_NORMALS
|
|
|
|
poly_vertices[i].normal[0] = 0;
|
|
|
|
poly_vertices[i].normal[1] = 0;
|
|
|
|
#ifdef WATER_NORMALS
|
|
|
|
poly_vertices[i].normal[2] = 0;
|
|
|
|
#else
|
|
|
|
poly_vertices[i].normal[2] = 1;
|
|
|
|
#endif
|
2021-06-14 18:19:21 +02:00
|
|
|
|
|
|
|
// Ray tracing apparently expects triangle list only (although spec is not very clear about this kekw)
|
|
|
|
if (i > 1) {
|
2021-06-14 20:22:07 +02:00
|
|
|
#ifdef WATER_NORMALS
|
|
|
|
vec3_t e0, e1, normal;
|
|
|
|
VectorSubtract( poly_vertices[i - 1].pos, poly_vertices[0].pos, e0 );
|
|
|
|
VectorSubtract( poly_vertices[i].pos, poly_vertices[0].pos, e1 );
|
|
|
|
CrossProduct( e1, e0, normal );
|
|
|
|
//VectorNormalize(normal);
|
|
|
|
|
|
|
|
VectorAdd(normal, poly_vertices[0].normal, poly_vertices[0].normal);
|
|
|
|
VectorAdd(normal, poly_vertices[i].normal, poly_vertices[i].normal);
|
|
|
|
VectorAdd(normal, poly_vertices[i - 1].normal, poly_vertices[i - 1].normal);
|
|
|
|
#endif
|
2021-06-14 18:19:21 +02:00
|
|
|
*(indices++) = (uint16_t)(vertex_offset);
|
|
|
|
*(indices++) = (uint16_t)(vertex_offset + i - 1);
|
|
|
|
*(indices++) = (uint16_t)(vertex_offset + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( reverse )
|
|
|
|
v -= VERTEXSIZE;
|
2021-08-11 20:43:33 +02:00
|
|
|
else
|
|
|
|
v += VERTEXSIZE;
|
2021-06-14 18:19:21 +02:00
|
|
|
}
|
|
|
|
|
2021-06-14 20:22:07 +02:00
|
|
|
#ifdef WATER_NORMALS
|
|
|
|
for( i = 0; i < p->numverts; i++ ) {
|
|
|
|
VectorNormalize(poly_vertices[i].normal);
|
|
|
|
}
|
|
|
|
#endif
|
2021-06-14 18:19:21 +02:00
|
|
|
|
2022-05-04 18:23:37 +02:00
|
|
|
memcpy(buffer.vertices.ptr + vertex_offset, poly_vertices, sizeof(vk_vertex_t) * p->numverts);
|
2021-06-14 18:19:21 +02:00
|
|
|
vertex_offset += p->numverts;
|
|
|
|
}
|
|
|
|
|
2022-05-04 18:23:37 +02:00
|
|
|
R_GeometryBufferUnlock( &buffer );
|
2021-06-14 18:19:21 +02:00
|
|
|
|
|
|
|
// Render
|
|
|
|
{
|
|
|
|
const vk_render_geometry_t geometry = {
|
|
|
|
.texture = warp->texinfo->texture->gl_texturenum, // FIXME assert >= 0
|
2021-06-19 21:52:13 +02:00
|
|
|
.material = kXVkMaterialWater,
|
2021-09-14 19:20:15 +02:00
|
|
|
.surf = warp,
|
2021-06-14 18:19:21 +02:00
|
|
|
|
2021-08-18 18:17:48 +02:00
|
|
|
.max_vertex = num_vertices,
|
2022-05-04 18:23:37 +02:00
|
|
|
.vertex_offset = buffer.vertices.unit_offset,
|
2021-06-14 18:19:21 +02:00
|
|
|
|
|
|
|
.element_count = num_indices,
|
2022-05-04 18:23:37 +02:00
|
|
|
.index_offset = buffer.indices.unit_offset,
|
2021-06-14 18:19:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
VK_RenderModelDynamicAddGeometry( &geometry );
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME VK GL_SetupFogColorForSurfaces();
|
|
|
|
}
|
|
|
|
|
|
|
|
void XVK_DrawWaterSurfaces( const cl_entity_t *ent )
|
|
|
|
{
|
|
|
|
const model_t *model = ent->model;
|
2021-06-14 20:22:07 +02:00
|
|
|
vec3_t mins, maxs;
|
|
|
|
|
|
|
|
if( !VectorIsNull( ent->angles ))
|
|
|
|
{
|
|
|
|
for( int i = 0; i < 3; i++ )
|
|
|
|
{
|
|
|
|
mins[i] = ent->origin[i] - model->radius;
|
|
|
|
maxs[i] = ent->origin[i] + model->radius;
|
|
|
|
}
|
|
|
|
//rotated = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VectorAdd( ent->origin, model->mins, mins );
|
|
|
|
VectorAdd( ent->origin, model->maxs, maxs );
|
|
|
|
//rotated = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if( R_CullBox( mins, maxs ))
|
|
|
|
// return;
|
|
|
|
|
2021-09-14 19:20:15 +02:00
|
|
|
VK_RenderModelDynamicBegin( ent->curstate.rendermode, "%s water", model->name );
|
2021-06-14 18:19:21 +02:00
|
|
|
|
|
|
|
// Iterate through all surfaces, find *TURB*
|
|
|
|
for( int i = 0; i < model->nummodelsurfaces; i++ )
|
|
|
|
{
|
|
|
|
const msurface_t *surf = model->surfaces + model->firstmodelsurface + i;
|
|
|
|
|
|
|
|
if( !FBitSet( surf->flags, SURF_DRAWTURB ) && !FBitSet( surf->flags, SURF_DRAWTURB_QUADS) )
|
|
|
|
continue;
|
|
|
|
|
2021-06-14 18:44:35 +02:00
|
|
|
if( surf->plane->type != PLANE_Z && !FBitSet( ent->curstate.effects, EF_WATERSIDES ))
|
|
|
|
continue;
|
|
|
|
|
2021-06-14 20:22:07 +02:00
|
|
|
if( mins[2] + 1.0f >= surf->plane->dist )
|
|
|
|
continue;
|
2021-06-14 18:44:35 +02:00
|
|
|
|
2021-06-14 18:19:21 +02:00
|
|
|
EmitWaterPolys( ent, surf, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
// submit as dynamic model
|
|
|
|
VK_RenderModelDynamicCommit();
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// - upload water geometry only once, animate in compute/vertex shader
|
|
|
|
}
|
|
|
|
|
2021-02-10 01:42:08 +01:00
|
|
|
/*
|
|
|
|
===============
|
|
|
|
R_TextureAnimation
|
|
|
|
|
|
|
|
Returns the proper texture for a given time and surface
|
|
|
|
===============
|
|
|
|
*/
|
2021-12-23 08:45:47 +01:00
|
|
|
const texture_t *R_TextureAnimation( const cl_entity_t *ent, const msurface_t *s, const struct texture_s *base_override )
|
2021-02-10 01:42:08 +01:00
|
|
|
{
|
2021-11-27 08:59:48 +01:00
|
|
|
const texture_t *base = base_override ? base_override : s->texinfo->texture;
|
2021-02-10 01:42:08 +01:00
|
|
|
int count, reletive;
|
|
|
|
|
|
|
|
if( ent && ent->curstate.frame )
|
|
|
|
{
|
|
|
|
if( base->alternate_anims )
|
|
|
|
base = base->alternate_anims;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !base->anim_total )
|
|
|
|
return base;
|
|
|
|
|
|
|
|
if( base->name[0] == '-' )
|
|
|
|
{
|
|
|
|
int tx = (int)((s->texturemins[0] + (base->width << 16)) / base->width) % MOD_FRAMES;
|
|
|
|
int ty = (int)((s->texturemins[1] + (base->height << 16)) / base->height) % MOD_FRAMES;
|
|
|
|
|
|
|
|
reletive = g_brush.rtable[tx][ty] % base->anim_total;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int speed;
|
|
|
|
|
|
|
|
// Quake1 textures uses 10 frames per second
|
|
|
|
if( FBitSet( findTexture( base->gl_texturenum )->flags, TF_QUAKEPAL ))
|
|
|
|
speed = 10;
|
|
|
|
else speed = 20;
|
|
|
|
|
|
|
|
reletive = (int)(gpGlobals->time * speed) % base->anim_total;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
while( base->anim_min > reletive || base->anim_max <= reletive )
|
|
|
|
{
|
|
|
|
base = base->anim_next;
|
|
|
|
|
|
|
|
if( !base || ++count > MOD_FRAMES )
|
|
|
|
return s->texinfo->texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base;
|
|
|
|
}
|
|
|
|
|
2022-02-03 06:32:10 +01:00
|
|
|
void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, const matrix4x4 model )
|
2021-01-27 21:00:11 +01:00
|
|
|
{
|
|
|
|
// Expect all buffers to be bound
|
2021-02-10 01:42:08 +01:00
|
|
|
const model_t *mod = ent->model;
|
2021-04-07 21:11:20 +02:00
|
|
|
vk_brush_model_t *bmodel = mod->cache.data;
|
2021-01-31 00:31:23 +01:00
|
|
|
|
2021-02-01 01:50:27 +01:00
|
|
|
if (!bmodel) {
|
|
|
|
gEngine.Con_Printf( S_ERROR "Model %s wasn't loaded\n", mod->name);
|
2021-01-27 21:00:11 +01:00
|
|
|
return;
|
2021-02-01 01:50:27 +01:00
|
|
|
}
|
|
|
|
|
2021-06-14 18:19:21 +02:00
|
|
|
if (bmodel->num_water_surfaces) {
|
|
|
|
XVK_DrawWaterSurfaces(ent);
|
|
|
|
}
|
|
|
|
|
2021-04-13 19:13:17 +02:00
|
|
|
if (bmodel->render_model.num_geometries == 0)
|
|
|
|
return;
|
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
for (int i = 0; i < bmodel->render_model.num_geometries; ++i) {
|
2021-11-27 08:59:48 +01:00
|
|
|
vk_render_geometry_t *geom = bmodel->render_model.geometries + i;
|
|
|
|
const int surface_index = geom->surf - mod->surfaces;
|
2021-12-22 20:55:35 +01:00
|
|
|
const xvk_patch_surface_t *patch_surface = g_map_entities.patch.surfaces ? g_map_entities.patch.surfaces+surface_index : NULL;
|
|
|
|
|
|
|
|
// Patch by constant texture index first, if it exists
|
|
|
|
if (patch_surface && patch_surface->tex_id >= 0) {
|
|
|
|
geom->texture = patch_surface->tex_id;
|
|
|
|
} else {
|
|
|
|
// Optionally patch by texture_s pointer and run animations
|
|
|
|
const struct texture_s *texture_override = patch_surface ? patch_surface->tex : NULL;
|
|
|
|
const texture_t *t = R_TextureAnimation(ent, geom->surf, texture_override);
|
|
|
|
if (t->gl_texturenum >= 0)
|
|
|
|
geom->texture = t->gl_texturenum;
|
|
|
|
}
|
2021-04-07 21:11:20 +02:00
|
|
|
}
|
2021-01-31 00:31:23 +01:00
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
bmodel->render_model.render_mode = render_mode;
|
2021-10-27 19:21:06 +02:00
|
|
|
VK_RenderModelDraw(ent, &bmodel->render_model);
|
2021-04-07 21:11:20 +02:00
|
|
|
}
|
2021-01-31 00:31:23 +01:00
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
static qboolean renderableSurface( const msurface_t *surf, int i ) {
|
2021-06-19 21:52:13 +02:00
|
|
|
// if ( i >= 0 && (surf->flags & ~(SURF_PLANEBACK | SURF_UNDERWATER | SURF_TRANSPARENT)) != 0)
|
|
|
|
// {
|
|
|
|
// gEngine.Con_Reportf("\t%d flags: ", i);
|
|
|
|
// #define PRINTFLAGS(X) \
|
|
|
|
// X(SURF_PLANEBACK) \
|
|
|
|
// X(SURF_DRAWSKY) \
|
|
|
|
// X(SURF_DRAWTURB_QUADS) \
|
|
|
|
// X(SURF_DRAWTURB) \
|
|
|
|
// X(SURF_DRAWTILED) \
|
|
|
|
// X(SURF_CONVEYOR) \
|
|
|
|
// X(SURF_UNDERWATER) \
|
|
|
|
// X(SURF_TRANSPARENT)
|
|
|
|
|
|
|
|
// #define PRINTFLAG(f) if (FBitSet(surf->flags, f)) gEngine.Con_Reportf(" %s", #f);
|
|
|
|
// PRINTFLAGS(PRINTFLAG)
|
|
|
|
// gEngine.Con_Reportf("\n");
|
|
|
|
// }
|
2021-11-27 08:59:48 +01:00
|
|
|
//
|
2021-11-28 20:15:02 +01:00
|
|
|
if (g_map_entities.patch.surfaces && g_map_entities.patch.surfaces[i].flags & Patch_Surface_Delete)
|
2021-11-27 08:59:48 +01:00
|
|
|
return false;
|
2021-06-19 21:52:13 +02:00
|
|
|
|
|
|
|
//if( surf->flags & ( SURF_DRAWSKY | SURF_DRAWTURB | SURF_CONVEYOR | SURF_DRAWTURB_QUADS ) ) {
|
2021-10-27 19:21:06 +02:00
|
|
|
if( surf->flags & ( SURF_DRAWTURB | SURF_DRAWTURB_QUADS ) ) {
|
2021-06-12 21:54:53 +02:00
|
|
|
//if( surf->flags & ( SURF_DRAWSKY | SURF_CONVEYOR ) ) {
|
2021-04-19 20:17:17 +02:00
|
|
|
// FIXME don't print this on second sort-by-texture pass
|
|
|
|
//gEngine.Con_Reportf("Skipping surface %d because of flags %08x\n", i, surf->flags);
|
2021-04-07 21:11:20 +02:00
|
|
|
return false;
|
|
|
|
}
|
2021-01-30 21:10:54 +01:00
|
|
|
|
2021-11-25 20:53:44 +01:00
|
|
|
// Explicitly enable SURF_SKY, otherwise they will be skipped by SURF_DRAWTILED
|
2021-06-19 21:52:13 +02:00
|
|
|
if( FBitSet( surf->flags, SURF_DRAWSKY )) {
|
2021-11-25 20:53:44 +01:00
|
|
|
return true;
|
2021-06-19 21:52:13 +02:00
|
|
|
}
|
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
if( FBitSet( surf->flags, SURF_DRAWTILED )) {
|
2021-04-19 20:17:17 +02:00
|
|
|
//gEngine.Con_Reportf("Skipping surface %d because of tiled flag\n", i);
|
2021-04-07 21:11:20 +02:00
|
|
|
return false;
|
2021-01-30 21:10:54 +01:00
|
|
|
}
|
2021-01-31 00:31:23 +01:00
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int num_surfaces, num_vertices, num_indices;
|
|
|
|
int max_texture_id;
|
2021-06-14 18:19:21 +02:00
|
|
|
int water_surfaces;
|
2021-09-20 01:57:23 +02:00
|
|
|
//int sky_surfaces;
|
2022-02-03 06:32:10 +01:00
|
|
|
int emissive_surfaces;
|
2021-04-07 21:11:20 +02:00
|
|
|
} model_sizes_t;
|
|
|
|
|
|
|
|
static model_sizes_t computeSizes( const model_t *mod ) {
|
|
|
|
model_sizes_t sizes = {0};
|
|
|
|
|
|
|
|
for( int i = 0; i < mod->nummodelsurfaces; ++i)
|
|
|
|
{
|
2021-11-29 18:51:33 +01:00
|
|
|
const int surface_index = mod->firstmodelsurface + i;
|
|
|
|
const msurface_t *surf = mod->surfaces + surface_index;
|
2022-02-03 06:32:10 +01:00
|
|
|
const int tex_id = surf->texinfo->texture->gl_texturenum;
|
2021-04-07 21:11:20 +02:00
|
|
|
|
2021-06-14 18:19:21 +02:00
|
|
|
sizes.water_surfaces += !!(surf->flags & (SURF_DRAWTURB | SURF_DRAWTURB_QUADS));
|
|
|
|
|
2021-11-29 18:51:33 +01:00
|
|
|
if (!renderableSurface(surf, surface_index))
|
2021-04-07 21:11:20 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
++sizes.num_surfaces;
|
|
|
|
sizes.num_vertices += surf->numedges;
|
|
|
|
sizes.num_indices += 3 * (surf->numedges - 1);
|
2022-02-03 06:32:10 +01:00
|
|
|
if (tex_id > sizes.max_texture_id)
|
|
|
|
sizes.max_texture_id = tex_id;
|
|
|
|
|
|
|
|
{
|
|
|
|
const xvk_patch_surface_t *const psurf = g_map_entities.patch.surfaces ? g_map_entities.patch.surfaces + surface_index : NULL;
|
|
|
|
vec3_t emissive;
|
|
|
|
if ((psurf && (psurf->flags & Patch_Surface_Emissive)) || (RT_GetEmissiveForTexture(emissive, tex_id)))
|
|
|
|
++sizes.emissive_surfaces;
|
|
|
|
}
|
2021-02-14 02:19:59 +01:00
|
|
|
}
|
2021-02-01 01:50:27 +01:00
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
return sizes;
|
2021-01-27 21:00:11 +01:00
|
|
|
}
|
|
|
|
|
2022-02-03 06:32:10 +01:00
|
|
|
static rt_light_add_polygon_t loadPolyLight(const model_t *mod, const int surface_index, const msurface_t *surf, const vec3_t emissive) {
|
|
|
|
rt_light_add_polygon_t lpoly = {0};
|
2022-01-14 07:36:21 +01:00
|
|
|
lpoly.num_vertices = Q_min(7, surf->numedges);
|
|
|
|
|
2022-01-15 08:48:57 +01:00
|
|
|
// TODO split, don't clip
|
2022-01-14 07:36:21 +01:00
|
|
|
if (surf->numedges > 7)
|
|
|
|
gEngine.Con_Printf(S_WARN "emissive surface %d has %d vertices; clipping to 7\n", surface_index, surf->numedges);
|
|
|
|
|
|
|
|
VectorCopy(emissive, lpoly.emissive);
|
|
|
|
|
|
|
|
for (int i = 0; i < lpoly.num_vertices; ++i) {
|
2022-01-16 04:54:35 +01:00
|
|
|
const int iedge = mod->surfedges[surf->firstedge + i];
|
2022-01-14 07:36:21 +01:00
|
|
|
const medge_t *edge = mod->edges + (iedge >= 0 ? iedge : -iedge);
|
|
|
|
const mvertex_t *vertex = mod->vertexes + (iedge >= 0 ? edge->v[0] : edge->v[1]);
|
|
|
|
VectorCopy(vertex->position, lpoly.vertices[i]);
|
|
|
|
}
|
|
|
|
|
2022-01-16 08:12:12 +01:00
|
|
|
lpoly.surface = surf;
|
2022-02-03 06:32:10 +01:00
|
|
|
return lpoly;
|
2022-01-14 07:36:21 +01:00
|
|
|
}
|
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
static qboolean loadBrushSurfaces( model_sizes_t sizes, const model_t *mod ) {
|
2021-02-10 19:33:44 +01:00
|
|
|
vk_brush_model_t *bmodel = mod->cache.data;
|
2021-01-27 21:00:11 +01:00
|
|
|
uint32_t vertex_offset = 0;
|
2021-06-05 21:48:16 +02:00
|
|
|
int num_geometries = 0;
|
2021-02-17 22:26:09 +01:00
|
|
|
vk_vertex_t *bvert = NULL;
|
2021-02-10 19:33:44 +01:00
|
|
|
uint16_t *bind = NULL;
|
|
|
|
uint32_t index_offset = 0;
|
2022-05-04 18:23:37 +02:00
|
|
|
r_geometry_buffer_lock_t buffer;
|
2021-01-27 21:00:11 +01:00
|
|
|
|
2022-05-14 22:36:33 +02:00
|
|
|
if (!R_GeometryBufferAllocAndLock( &buffer, sizes.num_vertices, sizes.num_indices, LifetimeLong )) {
|
2022-05-04 18:23:37 +02:00
|
|
|
gEngine.Con_Printf(S_ERROR "Cannot allocate geometry for %s\n", mod->name );
|
2021-04-07 21:11:20 +02:00
|
|
|
return false;
|
2021-02-10 19:33:44 +01:00
|
|
|
}
|
|
|
|
|
2022-05-04 18:23:37 +02:00
|
|
|
bvert = buffer.vertices.ptr;
|
|
|
|
bind = buffer.indices.ptr;
|
2021-08-11 20:43:33 +02:00
|
|
|
|
2022-05-04 18:23:37 +02:00
|
|
|
index_offset = buffer.indices.unit_offset;
|
2021-02-23 03:54:13 +01:00
|
|
|
|
2021-01-31 00:31:23 +01:00
|
|
|
// Load sorted by gl_texturenum
|
2022-01-14 07:36:21 +01:00
|
|
|
// TODO this does not make that much sense in vulkan (can sort later)
|
2021-04-07 21:11:20 +02:00
|
|
|
for (int t = 0; t <= sizes.max_texture_id; ++t)
|
2021-01-31 00:31:23 +01:00
|
|
|
{
|
|
|
|
for( int i = 0; i < mod->nummodelsurfaces; ++i)
|
2021-01-27 21:00:11 +01:00
|
|
|
{
|
2021-04-12 20:07:41 +02:00
|
|
|
const int surface_index = mod->firstmodelsurface + i;
|
|
|
|
msurface_t *surf = mod->surfaces + surface_index;
|
2021-01-31 00:31:23 +01:00
|
|
|
mextrasurf_t *info = surf->info;
|
2021-06-05 21:48:16 +02:00
|
|
|
vk_render_geometry_t *model_geometry = bmodel->render_model.geometries + num_geometries;
|
2021-01-31 00:31:23 +01:00
|
|
|
const float sample_size = gEngine.Mod_SampleSizeForFace( surf );
|
2021-04-07 21:11:20 +02:00
|
|
|
int index_count = 0;
|
2021-11-17 18:43:10 +01:00
|
|
|
vec3_t tangent;
|
2021-11-27 08:59:48 +01:00
|
|
|
int tex_id = surf->texinfo->texture->gl_texturenum;
|
2021-11-28 20:15:02 +01:00
|
|
|
const xvk_patch_surface_t *const psurf = g_map_entities.patch.surfaces ? g_map_entities.patch.surfaces + surface_index : NULL;
|
2021-01-27 21:00:11 +01:00
|
|
|
|
2021-11-29 18:51:33 +01:00
|
|
|
if (!renderableSurface(surf, surface_index))
|
2021-01-31 00:31:23 +01:00
|
|
|
continue;
|
2021-01-27 21:00:11 +01:00
|
|
|
|
2021-11-27 08:59:48 +01:00
|
|
|
if (t != tex_id)
|
2021-01-31 00:31:23 +01:00
|
|
|
continue;
|
2021-01-30 21:10:54 +01:00
|
|
|
|
2022-01-15 08:48:57 +01:00
|
|
|
// FIXME move this to rt_light_bsp and static loading
|
2022-01-14 07:36:21 +01:00
|
|
|
{
|
2022-02-03 06:32:10 +01:00
|
|
|
qboolean is_emissive = false;
|
2022-09-11 20:38:51 +02:00
|
|
|
vec3_t emissive = {0};
|
2022-02-03 06:32:10 +01:00
|
|
|
rt_light_add_polygon_t polylight;
|
|
|
|
|
2022-01-14 07:36:21 +01:00
|
|
|
if (psurf && (psurf->flags & Patch_Surface_Emissive)) {
|
2022-02-03 06:32:10 +01:00
|
|
|
is_emissive = true;
|
|
|
|
VectorCopy(psurf->emissive, emissive);
|
2022-01-14 07:36:21 +01:00
|
|
|
} else if (RT_GetEmissiveForTexture(emissive, tex_id)) {
|
2022-02-03 06:32:10 +01:00
|
|
|
is_emissive = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_emissive) {
|
2022-05-27 20:16:15 +02:00
|
|
|
if (bmodel->render_model.polylights) {
|
|
|
|
ASSERT(bmodel->render_model.polylights_count < sizes.emissive_surfaces);
|
|
|
|
bmodel->render_model.polylights[bmodel->render_model.polylights_count++] = loadPolyLight(mod, surface_index, surf, emissive);
|
2022-02-03 06:32:10 +01:00
|
|
|
} else {
|
|
|
|
polylight = loadPolyLight(mod, surface_index, surf, emissive);
|
|
|
|
RT_LightAddPolygon(&polylight);
|
|
|
|
}
|
2022-01-14 07:36:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-05 21:48:16 +02:00
|
|
|
++num_geometries;
|
2021-01-31 00:31:23 +01:00
|
|
|
|
|
|
|
//gEngine.Con_Reportf( "surface %d: numverts=%d numedges=%d\n", i, surf->polys ? surf->polys->numverts : -1, surf->numedges );
|
|
|
|
|
|
|
|
if (vertex_offset + surf->numedges >= UINT16_MAX)
|
|
|
|
{
|
|
|
|
gEngine.Con_Printf(S_ERROR "Model %s indices don't fit into 16 bits\n", mod->name);
|
2021-04-07 21:11:20 +02:00
|
|
|
// FIXME unlock and free buffers
|
|
|
|
return false;
|
2021-01-31 00:31:23 +01:00
|
|
|
}
|
|
|
|
|
2021-06-05 21:48:16 +02:00
|
|
|
model_geometry->surf = surf;
|
2021-11-27 08:59:48 +01:00
|
|
|
model_geometry->texture = tex_id;
|
2021-07-04 21:48:32 +02:00
|
|
|
|
2022-05-04 18:23:37 +02:00
|
|
|
model_geometry->vertex_offset = buffer.vertices.unit_offset;
|
2021-08-18 18:17:48 +02:00
|
|
|
model_geometry->max_vertex = vertex_offset + surf->numedges;
|
2021-07-04 21:48:32 +02:00
|
|
|
|
|
|
|
model_geometry->index_offset = index_offset;
|
2021-01-31 00:31:23 +01:00
|
|
|
|
2021-06-19 21:52:13 +02:00
|
|
|
if( FBitSet( surf->flags, SURF_DRAWSKY )) {
|
|
|
|
model_geometry->material = kXVkMaterialSky;
|
|
|
|
} else {
|
2021-08-26 18:18:20 +02:00
|
|
|
model_geometry->material = kXVkMaterialRegular;
|
2021-11-25 20:53:44 +01:00
|
|
|
if (!FBitSet( surf->flags, SURF_DRAWTILED )) {
|
|
|
|
VK_CreateSurfaceLightmap( surf, mod );
|
|
|
|
}
|
2021-06-19 21:52:13 +02:00
|
|
|
}
|
2021-01-31 00:31:23 +01:00
|
|
|
|
2021-10-27 19:21:06 +02:00
|
|
|
if (FBitSet( surf->flags, SURF_CONVEYOR )) {
|
|
|
|
model_geometry->material = kXVkMaterialConveyor;
|
|
|
|
}
|
|
|
|
|
2021-11-19 18:52:10 +01:00
|
|
|
VectorCopy(surf->texinfo->vecs[0], tangent);
|
|
|
|
VectorNormalize(tangent);
|
|
|
|
|
2021-01-31 00:31:23 +01:00
|
|
|
for( int k = 0; k < surf->numedges; k++ )
|
|
|
|
{
|
|
|
|
const int iedge = mod->surfedges[surf->firstedge + k];
|
|
|
|
const medge_t *edge = mod->edges + (iedge >= 0 ? iedge : -iedge);
|
|
|
|
const mvertex_t *in_vertex = mod->vertexes + (iedge >= 0 ? edge->v[0] : edge->v[1]);
|
2021-02-17 22:26:09 +01:00
|
|
|
vk_vertex_t vertex = {
|
2021-01-31 00:31:23 +01:00
|
|
|
{in_vertex->position[0], in_vertex->position[1], in_vertex->position[2]},
|
|
|
|
};
|
|
|
|
|
2023-01-22 00:45:29 +01:00
|
|
|
vertex.prev_pos[0] = in_vertex->position[0];
|
|
|
|
vertex.prev_pos[1] = in_vertex->position[1];
|
|
|
|
vertex.prev_pos[2] = in_vertex->position[2];
|
|
|
|
|
2021-01-31 00:31:23 +01:00
|
|
|
float s = DotProduct( in_vertex->position, surf->texinfo->vecs[0] ) + surf->texinfo->vecs[0][3];
|
|
|
|
float t = DotProduct( in_vertex->position, surf->texinfo->vecs[1] ) + surf->texinfo->vecs[1][3];
|
|
|
|
|
|
|
|
s /= surf->texinfo->texture->width;
|
|
|
|
t /= surf->texinfo->texture->height;
|
|
|
|
|
|
|
|
vertex.gl_tc[0] = s;
|
|
|
|
vertex.gl_tc[1] = t;
|
|
|
|
|
|
|
|
// lightmap texture coordinates
|
|
|
|
s = DotProduct( in_vertex->position, info->lmvecs[0] ) + info->lmvecs[0][3];
|
|
|
|
s -= info->lightmapmins[0];
|
|
|
|
s += surf->light_s * sample_size;
|
|
|
|
s += sample_size * 0.5f;
|
|
|
|
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
|
|
|
|
|
|
|
|
t = DotProduct( in_vertex->position, info->lmvecs[1] ) + info->lmvecs[1][3];
|
|
|
|
t -= info->lightmapmins[1];
|
|
|
|
t += surf->light_t * sample_size;
|
|
|
|
t += sample_size * 0.5f;
|
|
|
|
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->height;
|
|
|
|
|
2021-03-07 01:40:35 +01:00
|
|
|
if( FBitSet( surf->flags, SURF_PLANEBACK ))
|
|
|
|
VectorNegate( surf->plane->normal, vertex.normal );
|
|
|
|
else VectorCopy( surf->plane->normal, vertex.normal );
|
|
|
|
|
2021-11-19 18:52:10 +01:00
|
|
|
VectorCopy(tangent, vertex.tangent);
|
|
|
|
|
2021-01-31 00:31:23 +01:00
|
|
|
vertex.lm_tc[0] = s;
|
|
|
|
vertex.lm_tc[1] = t;
|
|
|
|
|
2021-02-10 19:33:44 +01:00
|
|
|
*(bvert++) = vertex;
|
2021-01-31 00:31:23 +01:00
|
|
|
|
2021-06-12 21:54:53 +02:00
|
|
|
// Ray tracing apparently expects triangle list only (although spec is not very clear about this kekw)
|
2021-01-31 00:31:23 +01:00
|
|
|
if (k > 1) {
|
2021-08-15 20:30:38 +02:00
|
|
|
*(bind++) = (uint16_t)(vertex_offset + 0);
|
|
|
|
*(bind++) = (uint16_t)(vertex_offset + k - 1);
|
|
|
|
*(bind++) = (uint16_t)(vertex_offset + k);
|
2021-04-07 21:11:20 +02:00
|
|
|
index_count += 3;
|
2021-02-10 19:33:44 +01:00
|
|
|
index_offset += 3;
|
2021-01-31 00:31:23 +01:00
|
|
|
}
|
2021-01-27 21:00:11 +01:00
|
|
|
}
|
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
model_geometry->element_count = index_count;
|
2021-01-31 00:31:23 +01:00
|
|
|
vertex_offset += surf->numedges;
|
|
|
|
}
|
2021-01-27 21:00:11 +01:00
|
|
|
}
|
|
|
|
|
2022-05-04 18:23:37 +02:00
|
|
|
R_GeometryBufferUnlock( &buffer );
|
2021-02-23 03:54:13 +01:00
|
|
|
|
2022-05-27 20:16:15 +02:00
|
|
|
if (bmodel->render_model.polylights) {
|
|
|
|
gEngine.Con_Reportf("Dynamic polylights %d %d \n", sizes.emissive_surfaces, bmodel->render_model.polylights_count);
|
|
|
|
ASSERT(sizes.emissive_surfaces == bmodel->render_model.polylights_count);
|
2022-02-03 06:32:10 +01:00
|
|
|
}
|
2022-05-27 20:16:15 +02:00
|
|
|
|
2021-06-05 21:48:16 +02:00
|
|
|
ASSERT(sizes.num_surfaces == num_geometries);
|
|
|
|
bmodel->render_model.num_geometries = num_geometries;
|
2021-02-23 03:54:13 +01:00
|
|
|
|
2021-04-13 19:13:17 +02:00
|
|
|
return true;
|
2021-01-30 21:10:54 +01:00
|
|
|
}
|
|
|
|
|
2022-09-11 20:38:51 +02:00
|
|
|
qboolean VK_BrushModelLoad( model_t *mod, qboolean map )
|
2021-01-30 21:10:54 +01:00
|
|
|
{
|
|
|
|
if (mod->cache.data)
|
|
|
|
{
|
|
|
|
gEngine.Con_Reportf( S_WARN "Model %s was already loaded\n", mod->name );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
gEngine.Con_Reportf("%s: %s flags=%08x\n", __FUNCTION__, mod->name, mod->flags);
|
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
{
|
|
|
|
const model_sizes_t sizes = computeSizes( mod );
|
2021-06-05 21:48:16 +02:00
|
|
|
const size_t model_size =
|
|
|
|
sizeof(vk_brush_model_t) +
|
|
|
|
sizeof(vk_render_geometry_t) * sizes.num_surfaces;
|
2021-04-13 19:13:17 +02:00
|
|
|
|
2021-06-05 21:48:16 +02:00
|
|
|
vk_brush_model_t *bmodel = Mem_Calloc(vk_core.pool, model_size);
|
2021-04-07 21:11:20 +02:00
|
|
|
mod->cache.data = bmodel;
|
2021-09-14 19:20:15 +02:00
|
|
|
Q_strncpy(bmodel->render_model.debug_name, mod->name, sizeof(bmodel->render_model.debug_name));
|
2021-04-07 21:11:20 +02:00
|
|
|
bmodel->render_model.render_mode = kRenderNormal;
|
2021-09-26 18:15:19 +02:00
|
|
|
bmodel->render_model.static_map = map;
|
2021-04-07 21:11:20 +02:00
|
|
|
|
2021-08-26 18:18:20 +02:00
|
|
|
bmodel->num_water_surfaces = sizes.water_surfaces;
|
2021-06-14 18:19:21 +02:00
|
|
|
|
2021-04-13 19:13:17 +02:00
|
|
|
if (sizes.num_surfaces != 0) {
|
2021-06-05 21:48:16 +02:00
|
|
|
bmodel->render_model.geometries = (vk_render_geometry_t*)((char*)(bmodel + 1));
|
2021-04-13 19:13:17 +02:00
|
|
|
|
2022-02-03 06:32:10 +01:00
|
|
|
if (!map && sizes.emissive_surfaces)
|
2022-05-27 20:16:15 +02:00
|
|
|
bmodel->render_model.polylights = Mem_Malloc(vk_core.pool, sizeof(bmodel->render_model.polylights[0]) * sizes.emissive_surfaces);
|
2022-02-03 06:32:10 +01:00
|
|
|
|
2022-09-11 20:38:51 +02:00
|
|
|
if (!loadBrushSurfaces(sizes, mod) || !VK_RenderModelInit(&bmodel->render_model)) {
|
2021-04-13 19:13:17 +02:00
|
|
|
gEngine.Con_Printf(S_ERROR "Could not load model %s\n", mod->name);
|
|
|
|
Mem_Free(bmodel);
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-07 21:11:20 +02:00
|
|
|
}
|
2021-01-30 21:10:54 +01:00
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
g_brush.stat.num_indices += sizes.num_indices;
|
|
|
|
g_brush.stat.num_vertices += sizes.num_vertices;
|
|
|
|
|
|
|
|
gEngine.Con_Reportf("Model %s loaded surfaces: %d (of %d); total vertices: %u, total indices: %u\n", mod->name, bmodel->render_model.num_geometries, mod->nummodelsurfaces, g_brush.stat.num_vertices, g_brush.stat.num_indices);
|
2021-01-30 21:10:54 +01:00
|
|
|
}
|
|
|
|
|
2021-01-27 21:00:11 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
void VK_BrushModelDestroy( model_t *mod ) {
|
|
|
|
vk_brush_model_t *bmodel = mod->cache.data;
|
2021-04-13 19:46:33 +02:00
|
|
|
ASSERT(mod->type == mod_brush);
|
2021-04-07 21:11:20 +02:00
|
|
|
if (!bmodel)
|
|
|
|
return;
|
|
|
|
|
|
|
|
VK_RenderModelDestroy(&bmodel->render_model);
|
2022-05-27 20:16:15 +02:00
|
|
|
if (bmodel->render_model.polylights)
|
|
|
|
Mem_Free(bmodel->render_model.polylights);
|
2021-04-07 21:11:20 +02:00
|
|
|
Mem_Free(bmodel);
|
|
|
|
mod->cache.data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VK_BrushStatsClear( void )
|
2021-01-27 21:00:11 +01:00
|
|
|
{
|
2021-02-01 20:05:04 +01:00
|
|
|
// Free previous map data
|
2021-02-10 19:33:44 +01:00
|
|
|
g_brush.stat.num_vertices = 0;
|
|
|
|
g_brush.stat.num_indices = 0;
|
2021-02-01 01:53:24 +01:00
|
|
|
}
|