mirror of
https://github.com/yquake2/ref_vk.git
synced 2024-11-10 06:41:45 +00:00
Code path clean up
This commit is contained in:
parent
ede4069a44
commit
24933bce91
8 changed files with 138 additions and 206 deletions
6
Makefile
6
Makefile
|
@ -341,9 +341,9 @@ REFVK_OBJS_ := \
|
|||
src/vk/vk_mesh.o \
|
||||
src/vk/vk_model.o \
|
||||
src/vk/vk_pipeline.o \
|
||||
src/vk/vk_rmain.o \
|
||||
src/vk/vk_rmisc.o \
|
||||
src/vk/vk_rsurf.o \
|
||||
src/vk/vk_main.o \
|
||||
src/vk/vk_misc.o \
|
||||
src/vk/vk_surf.o \
|
||||
src/vk/vk_shaders.o \
|
||||
src/vk/vk_swapchain.o \
|
||||
src/vk/vk_validation.o \
|
||||
|
|
|
@ -1,23 +1,29 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
Copyright (C) 2018-2019 Krzysztof Kondrak
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
* Copyright (C) 2018-2019 Krzysztof Kondrak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* Header for the model stuff.
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#ifndef __VK_MODEL_H__
|
||||
#define __VK_MODEL_H__
|
||||
|
@ -66,7 +72,6 @@ typedef struct msurface_s
|
|||
|
||||
short texturemins[2];
|
||||
short extents[2];
|
||||
|
||||
short lmshift;
|
||||
|
||||
int light_s, light_t; // gl lightmap coordinates
|
||||
|
@ -79,8 +84,8 @@ typedef struct msurface_s
|
|||
mtexinfo_t *texinfo;
|
||||
|
||||
/* decoupled lm */
|
||||
float lmvecs[2][4];
|
||||
float lmvlen[2];
|
||||
float lmvecs[2][4];
|
||||
float lmvlen[2];
|
||||
|
||||
/* lighting info */
|
||||
int dlightframe;
|
||||
|
@ -92,11 +97,7 @@ typedef struct msurface_s
|
|||
byte *samples; // [numstyles*surfsize]
|
||||
} msurface_t;
|
||||
|
||||
//===================================================================
|
||||
|
||||
//
|
||||
// Whole model
|
||||
//
|
||||
/* Whole model */
|
||||
|
||||
typedef struct model_s
|
||||
{
|
||||
|
|
|
@ -1,37 +1,34 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
Copyright (C) 2018-2019 Krzysztof Kondrak
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// vk_light.c
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
* Copyright (C) 2018-2019 Krzysztof Kondrak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* Lightmaps and dynamic lighting
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include "header/local.h"
|
||||
|
||||
int r_dlightframecount;
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
DYNAMIC LIGHTS BLEND RENDERING
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
R_RenderDlight(dlight_t *light)
|
||||
{
|
||||
|
@ -119,19 +116,15 @@ DYNAMIC LIGHTS
|
|||
=============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
=============
|
||||
R_MarkSurfaceLights
|
||||
=============
|
||||
*/
|
||||
void
|
||||
R_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node, int r_dlightframecount)
|
||||
{
|
||||
msurface_t *surf;
|
||||
int i;
|
||||
|
||||
// mark the polygons
|
||||
/* mark the polygons */
|
||||
surf = r_worldmodel->surfaces + node->firstsurface;
|
||||
|
||||
for (i=0 ; i<node->numsurfaces ; i++, surf++)
|
||||
{
|
||||
if (surf->dlightframe != r_dlightframecount)
|
||||
|
@ -293,11 +286,6 @@ RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end, vec3_t pointcolor)
|
|||
return RecursiveLightPoint(node->children[!side], mid, end, pointcolor);
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
R_LightPoint
|
||||
===============
|
||||
*/
|
||||
void
|
||||
R_LightPoint(vec3_t p, vec3_t color, entity_t *currententity)
|
||||
{
|
||||
|
@ -327,22 +315,21 @@ R_LightPoint(vec3_t p, vec3_t color, entity_t *currententity)
|
|||
VectorCopy(pointcolor, color);
|
||||
}
|
||||
|
||||
//
|
||||
// add dynamic lights
|
||||
//
|
||||
/* add dynamic lights */
|
||||
dl = r_newrefdef.dlights;
|
||||
|
||||
for (lnum = 0; lnum < r_newrefdef.num_dlights; lnum++, dl++)
|
||||
{
|
||||
float add;
|
||||
|
||||
VectorSubtract(currententity->origin,
|
||||
dl->origin,
|
||||
dist);
|
||||
dl->origin, dist);
|
||||
add = dl->intensity - VectorLength(dist);
|
||||
add *= (1.0/256);
|
||||
add *= (1.0 / 256);
|
||||
|
||||
if (add > 0)
|
||||
{
|
||||
VectorMA (color, add, dl->color, color);
|
||||
VectorMA(color, add, dl->color, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,12 +607,11 @@ store:
|
|||
{
|
||||
for (j = 0; j < smax; j++)
|
||||
{
|
||||
|
||||
r = Q_ftol(bl[0]);
|
||||
g = Q_ftol(bl[1]);
|
||||
b = Q_ftol(bl[2]);
|
||||
|
||||
// catch negative lights
|
||||
/* catch negative lights */
|
||||
if (r < 0)
|
||||
{
|
||||
r = 0;
|
||||
|
@ -641,9 +627,7 @@ store:
|
|||
b = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** determine the brightest of the three color components
|
||||
*/
|
||||
/* determine the brightest of the three color components */
|
||||
if (r > g)
|
||||
{
|
||||
max = r;
|
||||
|
@ -658,17 +642,14 @@ store:
|
|||
max = b;
|
||||
}
|
||||
|
||||
/*
|
||||
** alpha is ONLY used for the mono lightmap case. For this reason
|
||||
** we set it to the brightest of the color components so that
|
||||
** things don't get too dim.
|
||||
*/
|
||||
/* alpha is ONLY used for the mono lightmap case. For this
|
||||
reason we set it to the brightest of the color components
|
||||
so that things don't get too dim. */
|
||||
a = max;
|
||||
|
||||
/*
|
||||
** rescale all the color components if the intensity of the greatest
|
||||
** channel exceeds 1.0
|
||||
*/
|
||||
/* rescale all the color components if the
|
||||
intensity of the greatest channel exceeds
|
||||
1.0 */
|
||||
if (max > 255)
|
||||
{
|
||||
float t = 255.0F / max;
|
||||
|
|
|
@ -1,24 +1,29 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
Copyright (C) 2018-2019 Krzysztof Kondrak
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// vk_model.c -- model loading and caching
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
* Copyright (C) 2018-2019 Krzysztof Kondrak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* Model loading and caching. Includes the .bsp file format
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include "header/local.h"
|
||||
|
||||
|
@ -33,12 +38,6 @@ static int models_known_max = 0;
|
|||
|
||||
int registration_sequence;
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
Mod_ClusterPVS
|
||||
==============
|
||||
*/
|
||||
const byte *
|
||||
Mod_ClusterPVS(int cluster, const model_t *model)
|
||||
{
|
||||
|
@ -55,11 +54,6 @@ Mod_ClusterPVS(int cluster, const model_t *model)
|
|||
|
||||
//===============================================================================
|
||||
|
||||
/*
|
||||
===============
|
||||
Mod_Reallocate
|
||||
===============
|
||||
*/
|
||||
static void
|
||||
Mod_Reallocate (void)
|
||||
{
|
||||
|
@ -88,11 +82,6 @@ Mod_Reallocate (void)
|
|||
models_known = calloc(models_known_max, sizeof(model_t));
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Mod_Init
|
||||
===============
|
||||
*/
|
||||
void
|
||||
Mod_Init(void)
|
||||
{
|
||||
|
@ -107,12 +96,8 @@ Mod_Init(void)
|
|||
Mod_Reallocate ();
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Mod_Free
|
||||
================
|
||||
*/
|
||||
static void Mod_Free (model_t *mod)
|
||||
static void
|
||||
Mod_Free(model_t *mod)
|
||||
{
|
||||
if (!mod->extradata)
|
||||
{
|
||||
|
@ -135,12 +120,8 @@ static void Mod_Free (model_t *mod)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Mod_FreeAll
|
||||
================
|
||||
*/
|
||||
void Mod_FreeAll (void)
|
||||
void
|
||||
Mod_FreeAll (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -151,30 +132,13 @@ void Mod_FreeAll (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Mod_FreeModelsKnown
|
||||
================
|
||||
*/
|
||||
void Mod_FreeModelsKnown (void)
|
||||
void
|
||||
Mod_FreeModelsKnown (void)
|
||||
{
|
||||
free(models_known);
|
||||
models_known = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
BRUSHMODEL LOADING
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadSubmodels
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadSubmodels (model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
|
@ -220,9 +184,9 @@ Mod_LoadSubmodels (model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|||
}
|
||||
|
||||
out->radius = Mod_RadiusFromBounds(out->mins, out->maxs);
|
||||
out->firstnode = LittleLong (in->headnode);
|
||||
out->firstmodelsurface = LittleLong (in->firstface);
|
||||
out->nummodelsurfaces = LittleLong (in->numfaces);
|
||||
out->firstnode = LittleLong(in->headnode);
|
||||
out->firstmodelsurface = LittleLong(in->firstface);
|
||||
out->nummodelsurfaces = LittleLong(in->numfaces);
|
||||
// visleafs
|
||||
out->numleafs = 0;
|
||||
// check limits
|
||||
|
@ -235,12 +199,8 @@ Mod_LoadSubmodels (model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CalcSurfaceExtents
|
||||
|
||||
Fills in s->texturemins[] and s->extents[]
|
||||
================
|
||||
*/
|
||||
* Fills in s->texturemins[] and s->extents[]
|
||||
*/
|
||||
static void
|
||||
CalcSurfaceExtents(model_t *loadmodel, msurface_t *s)
|
||||
{
|
||||
|
@ -489,7 +449,7 @@ Mod_LoadBSPX(int filesize, byte* mod_base)
|
|||
}
|
||||
|
||||
static void
|
||||
SetSurfaceLighting(model_t* loadmodel, msurface_t* out, byte* styles, int lightofs)
|
||||
SetSurfaceLighting(model_t *loadmodel, msurface_t *out, byte *styles, int lightofs)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -703,11 +663,6 @@ Mod_LoadLeafs(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Mod_LoadMarksurfaces
|
||||
=================
|
||||
*/
|
||||
static void
|
||||
Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
||||
{
|
||||
|
@ -731,8 +686,7 @@ Mod_LoadMarksurfaces(model_t *loadmodel, const byte *mod_base, const lump_t *l)
|
|||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
int j;
|
||||
j = LittleShort(in[i]);
|
||||
|
||||
if ((j < 0) || (j >= loadmodel->numsurfaces))
|
||||
|
@ -1032,12 +986,6 @@ RE_BeginRegistration (char *model)
|
|||
r_viewcluster = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
RE_RegisterModel
|
||||
|
||||
=====================
|
||||
*/
|
||||
struct model_s *
|
||||
RE_RegisterModel(char *name)
|
||||
{
|
||||
|
@ -1098,12 +1046,8 @@ Mod_HasFreeSpace(void)
|
|||
return (mod_loaded + mod_max) < models_known_max;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Mod_Modellist_f
|
||||
================
|
||||
*/
|
||||
void Mod_Modellist_f (void)
|
||||
void
|
||||
Mod_Modellist_f (void)
|
||||
{
|
||||
int i, total, used;
|
||||
model_t *mod;
|
||||
|
|
|
@ -1,24 +1,30 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
Copyright (C) 2018-2019 Krzysztof Kondrak
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
* Copyright (C) 2018-2019 Krzysztof Kondrak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* Surface generation and drawing
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
// vk_rsurf.c: surface-related refresh code
|
||||
#include <assert.h>
|
||||
|
||||
#include "header/local.h"
|
|
@ -684,7 +684,7 @@ void R_DrawSkyBox (void)
|
|||
|
||||
/*
|
||||
============
|
||||
RE_SetSky_s
|
||||
RE_SetSky
|
||||
============
|
||||
*/
|
||||
// 3dstudio environment map names
|
||||
|
|
Loading…
Reference in a new issue