light: clean headers

This commit is contained in:
Eric Wasylishen 2016-08-04 16:32:04 -06:00
parent fcc54c547f
commit 7029ed5713
10 changed files with 259 additions and 154 deletions

View File

@ -28,6 +28,7 @@
#include <common/polylib.h>
#include <light/litfile.hh>
#include <light/trace.hh>
#include <vector>
#include <map>
@ -39,54 +40,6 @@
#define ON_EPSILON 0.1
#define ANGLE_EPSILON 0.001
enum class hittype_t : uint8_t {
NONE = 0,
SOLID = 1,
SKY = 2
};
/*
* Convenience functions TestLight and TestSky will test against all shadow
* casting bmodels and self-shadow the model 'self' if self != NULL. Returns
* true if sky or light is visible, respectively.
*/
qboolean TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *self);
qboolean TestLight(const vec3_t start, const vec3_t stop, const dmodel_t *self);
hittype_t DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
// used for CalcPoints
bool IntersectSingleModel(const vec3_t start, const vec3_t dir, vec_t dist, const dmodel_t *self, vec_t *hitdist_out);
class raystream_t {
public:
virtual void pushRay(int i, const vec_t *origin, const vec3_t dir, float dist, const dmodel_t *selfshadow, const vec_t *color = nullptr) = 0;
virtual size_t numPushedRays() = 0;
virtual void tracePushedRaysOcclusion() = 0;
virtual void tracePushedRaysIntersection() = 0;
virtual bool getPushedRayOccluded(size_t j) = 0;
virtual float getPushedRayDist(size_t j) = 0;
virtual float getPushedRayHitDist(size_t j) = 0;
virtual hittype_t getPushedRayHitType(size_t j) = 0;
virtual void getPushedRayDir(size_t j, vec3_t out) = 0;
virtual int getPushedRayPointIndex(size_t j) = 0;
virtual void getPushedRayColor(size_t j, vec3_t out) = 0;
virtual void clearPushedRays() = 0;
virtual ~raystream_t() {};
};
raystream_t *MakeRayStream(int maxrays);
void Embree_TraceInit(const bsp2_t *bsp);
qboolean Embree_TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *self);
qboolean Embree_TestLight(const vec3_t start, const vec3_t stop, const dmodel_t *self);
hittype_t Embree_DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
bool Embree_IntersectSingleModel(const vec3_t start, const vec3_t dir, vec_t dist, const dmodel_t *self, vec_t *hitdist_out);
raystream_t *Embree_MakeRayStream(int maxrays);
int
SampleTexture(const bsp2_dface_t *face, const bsp2_t *bsp, const vec3_t point);
typedef struct {
vec3_t color;
vec3_t direction;
@ -110,9 +63,6 @@ public:
/*with extra sampling, lit+lux etc, we need at least 46mb stack space per thread. yes, that's a lot. on the plus side, it doesn't affect bsp complexity (actually, can simplify it a little)*/
#define MAXDIMENSION (255+1)
/* Allow space for 4x4 oversampling */
//#define SINGLEMAP (MAXDIMENSION*MAXDIMENSION*4*4)
typedef struct {
vec3_t data[3]; /* permuted 3x3 matrix */
int row[3]; /* row permutations */
@ -223,29 +173,16 @@ typedef struct {
const bsp2_dleaf_t *leaf;
} bouncelight_t;
void AddBounceLight(const vec3_t pos, const vec3_t color, const vec3_t surfnormal, vec_t area, const bsp2_t *bsp);
const std::vector<bouncelight_t> &BounceLights();
extern byte thepalette[768];
/* tracelist is a std::vector of pointers to modelinfo_t to use for LOS tests */
extern std::vector<const modelinfo_t *> tracelist;
extern std::vector<const modelinfo_t *> selfshadowlist;
void vec_from_mangle(vec3_t v, const vec3_t m);
void LightFaceInit(const bsp2_t *bsp, struct ltface_ctx *ctx);
void LightFaceShutdown(struct ltface_ctx *ctx);
const modelinfo_t *ModelInfoForFace(const bsp2_t *bsp, int facenum);
void LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, struct ltface_ctx *ctx);
void MakeTnodes(const bsp2_t *bsp);
int GetSurfaceVertex(const bsp2_t *bsp, const bsp2_dface_t *f, int v);
const vec_t *GetSurfaceVertexPoint(const bsp2_t *bsp, const bsp2_dface_t *f, int v);
/* access the final phong-shaded vertex normal */
const vec_t *GetSurfaceVertexNormal(const bsp2_t *bsp, const bsp2_dface_t *f, const int v);
const bsp2_dface_t *
Face_EdgeIndexSmoothed(const bsp2_t *bsp, const bsp2_dface_t *f, const int edgeindex);
/* detect colors with components in 0-1 and scale them to 0-255 */
void normalize_color_format(vec3_t color);
/* command-line options */
@ -431,12 +368,6 @@ enum class vec3_transformer_t {
};
void vec_from_mangle(vec3_t v, const vec3_t m);
/* detect colors with components in 0-1 and scale them to 0-255 */
void normalize_color_format(vec3_t color);
class lockable_vec3_t : public lockable_setting_t {
private:
vec3_t _default, _value;
@ -516,7 +447,7 @@ public:
}
};
void SetGlobalSetting(std::string name, std::string value, bool cmdline);
//
// worldspawn keys / command-line settings
@ -696,12 +627,6 @@ public:
};
/*
* Return space for the lightmap and colourmap at the same time so it can
* be done in a thread-safe manner.
*/
void GetFileSpace(byte **lightdata, byte **colordata, byte **deluxdata, int size);
extern byte *filebase;
extern byte *lit_filebase;
extern byte *lux_filebase;
@ -721,50 +646,21 @@ typedef enum {
} backend_t;
extern backend_t rtbackend;
void SetupDirt();
/* Used by fence texture sampling */
void WorldToTexCoord(const vec3_t world, const texinfo_t *tex, vec_t coord[2]);
vec_t
TriangleArea(const vec3_t v0, const vec3_t v1, const vec3_t v2);
extern qboolean surflight_dump;
extern char mapfilename[1024];
void
PrintFaceInfo(const bsp2_dface_t *face, const bsp2_t *bsp);
// public functions
const miptex_t *
Face_Miptex(const bsp2_t *bsp, const bsp2_dface_t *face);
const char *
Face_TextureName(const bsp2_t *bsp, const bsp2_dface_t *face);
void
Face_MakeInwardFacingEdgePlanes(const bsp2_t *bsp, const bsp2_dface_t *face, plane_t *out);
plane_t Face_Plane(const bsp2_t *bsp, const bsp2_dface_t *f);
lockable_setting_t *FindSetting(std::string name);
void SetGlobalSetting(std::string name, std::string value, bool cmdline);
void GetFileSpace(byte **lightdata, byte **colordata, byte **deluxdata, int size);
const modelinfo_t *ModelInfoForFace(const bsp2_t *bsp, int facenum);
int GetSurfaceVertex(const bsp2_t *bsp, const bsp2_dface_t *f, int v);
void Face_Normal(const bsp2_t *bsp, const bsp2_dface_t *f, vec3_t norm);
void FaceCentroid(const bsp2_dface_t *face, const bsp2_t *bsp, vec3_t out);
vec_t TriArea(const dvertex_t *v0, const dvertex_t *v1, const dvertex_t *v2);
/* vis testing */
const bsp2_dleaf_t *Light_PointInLeaf( const bsp2_t *bsp, const vec3_t point );
int Light_PointContents( const bsp2_t *bsp, const vec3_t point );
bool Mod_LeafPvs(const bsp2_t *bsp, const bsp2_dleaf_t *leaf, byte *out);
int DecompressedVisSize(const bsp2_t *bsp);
bool Pvs_LeafVisible(const bsp2_t *bsp, const byte *pvs, const bsp2_dleaf_t *leaf);
/* PVS index (light.cc) */
const vec_t *GetSurfaceVertexNormal(const bsp2_t *bsp, const bsp2_dface_t *f, const int v);
plane_t Face_Plane(const bsp2_t *bsp, const bsp2_dface_t *f);
const bsp2_dface_t *Face_EdgeIndexSmoothed(const bsp2_t *bsp, const bsp2_dface_t *f, const int edgeindex);
const std::vector<bouncelight_t> &BounceLights();
bool Leaf_HasSky(const bsp2_t *bsp, const bsp2_dleaf_t *leaf);
const bsp2_dleaf_t **Face_CopyLeafList(const bsp2_t *bsp, const bsp2_dface_t *face);
qboolean VisCullEntity(const bsp2_t *bsp, const byte *pvs, const bsp2_dleaf_t *entleaf);
void GetDirectLighting(raystream_t *rs, const vec3_t origin, const vec3_t normal, vec3_t colorout);
#endif /* __LIGHT_LIGHT_H__ */

