From a807204fe6eeae2c4cd4ee635ce9f40ec64c9dcd Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 6 Aug 2016 15:37:00 -0700 Subject: [PATCH] build: vs2013 compat changes --- include/common/cmdlib.h | 3 +++ include/common/mathlib.h | 1 + include/light/entities.hh | 15 +++++++-------- include/light/light.hh | 8 ++++---- include/vis/leafbits.h | 4 +++- light/ltface.cc | 2 +- light/trace.cc | 4 ++-- light/trace_embree.cc | 6 +++--- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/include/common/cmdlib.h b/include/common/cmdlib.h index ce7bd993..18909e7c 100644 --- a/include/common/cmdlib.h +++ b/include/common/cmdlib.h @@ -45,6 +45,9 @@ typedef unsigned char byte; #ifdef _MSC_VER #define __func__ __FUNCTION__ +#ifndef __cplusplus +#define inline _inline +#endif #endif #ifdef __GNUC__ diff --git a/include/common/mathlib.h b/include/common/mathlib.h index 17c9d98d..2c2f653b 100644 --- a/include/common/mathlib.h +++ b/include/common/mathlib.h @@ -22,6 +22,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/include/light/entities.hh b/include/light/entities.hh index 01ec5559..f45c6fb7 100644 --- a/include/light/entities.hh +++ b/include/light/entities.hh @@ -83,16 +83,9 @@ public: light_t(void) : spotlight { false }, - spotvec { 0, 0, 0 }, spotfalloff { 0 }, spotfalloff2 { 0 }, projectedmip { nullptr }, - projectionmatrix { - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - }, epairs {nullptr}, targetent {nullptr}, generated {false}, @@ -119,7 +112,13 @@ public: mangle { "mangle", 0, 0, 0 }, // not transformed to vec projangle { "project_mangle", 20, 0, 0 }, // not transformed to vec project_texture { "project_texture", "" } - {} + { + VectorSet(spotvec, 0, 0, 0); + + for (int i = 0; i < 16; i++) { + projectionmatrix[i] = 0; + } + } settingsdict_t settings() { return {{ diff --git a/include/light/light.hh b/include/light/light.hh index 094682d7..758576bd 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -579,8 +579,7 @@ public: class modelinfo_t { -private: - static constexpr float DEFAULT_PHONG_ANGLE = 89.0f; +#define DEFAULT_PHONG_ANGLE 89.0f public: const dmodel_t *model; @@ -607,7 +606,6 @@ public: modelinfo_t(const dmodel_t *m, float lmscale) : model { m }, lightmapscale { lmscale }, - offset { 0, 0, 0 }, minlight { "minlight", 0 }, shadow { "shadow", 0 }, shadowself { "shadowself", 0 }, @@ -616,7 +614,9 @@ public: phong_angle { "phong_angle", 0 }, minlight_exclude { "minlight_exclude", "" }, minlight_color { "minlight_color", 255, 255, 255, vec3_transformer_t::NORMALIZE_COLOR_TO_255 } - {} + { + VectorSet(offset, 0, 0, 0); + } settingsdict_t settings() { return {{ diff --git a/include/vis/leafbits.h b/include/vis/leafbits.h index c67ef1f3..a5bf5fe3 100644 --- a/include/vis/leafbits.h +++ b/include/vis/leafbits.h @@ -22,6 +22,7 @@ #include #include +#include /* Use some GCC builtins */ #if !defined(ffsl) && defined(__GNUC__) @@ -73,7 +74,8 @@ ClearLeafBit(leafbits_t *bits, int leafnum) static inline size_t LeafbitsSize(int numleafs) { - return offsetof(leafbits_t, bits[(numleafs + LEAFMASK) >> LEAFSHIFT]); + int numblocks = (numleafs + LEAFMASK) >> LEAFSHIFT; + return sizeof(leafbits_t) + (sizeof(leafblock_t) * numblocks); } #endif /* VIS_LEAFBITS_H */ diff --git a/light/ltface.cc b/light/ltface.cc index a05e346f..300c0fbb 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -1500,7 +1500,7 @@ LightFace_Entity(const bsp2_t *bsp, static void LightFace_Sky(const sun_t *sun, const lightsurf_t *lightsurf, lightmap_t *lightmaps) { - constexpr float MAX_SKY_DIST = 65536.0f; + const float MAX_SKY_DIST = 65536.0f; const modelinfo_t *modelinfo = lightsurf->modelinfo; const plane_t *plane = &lightsurf->plane; diff --git a/light/trace.cc b/light/trace.cc index f756c821..91654fbc 100644 --- a/light/trace.cc +++ b/light/trace.cc @@ -875,13 +875,13 @@ public: bsp_ray_t(int i, const vec_t *origin, const vec3_t dir, float dist, const dmodel_t *selfshadow, const vec_t *color) : _pointindex{i}, - _origin{origin[0], origin[1], origin[2]}, - _dir{dir[0], dir[1], dir[2]}, _maxdist{dist}, _selfshadow{selfshadow}, _hitdist{dist}, _hittype{hittype_t::NONE}, _hit_occluded{false} { + VectorCopy(origin, _origin); + VectorCopy(dir, _dir); if (color != nullptr) { VectorCopy(color, _color); } diff --git a/light/trace_embree.cc b/light/trace_embree.cc index 85b3daa8..5bbcf0ca 100644 --- a/light/trace_embree.cc +++ b/light/trace_embree.cc @@ -33,7 +33,7 @@ using namespace std; -static constexpr float MAX_SKY_RAY_DEPTH = 8192.0f; +static const float MAX_SKY_RAY_DEPTH = 8192.0f; /** * i is between 0 and face->numedges - 1 @@ -197,8 +197,8 @@ Embree_FilterFuncN(int* valid, const struct RTCHitN* potentialHit, const size_t N) { - constexpr int VALID = -1; - constexpr int INVALID = 0; + const int VALID = -1; + const int INVALID = 0; for (size_t i=0; i