light: change assertions to Q_assert (so they are all enabled in release builds)

This commit is contained in:
Eric Wasylishen 2016-09-18 15:41:56 -06:00
parent b2fb764e36
commit 857b4402ad
8 changed files with 60 additions and 60 deletions

View File

@ -23,8 +23,8 @@
/* small helper that just retrieves the correct vertex from face->surfedge->edge lookups */
int Face_VertexAtIndex(const bsp2_t *bsp, const bsp2_dface_t *f, int v)
{
assert(v >= 0);
assert(v < f->numedges);
Q_assert(v >= 0);
Q_assert(v < f->numedges);
int edge = f->firstedge + v;
edge = bsp->dsurfedges[edge];
@ -36,7 +36,7 @@ int Face_VertexAtIndex(const bsp2_t *bsp, const bsp2_dface_t *f, int v)
static void
Vertex_GetPos(const bsp2_t *bsp, int num, vec3_t out)
{
assert(num >= 0 && num < bsp->numvertexes);
Q_assert(num >= 0 && num < bsp->numvertexes);
const dvertex_t *v = &bsp->dvertexes[num];
for (int i=0; i<3; i++)

View File

@ -79,8 +79,8 @@ VecStrf(const vec3_t vec)
void
UniformPointOnSphere(vec3_t dir, float u1, float u2)
{
assert(u1 >= 0 && u1 <= 1);
assert(u2 >= 0 && u2 <= 1);
Q_assert(u1 >= 0 && u1 <= 1);
Q_assert(u2 >= 0 && u2 <= 1);
const vec_t theta = u1 * 2.0 * Q_PI;
const vec_t u = (2.0 * u2) - 1.0;
@ -91,8 +91,8 @@ UniformPointOnSphere(vec3_t dir, float u1, float u2)
dir[2] = u;
for (int i=0; i<3; i++) {
assert(dir[i] >= -1.001);
assert(dir[i] <= 1.001);
Q_assert(dir[i] >= -1.001);
Q_assert(dir[i] <= 1.001);
}
}

View File

@ -52,7 +52,7 @@ protected:
lockable_setting_t(std::vector<std::string> names)
: _source(setting_source_t::DEFAULT), _names(names) {
assert(_names.size() > 0);
Q_assert(_names.size() > 0);
}
bool changeSource(setting_source_t newSource) {
@ -187,9 +187,9 @@ public:
float maxval=std::numeric_limits<float>::infinity())
: lockable_setting_t(names), _default(v), _value(v), _min(minval), _max(maxval) {
// check the default value is valid
assert(_min < _max);
assert(_value >= _min);
assert(_value <= _max);
Q_assert(_min < _max);
Q_assert(_value >= _min);
Q_assert(_value <= _max);
}
lockable_vec_t(std::string name, float v,
@ -313,10 +313,10 @@ public:
: _allsettings(settings)
{
for (lockable_setting_t *setting : settings) {
assert(setting->names().size() > 0);
Q_assert(setting->names().size() > 0);
for (const auto &name : setting->names()) {
assert(_settingsmap.find(name) == _settingsmap.end());
Q_assert(_settingsmap.find(name) == _settingsmap.end());
_settingsmap[name] = setting;
}

View File

@ -92,7 +92,7 @@ std::string WorldValueForKey(const std::string &key)
static int
LightStyleForTargetname(const std::string &targetname)
{
assert(targetname.size() > 0);
Q_assert(targetname.size() > 0);
// check if already assigned
auto it = lightstyleForTargetname.find(targetname);
@ -838,7 +838,7 @@ EntDict_RemoveValueForKey(entdict_t &dict, const std::string key)
if (it != dict.end()) {
dict.erase(it);
}
assert(dict.find(key) == dict.end());
Q_assert(dict.find(key) == dict.end());
}
static std::string
@ -925,7 +925,7 @@ LoadEntities(const globalconfig_t &cfg, const bsp2_t *bsp)
/* apply side effects of settings (in particular "dirt") */
FixupGlobalSettings();
assert(all_lights.size() == 0);
Q_assert(all_lights.size() == 0);
if (nolights) {
return;
}
@ -1174,7 +1174,7 @@ SetupLights(const globalconfig_t &cfg, const bsp2_t *bsp)
static_cast<int>(all_suns.size()));
assert(final_lightcount == all_lights.size());
Q_assert(final_lightcount == all_lights.size());
}
const char *
@ -1231,7 +1231,7 @@ WriteEntitiesToString(bsp2_t *bsp)
memcpy(bsp->dentdata, entdata.data(), entdata.size());
assert(0 == bsp->dentdata[bsp->entdatasize - 1]);
Q_assert(0 == bsp->dentdata[bsp->entdatasize - 1]);
}
@ -1249,7 +1249,7 @@ char surflights_dump_filename[1024];
static void
SurfLights_WriteEntityToFile(FILE *f, light_t *entity, const vec3_t pos)
{
assert(entity->epairs != nullptr);
Q_assert(entity->epairs != nullptr);
entdict_t epairs { *entity->epairs };
EntDict_RemoveValueForKey(epairs, "_surface");

View File

@ -113,7 +113,7 @@ void SetGlobalSetting(std::string name, std::string value, bool cmdline) {
void FixupGlobalSettings() {
static bool once = false;
assert(!once);
Q_assert(!once);
once = true;
// NOTE: This is confusing.. Setting "dirt" "1" implies "minlight_dirt" "1"
@ -271,9 +271,9 @@ LightThread(void *arg)
static void
FindModelInfo(const bsp2_t *bsp, const char *lmscaleoverride)
{
assert(modelinfo.size() == 0);
assert(tracelist.size() == 0);
assert(selfshadowlist.size() == 0);
Q_assert(modelinfo.size() == 0);
Q_assert(tracelist.size() == 0);
Q_assert(selfshadowlist.size() == 0);
if (!bsp->nummodels) {
Error("Corrupt .BSP: bsp->nummodels is 0!");
@ -334,13 +334,13 @@ FindModelInfo(const bsp2_t *bsp, const char *lmscaleoverride)
if (EntDict_StringForKey(*entdict, "classname").find("rotate_") == 0) {
EntDict_VectorForKey(*entdict, "origin", info->offset);
} else {
assert(info->offset[0] == 0);
assert(info->offset[1] == 0);
assert(info->offset[2] == 0);
Q_assert(info->offset[0] == 0);
Q_assert(info->offset[1] == 0);
Q_assert(info->offset[2] == 0);
}
}
assert(modelinfo.size() == bsp->nummodels);
Q_assert(modelinfo.size() == bsp->nummodels);
}
/* return 0 if either vector is zero-length */
@ -595,14 +595,14 @@ CalcualateVertexNormals(const bsp2_t *bsp)
// sanity check
if (!neighboursToSmooth.size()) {
for (auto vertIndexNormalPair : smoothedNormals) {
assert(VectorCompare(vertIndexNormalPair.second.v, f_norm));
Q_assert(VectorCompare(vertIndexNormalPair.second.v, f_norm));
}
}
// now, record all of the smoothed normals that are actually part of `f`
for (int j=0; j<f->numedges; j++) {
int v = Face_VertexAtIndex(bsp, f, j);
assert(smoothedNormals.find(v) != smoothedNormals.end());
Q_assert(smoothedNormals.find(v) != smoothedNormals.end());
vertex_normals[f].push_back(smoothedNormals[v]);
}

View File

@ -1747,7 +1747,7 @@ LightFace_Bounce(const bsp2_t *bsp, const bsp2_dface_t *face, const lightsurf_t
const int i = rs->getPushedRayPointIndex(j);
vec3_t indirect = {0};
rs->getPushedRayColor(j, indirect);
assert(LightSample_Brightness(indirect) >= 0.25);
Q_assert(LightSample_Brightness(indirect) >= 0.25);
/* Use dirt scaling on the indirect lighting.
* Except, not in bouncedebug mode.
@ -1901,7 +1901,7 @@ TransformToTangentSpace(const vec3_t normal, const vec3_t myUp, const vec3_t myR
static inline void
GetDirtVector(const globalconfig_t &cfg, int i, vec3_t out)
{
assert(i < numDirtVectors);
Q_assert(i < numDirtVectors);
if (cfg.dirtMode.intValue() == 1) {
/* get random vector */
@ -1944,7 +1944,7 @@ DirtAtPoint(const globalconfig_t &cfg, raystream_t *rs, const vec3_t point, cons
rs->pushRay(j, point, dir, cfg.dirtDepth.floatValue(), selfshadow);
}
assert(rs->numPushedRays() == numDirtVectors);
Q_assert(rs->numPushedRays() == numDirtVectors);
// trace the batch
rs->tracePushedRaysIntersection();
@ -1976,7 +1976,7 @@ LightFace_CalculateDirt(lightsurf_t *lightsurf)
{
const globalconfig_t &cfg = *lightsurf->cfg;
assert(dirt_in_use);
Q_assert(dirt_in_use);
const dmodel_t *selfshadow = lightsurf->modelinfo->shadowself.boolValue() ? lightsurf->modelinfo->model : NULL;
@ -2011,7 +2011,7 @@ LightFace_CalculateDirt(lightsurf_t *lightsurf)
rs->pushRay(i, lightsurf->points[i], dir, cfg.dirtDepth.floatValue(), selfshadow);
}
assert(rs->numPushedRays() == lightsurf->numpoints);
Q_assert(rs->numPushedRays() == lightsurf->numpoints);
// trace the batch
rs->tracePushedRaysIntersection();
@ -2109,7 +2109,7 @@ WriteLightmaps(const bsp2_t *bsp, bsp2_dface_t *face, facesup_t *facesup, const
/* final number of lightmaps */
const int numstyles = static_cast<int>(sorted.size());
assert(numstyles <= MAXLIGHTMAPS);
Q_assert(numstyles <= MAXLIGHTMAPS);
/* update face info (either core data or supplementary stuff) */
if (facesup)
@ -2151,9 +2151,9 @@ WriteLightmaps(const bsp2_t *bsp, bsp2_dface_t *face, facesup_t *facesup, const
// sanity check that we don't save a lightmap for a non-lightmapped face
{
const char *texname = Face_TextureName(bsp, face);
assert(!(bsp->texinfo[face->texinfo].flags & TEX_SPECIAL));
assert(Q_strcasecmp(texname, "skip") != 0);
assert(Q_strcasecmp(texname, "trigger") != 0);
Q_assert(!(bsp->texinfo[face->texinfo].flags & TEX_SPECIAL));
Q_assert(Q_strcasecmp(texname, "skip") != 0);
Q_assert(Q_strcasecmp(texname, "trigger") != 0);
}
int width = (lightsurf->texsize[0] + 1) * oversample;

View File

@ -150,8 +150,8 @@ MakeTnodes_r(int nodenum, const bsp2_t *bsp)
bsp2_dnode_t *node;
bsp2_dleaf_t *leaf;
assert(nodenum >= 0);
assert(nodenum < bsp->numnodes);
Q_assert(nodenum >= 0);
Q_assert(nodenum < bsp->numnodes);
tnode = &tnodes[nodenum];
node = bsp->dnodes + nodenum;
@ -279,7 +279,7 @@ MakeFaceInfo(const bsp2_t *bsp, const bsp2_dface_t *face, faceinfo_t *info)
for (int i=0; i<face->numedges; i++)
{
const vec_t *v = GetSurfaceVertexPoint(bsp, face, i);
assert(!SphereCullPoint(info, v));
Q_assert(!SphereCullPoint(info, v));
}
//test
{
@ -290,7 +290,7 @@ MakeFaceInfo(const bsp2_t *bsp, const bsp2_dface_t *face, faceinfo_t *info)
vec3_t n = {1, 0, 0};
VectorMA(centroid, radius, n, test);
assert(SphereCullPoint(info, test));
Q_assert(SphereCullPoint(info, test));
}
#endif
}
@ -895,7 +895,7 @@ 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, const vec_t *normalcontrib = nullptr) {
bsp_ray_t r { i, origin, dir, dist, selfshadow, color, normalcontrib };
_rays.push_back(r);
assert(_rays.size() <= _maxrays);
Q_assert(_rays.size() <= _maxrays);
}
virtual size_t numPushedRays() {

View File

@ -105,7 +105,7 @@ CreateGeometryFromWindings(RTCScene scene, const std::vector<winding_t *> &windi
int numtris = 0;
int numverts = 0;
for (const auto &winding : windings) {
assert(winding->numpoints >= 3);
Q_assert(winding->numpoints >= 3);
numtris += (winding->numpoints - 2);
numverts += winding->numpoints;
}
@ -144,8 +144,8 @@ CreateGeometryFromWindings(RTCScene scene, const std::vector<winding_t *> &windi
}
vert_index += winding->numpoints;
}
assert(vert_index == numverts);
assert(tri_index == numtris);
Q_assert(vert_index == numverts);
Q_assert(tri_index == numtris);
rtcUnmapBuffer(scene, geomID, RTC_INDEX_BUFFER);
}
@ -465,7 +465,7 @@ MakeFaces(const bsp2_t *bsp, const dmodel_t *model)
std::vector<winding_t *> result;
std::vector<plane_t> planes;
MakeFaces_r(bsp, model->headnode[0], &planes, &result);
assert(planes.empty());
Q_assert(planes.empty());
return result;
}
@ -474,7 +474,7 @@ void
Embree_TraceInit(const bsp2_t *bsp)
{
bsp_static = bsp;
assert(device == nullptr);
Q_assert(device == nullptr);
std::vector<const bsp2_dface_t *> skyfaces, solidfaces, fencefaces, selfshadowfaces;
@ -534,7 +534,7 @@ Embree_TraceInit(const bsp2_t *bsp)
for (int i=0; i<bsp->nummodels; i++) {
perModelScenes.push_back(CreatePerModelScene(device, bsp, &bsp->dmodels[i]));
}
assert(perModelScenes.size() == bsp->nummodels);
Q_assert(perModelScenes.size() == bsp->nummodels);
scene = rtcDeviceNewScene(device, RTC_SCENE_STATIC | RTC_SCENE_COHERENT, RTC_INTERSECT1 | RTC_INTERSECT_STREAM);
skygeom = CreateGeometry(bsp, scene, skyfaces);
@ -729,7 +729,7 @@ 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, const vec_t *normalcontrib = nullptr) {
assert(_numrays<_maxrays);
Q_assert(_numrays<_maxrays);
_rays[_numrays] = SetupRay(origin, dir, dist, selfshadow);
_rays_maxdist[_numrays] = dist;
_point_indices[_numrays] = i;
@ -747,7 +747,7 @@ public:
}
virtual void tracePushedRaysOcclusion() {
//assert(_state == streamstate_t::READY);
//Q_assert(_state == streamstate_t::READY);
if (!_numrays)
return;
@ -773,22 +773,22 @@ public:
}
virtual bool getPushedRayOccluded(size_t j) {
assert(j < _maxrays);
Q_assert(j < _maxrays);
return (_rays[j].geomID != RTC_INVALID_GEOMETRY_ID);
}
virtual float getPushedRayDist(size_t j) {
assert(j < _maxrays);
Q_assert(j < _maxrays);
return _rays_maxdist[j];
}
virtual float getPushedRayHitDist(size_t j) {
assert(j < _maxrays);
Q_assert(j < _maxrays);
return _rays[j].tfar;
}
virtual hittype_t getPushedRayHitType(size_t j) {
assert(j < _maxrays);
Q_assert(j < _maxrays);
if (_rays[j].geomID == RTC_INVALID_GEOMETRY_ID) {
return hittype_t::NONE;
@ -800,25 +800,25 @@ public:
}
virtual void getPushedRayDir(size_t j, vec3_t out) {
assert(j < _maxrays);
Q_assert(j < _maxrays);
for (int i=0; i<3; i++) {
out[i] = _rays[j].dir[i];
}
}
virtual int getPushedRayPointIndex(size_t j) {
// assert(_state != streamstate_t::READY);
assert(j < _maxrays);
// Q_assert(_state != streamstate_t::READY);
Q_assert(j < _maxrays);
return _point_indices[j];
}
virtual void getPushedRayColor(size_t j, vec3_t out) {
assert(j < _maxrays);
Q_assert(j < _maxrays);
VectorCopy(_ray_colors[j], out);
}
virtual void getPushedRayNormalContrib(size_t j, vec3_t out) {
assert(j < _maxrays);
Q_assert(j < _maxrays);
VectorCopy(_ray_normalcontribs[j], out);
}