53
include/light/ltface.hh Normal file
View File

@ -0,0 +1,53 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
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
See file, 'COPYING', for details.
*/
#ifndef __LIGHT_LTFACE_H__
#define __LIGHT_LTFACE_H__
#include <common/cmdlib.h>
#include <common/mathlib.h>
#include <common/bspfile.h>
#include <common/log.h>
#include <common/threads.h>
#include <common/polylib.h>
#include <light/litfile.hh>
#include <light/trace.hh>
#include <light/entities.hh>
#include <vector>
#include <map>
#include <string>
#include <cassert>
#include <limits>
#include <sstream>
void FaceCentroid(const bsp2_dface_t *face, const bsp2_t *bsp, vec3_t out);
void WorldToTexCoord(const vec3_t world, const texinfo_t *tex, vec_t coord[2]);
const vec_t *GetSurfaceVertexPoint(const bsp2_t *bsp, const bsp2_dface_t *f, int v);
vec_t GetLightValue(const light_t *entity, vec_t dist);
void GetDirectLighting(raystream_t *rs, const vec3_t origin, const vec3_t normal, vec3_t colorout);
void SetupDirt();
void LightFaceInit(const bsp2_t *bsp, struct ltface_ctx *ctx);
void LightFaceShutdown(struct ltface_ctx *ctx);
const miptex_t *Face_Miptex(const bsp2_t *bsp, const bsp2_dface_t *face);
const char *Face_TextureName(const bsp2_t *bsp, const bsp2_dface_t *face);
void LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, struct ltface_ctx *ctx);
#endif /* __LIGHT_LTFACE_H__ */

