VectorInverse, VectorSet, VectorClear gone

This commit is contained in:
Jonathan 2021-10-23 13:15:38 -04:00
parent c607c0d98f
commit 4dca2d7d07
6 changed files with 38 additions and 77 deletions

View File

@ -868,33 +868,6 @@ namespace qv
// "vec3" type. legacy; eventually will be replaced entirely
#define DEPRECATE_SNIFF [[deprecated]]
#undef DEPRECATE_SNIFF
#define DEPRECATE_SNIFF
template<typename T>
DEPRECATE_SNIFF constexpr void VectorInverse(T &v)
{
v[0] = -v[0];
v[1] = -v[1];
v[2] = -v[2];
}
template<typename T>
DEPRECATE_SNIFF constexpr void VectorSet(T &out, vec_t x, vec_t y, vec_t z)
{
out[0] = x;
out[1] = y;
out[2] = z;
}
template<typename T>
DEPRECATE_SNIFF constexpr void VectorClear(T &out)
{
out[0] = 0;
out[1] = 0;
out[2] = 0;
}
template<typename Ta, typename Tb, typename Tc>
DEPRECATE_SNIFF constexpr void VectorMA(const Ta &va, vec_t scale, const Tb &vb, Tc &vc)
{
@ -903,6 +876,9 @@ DEPRECATE_SNIFF constexpr void VectorMA(const Ta &va, vec_t scale, const Tb &vb,
vc[2] = va[2] + scale * vb[2];
}
#undef DEPRECATE_SNIFF
#define DEPRECATE_SNIFF
template<typename Tx, typename Ty, typename Tout>
DEPRECATE_SNIFF constexpr void VectorSubtract(const Tx &x, const Ty &y, Tout &out)
{

View File

@ -477,9 +477,8 @@ static void SetupSuns(const globalconfig_t &cfg)
} else if (VectorLengthSq(entity.mangle.vec3Value()) > 0) {
VectorCopy(entity.mangle.vec3Value(), sunvec);
} else { // Use { 0, 0, 0 } as sun target...
LogPrint("WARNING: sun missing target, { 0 0 0 } used.\n");
VectorCopy(entity.origin.vec3Value(), sunvec);
VectorInverse(sunvec);
LogPrint("WARNING: sun missing target, entity origin used.\n");
sunvec = -entity.origin.vec3Value();
}
// Add the sun
@ -582,16 +581,12 @@ static void SetupSkyDome(const globalconfig_t &cfg, vec_t upperLight, const qvec
}
/* create vertical sun */
VectorSet(direction, 0.0f, 0.0f, -1.0f);
if (sunlight2value > 0) {
AddSun(cfg, direction, sunlight2value, upperColor, upperDirt, upperAnglescale, upperStyle, upperSuntexture);
AddSun(cfg, { 0.0, 0.0, -1.0 }, sunlight2value, upperColor, upperDirt, upperAnglescale, upperStyle, upperSuntexture);
}
VectorSet(direction, 0.0f, 0.0f, 1.0f);
if (sunlight3value > 0) {
AddSun(cfg, direction, sunlight3value, lowerColor, lowerDirt, lowerAnglescale, lowerStyle, lowerSuntexture);
AddSun(cfg, { 0.0, 0.0, 1.0 }, sunlight3value, lowerColor, lowerDirt, lowerAnglescale, lowerStyle, lowerSuntexture);
}
}

View File