81
include/light/trace.hh Normal file
View File

@ -0,0 +1,81 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
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
See file, 'COPYING', for details.
*/
#ifndef __LIGHT_TRACE_H__
#define __LIGHT_TRACE_H__
#include <common/cmdlib.h>
#include <common/mathlib.h>
#include <common/bspfile.h>
#include <common/log.h>
#include <common/threads.h>
#include <common/polylib.h>
#include <vector>
#include <map>
#include <string>
#include <cassert>
#include <limits>
#include <sstream>
enum class hittype_t : uint8_t {
NONE = 0,
SOLID = 1,
SKY = 2
};
const bsp2_dleaf_t *Light_PointInLeaf( const bsp2_t *bsp, const vec3_t point );
int Light_PointContents( const bsp2_t *bsp, const vec3_t point );
void Face_MakeInwardFacingEdgePlanes(const bsp2_t *bsp, const bsp2_dface_t *face, plane_t *out);
int SampleTexture(const bsp2_dface_t *face, const bsp2_t *bsp, const vec3_t point);
/*
* Convenience functions TestLight and TestSky will test against all shadow
* casting bmodels and self-shadow the model 'self' if self != NULL. Returns
* true if sky or light is visible, respectively.
*/
qboolean TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *self);
qboolean TestLight(const vec3_t start, const vec3_t stop, const dmodel_t *self);
hittype_t DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
// used for CalcPoints
bool IntersectSingleModel(const vec3_t start, const vec3_t dir, vec_t dist, const dmodel_t *self, vec_t *hitdist_out);
class raystream_t {
public:
virtual void pushRay(int i, const vec_t *origin, const vec3_t dir, float dist, const dmodel_t *selfshadow, const vec_t *color = nullptr) = 0;
virtual size_t numPushedRays() = 0;
virtual void tracePushedRaysOcclusion() = 0;
virtual void tracePushedRaysIntersection() = 0;
virtual bool getPushedRayOccluded(size_t j) = 0;
virtual float getPushedRayDist(size_t j) = 0;
virtual float getPushedRayHitDist(size_t j) = 0;
virtual hittype_t getPushedRayHitType(size_t j) = 0;
virtual void getPushedRayDir(size_t j, vec3_t out) = 0;
virtual int getPushedRayPointIndex(size_t j) = 0;
virtual void getPushedRayColor(size_t j, vec3_t out) = 0;
virtual void clearPushedRays() = 0;
virtual ~raystream_t() {};
};
raystream_t *MakeRayStream(int maxrays);
void MakeTnodes(const bsp2_t *bsp);
#endif /* __LIGHT_TRACE_H__ */

View File

@ -0,0 +1,38 @@
/* Copyright (C) 2016 Eric Wasylishen
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
See file, 'COPYING', for details.
*/
#ifndef __LIGHT_TRACE_EMBREE_H__
#define __LIGHT_TRACE_EMBREE_H__
#include <common/cmdlib.h>
#include <common/mathlib.h>
#include <common/bspfile.h>
#include <common/log.h>
#include <common/threads.h>
#include <common/polylib.h>
void Embree_TraceInit(const bsp2_t *bsp);
qboolean Embree_TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *self);
qboolean Embree_TestLight(const vec3_t start, const vec3_t stop, const dmodel_t *self);
hittype_t Embree_DirtTrace(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out);
bool Embree_IntersectSingleModel(const vec3_t start, const vec3_t dir, vec_t dist, const dmodel_t *self, vec_t *hitdist_out);
raystream_t *Embree_MakeRayStream(int maxrays);
#endif /* __LIGHT_TRACE_EMBREE_H__ */

View File

@ -4,6 +4,8 @@ project (light CXX C)
set(LIGHT_INCLUDES
${CMAKE_SOURCE_DIR}/include/light/entities.hh
${CMAKE_SOURCE_DIR}/include/light/light.hh
${CMAKE_SOURCE_DIR}/include/light/ltface.hh
${CMAKE_SOURCE_DIR}/include/light/trace.hh
${CMAKE_SOURCE_DIR}/include/light/litfile.hh)
set(LIGHT_SOURCES
@ -27,8 +29,12 @@ FIND_PACKAGE(embree 2.0)
if (embree_FOUND)
MESSAGE(STATUS "Embree library found: ${EMBREE_LIBRARY}")
INCLUDE_DIRECTORIES(${EMBREE_INCLUDE_DIRS})
set(LIGHT_INCLUDES
${CMAKE_SOURCE_DIR}/include/light/trace_embree.hh
${LIGHT_INCLUDES})
set(LIGHT_SOURCES
trace_embree.cc
${CMAKE_SOURCE_DIR}/include/light/trace_embree.hh
${LIGHT_SOURCES})
endif(embree_FOUND)

View File

@ -23,6 +23,7 @@
#include <light/light.hh>
#include <light/entities.hh>
#include <light/ltface.hh>
using strings = std::vector<std::string>;

View File

@ -23,6 +23,7 @@
#include <light/light.hh>
#include <light/entities.hh>
#include <light/ltface.hh>
#include <common/polylib.h>
@ -154,7 +155,8 @@ void SetGlobalSetting(std::string name, std::string value, bool cmdline) {
globalsettings.setSetting(name, value, cmdline);
}
void InitSettings()
static void
InitSettings()
{
globalsettings = {{
&minlight,
@ -205,6 +207,10 @@ PrintOptionsSummary(void)
}
}
/*
* Return space for the lightmap and colourmap at the same time so it can
* be done in a thread-safe manner.
*/
void
GetFileSpace(byte **lightdata, byte **colordata, byte **deluxdata, int size)
{
@ -467,6 +473,7 @@ Face_Normal(const bsp2_t *bsp, const bsp2_dface_t *f, vec3_t norm)
VectorCopy(bsp->dplanes[f->planenum].normal, norm);
}
/* access the final phong-shaded vertex normal */
const vec_t *GetSurfaceVertexNormal(const bsp2_t *bsp, const bsp2_dface_t *f, const int vertindex)
{
const auto &face_normals_vector = vertex_normals.at(f);
@ -842,7 +849,8 @@ public:
vec3_t directlight;
};
unique_ptr<patch_t> MakePatch (winding_t *w)
static unique_ptr<patch_t>
MakePatch (winding_t *w)
{
unique_ptr<patch_t> p { new patch_t };
p->w = w;
@ -903,6 +911,9 @@ Face_LookupTextureColor(const bsp2_t *bsp, const bsp2_dface_t *face, vec3_t colo
}
}
static void
AddBounceLight(const vec3_t pos, const vec3_t color, const vec3_t surfnormal, vec_t area, const bsp2_t *bsp);
static void *
MakeBounceLightsThread (void *arg)
{
@ -966,7 +977,8 @@ MakeBounceLightsThread (void *arg)
return NULL;
}
void AddBounceLight(const vec3_t pos, const vec3_t color, const vec3_t surfnormal, vec_t area, const bsp2_t *bsp)
static void
AddBounceLight(const vec3_t pos, const vec3_t color, const vec3_t surfnormal, vec_t area, const bsp2_t *bsp)
{
bouncelight_t l;
VectorCopy(pos, l.pos);
@ -985,7 +997,8 @@ const std::vector<bouncelight_t> &BounceLights()
}
// Returns color in [0,1]
void Texture_AvgColor (const bsp2_t *bsp, const miptex_t *miptex, vec3_t color)
static void
Texture_AvgColor (const bsp2_t *bsp, const miptex_t *miptex, vec3_t color)
{
VectorSet(color, 0, 0, 0);
if (!bsp->texdatasize)
@ -1003,7 +1016,8 @@ void Texture_AvgColor (const bsp2_t *bsp, const miptex_t *miptex, vec3_t color)
VectorScale(color, 1.0 / (miptex->width * miptex->height), color);
}
void MakeTextureColors (const bsp2_t *bsp)
static void
MakeTextureColors (const bsp2_t *bsp)
{
logprint("--- MakeTextureColors ---\n");
@ -1026,7 +1040,8 @@ void MakeTextureColors (const bsp2_t *bsp)
}
}
void MakeBounceLights (const bsp2_t *bsp)
static void
MakeBounceLights (const bsp2_t *bsp)
{
logprint("--- MakeBounceLights ---\n");
@ -1079,7 +1094,7 @@ ExportObjFace(FILE *f, const bsp2_t *bsp, const bsp2_dface_t *face, int *vertcou
*vertcount += face->numedges;
}
void
static void
ExportObj(const char *filename, const bsp2_t *bsp)
{
FILE *objfile = InitObjFile(filename);
@ -1102,7 +1117,8 @@ vector<vector<const bsp2_dleaf_t *>> faceleafs;
vector<bool> leafhassky;
// index some stuff from the bsp
void BuildPvsIndex(const bsp2_t *bsp)
static void
BuildPvsIndex(const bsp2_t *bsp)
{
if (bsp->visdatasize != 0) {
if (novis) {
@ -1145,7 +1161,8 @@ bool Leaf_HasSky(const bsp2_t *bsp, const bsp2_dleaf_t *leaf)
return leafhassky.at(leafnum);
}
const bsp2_dleaf_t **Face_CopyLeafList(const bsp2_t *bsp, const bsp2_dface_t *face)
static const bsp2_dleaf_t **
Face_CopyLeafList(const bsp2_t *bsp, const bsp2_dface_t *face)
{
const int facenum = face - bsp->dfaces;
auto &leafs = faceleafs.at(facenum);
@ -1191,7 +1208,8 @@ Face_NearestCentroid(const bsp2_t *bsp, const vec3_t point)
return nearest_face;
}
void FindDebugFace(const bsp2_t *bsp)
static void
FindDebugFace(const bsp2_t *bsp)
{
if (!dump_face)
return;
@ -1235,7 +1253,8 @@ Vertex_NearestPoint(const bsp2_t *bsp, const vec3_t point)
return nearest_vert;
}
void FindDebugVert(const bsp2_t *bsp)
static void
FindDebugVert(const bsp2_t *bsp)
{
if (!dump_vert)
return;

View File

@ -19,9 +19,14 @@
#include <light/light.hh>
#include <light/entities.hh>
#include <light/trace.hh>
#include <light/ltface.hh>
#include <cassert>
static void
PrintFaceInfo(const bsp2_dface_t *face, const bsp2_t *bsp);
/* ======================================================================== */
@ -142,7 +147,7 @@ TriCentroid(const dvertex_t *v0, const dvertex_t *v1, const dvertex_t *v2,
out[i] = (v0->point[i] + v1->point[i] + v2->point[i]) / 3.0;
}
vec_t
static vec_t
TriArea(const dvertex_t *v0, const dvertex_t *v1, const dvertex_t *v2)
{
int i;
@ -270,7 +275,7 @@ WorldToTexCoord(const vec3_t world, const texinfo_t *tex, vec_t coord[2])
}
/* Debug helper - move elsewhere? */
void
static void
PrintFaceInfo(const bsp2_dface_t *face, const bsp2_t *bsp)
{
const texinfo_t *tex = &bsp->texinfo[face->texinfo];
@ -303,7 +308,6 @@ PrintFaceInfo(const bsp2_dface_t *face, const bsp2_t *bsp)
* Fills in surf->texmins[], surf->texsize[] and sets surf->exactmid[]
* ================
*/
__attribute__((noinline))
static void
CalcFaceExtents(const bsp2_dface_t *face,
const bsp2_t *bsp, lightsurf_t *surf)
@ -403,7 +407,7 @@ const vec_t *GetSurfaceVertexPoint(const bsp2_t *bsp, const bsp2_dface_t *f, int
return bsp->dvertexes[GetSurfaceVertex(bsp, f, v)].point;
}
vec_t
static vec_t
TriangleArea(const vec3_t v0, const vec3_t v1, const vec3_t v2)
{
vec3_t edge0, edge1, cross;
@ -611,7 +615,7 @@ CheckObstructed(const lightsurf_t *surf, const vec3_t offset, const vec_t us, co
}
// Dump points to a .map file
void
static void
CalcPoints_Debug(const lightsurf_t *surf, const bsp2_t *bsp)
{
const int facenum = surf->face - bsp->dfaces;
@ -647,7 +651,6 @@ CalcPoints_Debug(const lightsurf_t *surf, const bsp2_t *bsp)
* to get the world xyz value of the sample point
* =================
*/
__attribute__((noinline))
static void
CalcPoints(const modelinfo_t *modelinfo, const vec3_t offset, lightsurf_t *surf, const bsp2_t *bsp, const bsp2_dface_t *face)
{
@ -705,7 +708,7 @@ CalcPoints(const modelinfo_t *modelinfo, const vec3_t offset, lightsurf_t *surf,
}
}
int
static int
DecompressedVisSize(const bsp2_t *bsp)
{
return (bsp->dmodels[0].visleafs + 7) / 8;
@ -746,7 +749,7 @@ static void Mod_Q1BSP_DecompressVis(const unsigned char *in, const unsigned char
}
}
bool
static bool
Mod_LeafPvs(const bsp2_t *bsp, const bsp2_dleaf_t *leaf, byte *out)
{
const int num_pvsclusterbytes = DecompressedVisSize(bsp);
@ -777,7 +780,7 @@ Mod_LeafPvs(const bsp2_t *bsp, const bsp2_dleaf_t *leaf, byte *out)
}
// returns true if pvs can see leaf
bool
static bool
Pvs_LeafVisible(const bsp2_t *bsp, const byte *pvs, const bsp2_dleaf_t *leaf)
{
const int leafnum = (leaf - bsp->dleafs);
@ -838,7 +841,6 @@ CalcPvs(const bsp2_t *bsp, lightsurf_t *lightsurf)
}
}
__attribute__((noinline))
static void
Lightsurf_Init(const modelinfo_t *modelinfo, const bsp2_dface_t *face,
const bsp2_t *bsp, lightsurf_t *lightsurf, facesup_t *facesup)
@ -962,7 +964,8 @@ Lightmap_ForStyle(lightmap_t *lightmaps, const int style, const lightsurf_t *lig
*
* Sets all styles to 255, doesn't actually clear the data.
*/
void Lightmap_ClearAll(lightmap_t *lightmaps)
static void
Lightmap_ClearAll(lightmap_t *lightmaps)
{
for (int i = 0; i <= MAXLIGHTMAPS; i++) {
lightmaps[i].style = 255;
@ -993,7 +996,6 @@ Lightmap_Save(lightmap_t *lightmaps, const lightsurf_t *lightsurf,
/*
* Average adjacent points on the grid to soften shadow edges
*/
__attribute__((noinline))
static void
Lightmap_Soften(lightmap_t *lightmap, const lightsurf_t *lightsurf)
{
@ -1280,7 +1282,7 @@ ProjectPointOntoPlane(const vec3_t point, const plane_t *plane, vec3_t out)
VectorMA(point, -dist, plane->normal, out);
}
qboolean
static qboolean
VisCullEntity(const bsp2_t *bsp, const byte *pvs, const bsp2_dleaf_t *entleaf)
{
if (novis) return false;
@ -1792,7 +1794,7 @@ BounceLight_SphereCull(const bsp2_t *bsp, const bouncelight_t *vpl, const lights
return false;
}
void
static void
LightFace_Bounce(const bsp2_t *bsp, const bsp2_dface_t *face, const lightsurf_t *lightsurf, lightmap_t *lightmaps)
{
//const dmodel_t *shadowself = lightsurf->modelinfo->shadowself.boolValue() ? lightsurf->modelinfo->model : NULL;
@ -2008,7 +2010,7 @@ GetDirtVector(int i, vec3_t out)
}
}
float
static float
DirtAtPoint(raystream_t *rs, const vec3_t point, const vec3_t normal, const dmodel_t *selfshadow)
{
if (!dirt_in_use) {

View File

@ -18,6 +18,11 @@
*/
#include <light/light.hh>
#include <light/trace.hh>
#include <light/ltface.hh>
#ifdef HAVE_EMBREE
#include <light/trace_embree.hh>
#endif
#include <cassert>
#define TRACE_HIT_NONE 0
@ -40,7 +45,7 @@ typedef struct traceinfo_s {
} traceinfo_t;
/* Stopped by solid and sky */
bool TraceFaces (traceinfo_t *ti, int node, const vec3_t start, const vec3_t end);
static bool TraceFaces (traceinfo_t *ti, int node, const vec3_t start, const vec3_t end);
/*
* ---------
@ -64,7 +69,7 @@ bool TraceFaces (traceinfo_t *ti, int node, const vec3_t start, const vec3_t end
* Yet, which side is the node with the solid leaf child determines
* what the hit point will be.
*/
int TraceLine(const dmodel_t *model, const int traceflags,
static int TraceLine(const dmodel_t *model, const int traceflags,
const vec3_t start, const vec3_t end);
typedef struct tnode_s {
@ -241,7 +246,7 @@ Face_MakeInwardFacingEdgePlanes(const bsp2_t *bsp, const bsp2_dface_t *face, pla
}
}
void
static void
MakeFaceInfo(const bsp2_t *bsp, const bsp2_dface_t *face, faceinfo_t *info)
{
info->numedges = face->numedges;
@ -322,7 +327,7 @@ MakeFenceInfo(const bsp2_t *bsp)
}
}
void
static void
BSP_MakeTnodes(const bsp2_t *bsp)
{
bsp_static = bsp;
@ -343,7 +348,7 @@ BSP_MakeTnodes(const bsp2_t *bsp)
* ============================================================================
*/
uint32_t fix_coord(vec_t in, uint32_t width)
static uint32_t fix_coord(vec_t in, uint32_t width)
{
if (in > 0)
{
@ -448,7 +453,7 @@ typedef struct {
* ==============
*/
#define MAX_TSTACK 256
int
static int
TraceLine(const dmodel_t *model, const int traceflags,
const vec3_t start, const vec3_t stop)
{
@ -645,7 +650,7 @@ BSP_TestSky(const vec3_t start, const vec3_t dirn, const dmodel_t *self)
* or if it started in the void.
* ============
*/
hittype_t
static hittype_t
BSP_DirtTrace(const vec3_t start, const vec3_t dirn, const vec_t dist, const dmodel_t *self, vec_t *hitdist_out, plane_t *hitplane_out, const bsp2_dface_t **face_out)
{
vec3_t stop;
@ -694,7 +699,8 @@ BSP_DirtTrace(const vec3_t start, const vec3_t dirn, const vec_t dist, const dmo
return hittype_t::NONE;
}
bool BSP_IntersectSingleModel(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out)
static bool
BSP_IntersectSingleModel(const vec3_t start, const vec3_t dirn, vec_t dist, const dmodel_t *self, vec_t *hitdist_out)
{
vec3_t stop;
VectorMA(start, dist, dirn, stop);
@ -720,7 +726,8 @@ TraceFaces
From lordhavoc, johnfitz (RecursiveLightPoint)
=============
*/
bool TraceFaces (traceinfo_t *ti, int node, const vec3_t start, const vec3_t end)
static bool
TraceFaces (traceinfo_t *ti, int node, const vec3_t start, const vec3_t end)
{
float front, back, frac;
vec3_t mid;

View File

@ -18,6 +18,8 @@
*/
#include <light/light.hh>
#include <light/trace_embree.hh>
#include <light/ltface.hh>
#include <embree2/rtcore.h>
#include <embree2/rtcore_ray.h>
#include <vector>