@ -1706,7 +1706,7 @@ static void LightFace_DirtDebug(const lightsurf_t *lightsurf, lightmapdict_t *li
for (int i = 0; i < lightsurf->numpoints; i++) {
lightsample_t *sample = &lightmap->samples[i];
const float light = 255 * Dirt_GetScaleFactor(cfg, lightsurf->occlusion[i], NULL, 0.0, lightsurf);
VectorSet(sample->color, light, light, light);
sample->color = { light };
}
Lightmap_Save(lightmaps, lightsurf, lightmap, 0);
@ -2354,14 +2354,14 @@ static void GetUpRtVecs(const qvec3d &normal, qvec3d &myUp, qvec3d &myRt)
/* check if the normal is aligned to the world-up */
if (normal[0] == 0.0f && normal[1] == 0.0f) {
if (normal[2] == 1.0f) {
VectorSet(myRt, 1.0f, 0.0f, 0.0f);
VectorSet(myUp, 0.0f, 1.0f, 0.0f);
myRt = { 1.0, 0.0, 0.0 };
myUp = { 0.0, 1.0, 0.0 };
} else if (normal[2] == -1.0f) {
VectorSet(myRt, -1.0f, 0.0f, 0.0f);
VectorSet(myUp, 0.0f, 1.0f, 0.0f);
myRt = { -1.0, 0.0, 0.0 };
myUp = { 0.0, 1.0, 0.0 };
}
} else {
constexpr qvec3d worldUp = { 0, 0, 1 };
constexpr qvec3d worldUp { 0, 0, 1 };
myRt = qv::normalize(qv::cross(normal, worldUp));
myUp = qv::normalize(qv::cross(myRt, normal));
}
@ -3112,14 +3112,15 @@ static void WriteSingleLightmap(const mbsp_t *bsp, const mface_t *face, const li
*out++ = light;
if (lux) {
qvec3d temp;
const qvec4f &direction = output_dir->at(sampleindex);
temp[0] = qv::dot(qvec3f(direction), qvec3f(lightsurf->snormal));
temp[1] = qv::dot(qvec3f(direction), qvec3f(lightsurf->tnormal));
temp[2] = qv::dot(qvec3f(direction), qvec3f(lightsurf->plane.normal));
qvec3d direction = output_dir->at(sampleindex).xyz();
qvec3d temp = {
qv::dot(direction, lightsurf->snormal),
qv::dot(direction, lightsurf->tnormal),
qv::dot(direction, lightsurf->plane.normal)
};
if (!temp[0] && !temp[1] && !temp[2])
VectorSet(temp, 0, 0, 1);
if (qv::emptyExact(temp))
temp = { 0, 0, 1 };
else
VectorNormalize(temp);

View File

@ -84,7 +84,7 @@ static void CheckFace(face_t *face, const mapface_t &sourceface)
qvec3d facenormal = plane.normal;
if (face->planeside)
VectorInverse(facenormal);
facenormal = -facenormal;
for (size_t i = 0; i < face->w.size(); i++) {
const qvec3d &p1 = face->w[i];

View File

@ -98,9 +98,9 @@ static face_t *TryMerge(face_t *f1, face_t *f2)
// check slope of connected lines
// if the slopes are colinear, the point can be removed
plane = &map.planes[f1->planenum];
VectorCopy(plane->normal, planenormal);
planenormal = plane->normal;
if (f1->planeside)
VectorInverse(planenormal);
planenormal = -planenormal;
back = f1->w[(i + f1->w.size() - 1) % f1->w.size()];
VectorSubtract(p1, back, delta);

View File

@ -92,33 +92,22 @@ static unsigned HashVec(const qvec3d &vec)
static void CanonicalVector(const qvec3d &p1, const qvec3d &p2, qvec3d &vec)
{
VectorSubtract(p2, p1, vec);
vec_t length = VectorNormalize(vec);
if (vec[0] > EQUAL_EPSILON)
return;
else if (vec[0] < -EQUAL_EPSILON) {
VectorInverse(vec);
return;
} else
vec[0] = 0;
vec = p2 - p1;
vec_t length = qv::normalizeInPlace(vec);
if (vec[1] > EQUAL_EPSILON)
for (size_t i = 0; i < 3; i++) {
if (vec[i] > EQUAL_EPSILON)
return;
else if (vec[1] < -EQUAL_EPSILON) {
VectorInverse(vec);
else if (vec[i] < -EQUAL_EPSILON) {
vec = -vec;
return;
} else
vec[1] = 0;
} else {
vec[i] = 0;
}
}
if (vec[2] > EQUAL_EPSILON)
return;
else if (vec[2] < -EQUAL_EPSILON) {
VectorInverse(vec);
return;
} else
vec[2] = 0;
LogPrint("WARNING: Line {}: Healing degenerate edge ({}) at ({:.3f} {:.3} {:.3})\n", length, p1[0], p1[1], p1[2]);
// FIXME: Line {}: was here but no line number can be grabbed here?
LogPrint("WARNING: Healing degenerate edge ({}) at ({:.3})\n", length, p1);
}
static wedge_t *FindEdge(const qvec3d &p1, const qvec3d &p2, vec_t &t1, vec_t &t2)