remove implicit conversion for qplane3

This commit is contained in:
Jonathan 2023-11-19 19:41:58 -05:00
parent 0ea6b0989c
commit ec452e2291
14 changed files with 45 additions and 45 deletions

View File

@ -786,7 +786,7 @@ int bsputil_main(int argc, char **argv)
std::reverse(pts.begin(), pts.end());
}
auto scaled = dplane_t{pts.plane(), p.type};
dplane_t scaled{qplane3f(pts.plane()), p.type};
plane_remap[i] = new_planes.add_or_find_plane(scaled);
i++;

View File

@ -125,10 +125,10 @@ qvec3d Face_Normal(const mbsp_t *bsp, const mface_t *f)
return Face_Plane(bsp, f).normal;
}
qplane3d Face_Plane(const mbsp_t *bsp, const mface_t *f)
qplane3f Face_Plane(const mbsp_t *bsp, const mface_t *f)
{
Q_assert(f->planenum >= 0 && f->planenum < bsp->dplanes.size());
qplane3d result = bsp->dplanes[f->planenum];
qplane3f result = bsp->dplanes[f->planenum];
if (f->side) {
return -result;
@ -289,7 +289,7 @@ static std::vector<qplane3d> Face_AllocInwardFacingEdgePlanes(const mbsp_t *bsp,
std::vector<qplane3d> out;
out.reserve(face->numedges);
const qplane3d faceplane = Face_Plane(bsp, face);
const qplane3f faceplane = Face_Plane(bsp, face);
for (int i = 0; i < face->numedges; i++) {
const qvec3f &v0 = GetSurfaceVertexPoint(bsp, face, i);
const qvec3f &v1 = GetSurfaceVertexPoint(bsp, face, (i + 1) % face->numedges);
@ -836,7 +836,7 @@ qmat4x4f WorldToTexSpace(const mbsp_t *bsp, const mface_t *f)
Q_assert_unreachable();
return qmat4x4f();
}
const qplane3d plane = Face_Plane(bsp, f);
const qplane3f plane = Face_Plane(bsp, f);
// [s]
// T * vec = [t]
@ -844,10 +844,10 @@ qmat4x4f WorldToTexSpace(const mbsp_t *bsp, const mface_t *f)
// [?]
qmat4x4f T{
tex->vecs.at(0, 0), tex->vecs.at(1, 0), static_cast<float>(plane.normal[0]), 0, // col 0
tex->vecs.at(0, 1), tex->vecs.at(1, 1), static_cast<float>(plane.normal[1]), 0, // col 1
tex->vecs.at(0, 2), tex->vecs.at(1, 2), static_cast<float>(plane.normal[2]), 0, // col 2
tex->vecs.at(0, 3), tex->vecs.at(1, 3), static_cast<float>(-plane.dist), 1 // col 3
tex->vecs.at(0, 0), tex->vecs.at(1, 0), plane.normal[0], 0, // col 0
tex->vecs.at(0, 1), tex->vecs.at(1, 1), plane.normal[1], 0, // col 1
tex->vecs.at(0, 2), tex->vecs.at(1, 2), plane.normal[2], 0, // col 2
tex->vecs.at(0, 3), tex->vecs.at(1, 3), -plane.dist, 1 // col 3
};
return T;
}
@ -891,7 +891,7 @@ faceextents_t::faceextents_t(const mface_t &face, const mbsp_t &bsp, float light
lm_extents[i] = static_cast<int>(tex_bounds[1][i] - tex_bounds[0][i]);
if (lm_extents[i] >= MAXDIMENSION * (16.0 / lightmapshift)) {
const qplane3d plane = Face_Plane(&bsp, &face);
const qplane3f plane = Face_Plane(&bsp, &face);
const qvec3f &point = Face_PointAtIndex(&bsp, &face, 0); // grab first vert
const char *texname = Face_TextureName(&bsp, &face);

View File

@ -982,7 +982,7 @@ decomp_plane_t MakeDecompPlane(const mbsp_t *bsp, const bsp2_dnode_t *node, cons
const dplane_t &dplane = *BSP_GetPlane(bsp, node->planenum);
return {// flip the plane if we went down the front side, since we want the outward-facing plane
front ? -dplane : dplane, node};
qplane3d(front ? -dplane : dplane), node};
}
decomp_plane_t MakeClipDecompPlane(const mbsp_t *bsp, const bsp2_dclipnode_t *clipnode, const bool front)
@ -990,7 +990,7 @@ decomp_plane_t MakeClipDecompPlane(const mbsp_t *bsp, const bsp2_dclipnode_t *cl
const dplane_t &dplane = *BSP_GetPlane(bsp, clipnode->planenum);
return {// flip the plane if we went down the front side, since we want the outward-facing plane
front ? -dplane : dplane, nullptr, nullptr, clipnode};
qplane3d(front ? -dplane : dplane), nullptr, nullptr, clipnode};
}
/**
@ -1084,7 +1084,7 @@ static std::vector<compiled_brush_t> DecompileBrushTask(
{
for (size_t i = 0; i < task.brush->numsides; i++) {
const q2_dbrushside_qbism_t *side = &bsp->dbrushsides[task.brush->firstside + i];
decomp_plane_t &plane = task.allPlanes.emplace_back(decomp_plane_t{{bsp->dplanes[side->planenum]}});
decomp_plane_t &plane = task.allPlanes.emplace_back(decomp_plane_t{qplane3d{bsp->dplanes[side->planenum]}});
plane.source = side;
}

View File

@ -46,7 +46,7 @@ mface_t *BSP_GetFace(mbsp_t *bsp, int fnum);
int Face_VertexAtIndex(const mbsp_t *bsp, const mface_t *f, int v);
const qvec3f &Face_PointAtIndex(const mbsp_t *bsp, const mface_t *f, int v);
qplane3d Face_Plane(const mbsp_t *bsp, const mface_t *f);
qplane3f Face_Plane(const mbsp_t *bsp, const mface_t *f);
const mtexinfo_t *Face_Texinfo(const mbsp_t *bsp, const mface_t *face);
const miptex_t *Face_Miptex(const mbsp_t *bsp, const mface_t *face);
const char *Face_TextureName(const mbsp_t *bsp, const mface_t *face);

View File

@ -743,7 +743,8 @@ public:
return {normal, qv::dot(at(0), normal)};
}
static winding_base_t from_plane(const qplane3d &plane, const vec_t &worldextent)
template<typename TPlane>
static winding_base_t from_plane(const qplane3<TPlane> &plane, const vec_t &worldextent)
{
/* find the major axis */
vec_t max = -VECT_MAX;
@ -863,8 +864,9 @@ public:
}
// dists/sides can be null, or must have (size() + 1) reserved
template<typename TPlane>
inline std::array<size_t, SIDE_TOTAL> calc_sides(
const qplane3d &plane, vec_t *dists, planeside_t *sides, const vec_t &on_epsilon = DEFAULT_ON_EPSILON) const
const qplane3<TPlane> &plane, vec_t *dists, planeside_t *sides, const vec_t &on_epsilon = DEFAULT_ON_EPSILON) const
{
std::array<size_t, SIDE_TOTAL> counts{};
@ -997,8 +999,9 @@ public:
Cheaper than clip(...)[SIDE_FRONT]
==================
*/
template<typename TPlane>
std::optional<winding_base_t> clip_front(
const qplane3d &plane, const vec_t &on_epsilon = DEFAULT_ON_EPSILON, const bool &keepon = false)
const qplane3<TPlane> &plane, const vec_t &on_epsilon = DEFAULT_ON_EPSILON, const bool &keepon = false)
{
vec_t *dists = (vec_t *)alloca(sizeof(vec_t) * (size() + 1));
planeside_t *sides = (planeside_t *)alloca(sizeof(planeside_t) * (size() + 1));

View File

@ -772,7 +772,7 @@ public:
// convert from plane of a different type
template<typename T2>
constexpr qplane3(const qplane3<T2> &plane)
explicit constexpr qplane3(const qplane3<T2> &plane)
: qplane3(plane.normal, static_cast<T2>(plane.dist))
{
}
@ -874,7 +874,7 @@ public:
* Casting from another matrix type of the same size
*/
template<class T2>
constexpr qmat(const qmat<T2, NRow, NCol> &other)
explicit constexpr qmat(const qmat<T2, NRow, NCol> &other)
{
for (size_t i = 0; i < NRow * NCol; i++)
this->m_values[i] = static_cast<T>(other.m_values[i]);

View File

@ -103,7 +103,7 @@ struct lightsurf_t
bool twosided;
int32_t object_channel_mask;
qplane3d plane;
qplane3f plane;
qvec3d snormal;
qvec3d tnormal;

View File

@ -1278,14 +1278,11 @@ static void CreateSurfaceLightOnFaceSubdivision(const mface_t *face, const model
const light_t *surflight_template, const mbsp_t *bsp, int numverts, const qvec3d *verts)
{
qvec3d midpoint = qv::PolyCentroid(verts, verts + numverts);
qplane3d plane = bsp->dplanes[face->planenum];
qplane3f plane = Face_Plane(bsp, face);
/* Nudge 2 units (by default) along face normal */
if (face->side) {
plane = -plane;
}
vec_t offset = surflight_template->epairs->get_float("_surface_offset");
if (offset == 0)
offset = 2.0;

View File

@ -667,7 +667,7 @@ static std::unique_ptr<lightsurf_t> Lightsurf_Init(const modelinfo_t *modelinfo,
}
/* Set up the plane, not including model offset */
qplane3d &plane = lightsurf->plane;
qplane3f &plane = lightsurf->plane;
if (face->side) {
plane = -bsp->dplanes[face->planenum];
} else {
@ -1158,7 +1158,7 @@ static void LightFace_Entity(
{
const settings::worldspawn_keys &cfg = *lightsurf->cfg;
const modelinfo_t *modelinfo = lightsurf->modelinfo;
const qplane3d *plane = &lightsurf->plane;
const qplane3f &plane = lightsurf->plane;
/* vis cull */
if (light_options.visapprox.value() == visapprox_t::VIS &&
@ -1168,7 +1168,7 @@ static void LightFace_Entity(
return;
}
const vec_t planedist = plane->distance_to(entity->origin.value());
const vec_t planedist = plane.distance_to(entity->origin.value());
/* don't bother with lights behind the surface.
@ -1340,7 +1340,7 @@ static void LightFace_Sky(const mbsp_t *bsp, const sun_t *sun, lightsurf_t *ligh
{
const settings::worldspawn_keys &cfg = *lightsurf->cfg;
const modelinfo_t *modelinfo = lightsurf->modelinfo;
const qplane3d *plane = &lightsurf->plane;
const qplane3f &plane = lightsurf->plane;
// FIXME: Normalized sun vector should be stored in the sun_t. Also clarify which way the vector points (towards or
// away..)
@ -1348,7 +1348,7 @@ static void LightFace_Sky(const mbsp_t *bsp, const sun_t *sun, lightsurf_t *ligh
qvec3d incoming = qv::normalize(sun->sunvec);
/* Don't bother if surface facing away from sun */
const vec_t dp = qv::dot(incoming, plane->normal);
const vec_t dp = qv::dot(incoming, plane.normal);
if (dp < -LIGHT_ANGLE_EPSILON && !lightsurf->curved && !lightsurf->twosided) {
return;
}

View File

@ -466,7 +466,7 @@ void CalculateVertexNormals(const mbsp_t *bsp)
auto *f_texinfo = Face_Texinfo(bsp, &f);
const auto f_points = Face_Points(bsp, &f);
const qvec3d f_norm = Face_Normal(bsp, &f);
const qplane3d f_plane = Face_Plane(bsp, &f);
const qplane3f f_plane = Face_Plane(bsp, &f);
// any face normal within this many degrees can be smoothed with this face
vec_t f_phong_angle = extended_texinfo_flags[f.texinfo].phong_angle;

View File

@ -453,9 +453,9 @@ static void PerRay_FilterFuncN(const struct RTCFilterFunctionNArguments *args)
// building faces for skip-textured bmodels
qplane3d Node_Plane(const mbsp_t *bsp, const bsp2_dnode_t *node, bool side)
qplane3f Node_Plane(const mbsp_t *bsp, const bsp2_dnode_t *node, bool side)
{
qplane3d plane = bsp->dplanes[node->planenum];
qplane3f plane = bsp->dplanes[node->planenum];
if (side) {
return -plane;
@ -468,16 +468,16 @@ qplane3d Node_Plane(const mbsp_t *bsp, const bsp2_dnode_t *node, bool side)
* `planes` all of the node planes that bound this leaf, facing inward.
*/
static void Leaf_MakeFaces(const mbsp_t *bsp, const modelinfo_t *modelinfo, const mleaf_t *leaf,
const std::vector<qplane3d> &planes, std::vector<polylib::winding_t> &result)
const std::vector<qplane3f> &planes, std::vector<polylib::winding_t> &result)
{
for (const qplane3d &plane : planes) {
for (const qplane3f &plane : planes) {
// flip the inward-facing split plane to get the outward-facing plane of the face we're constructing
qplane3d faceplane = -plane;
qplane3f faceplane = -plane;
std::optional<polylib::winding_t> winding = polylib::winding_t::from_plane(faceplane, 10e6);
// clip `winding` by all of the other planes
for (const qplane3d &plane2 : planes) {
for (const qplane3f &plane2 : planes) {
if (&plane2 == &plane)
continue;
@ -497,7 +497,7 @@ static void Leaf_MakeFaces(const mbsp_t *bsp, const modelinfo_t *modelinfo, cons
}
}
void MakeFaces_r(const mbsp_t *bsp, const modelinfo_t *modelinfo, const int nodenum, std::vector<qplane3d> *planes,
void MakeFaces_r(const mbsp_t *bsp, const modelinfo_t *modelinfo, const int nodenum, std::vector<qplane3f> *planes,
std::vector<polylib::winding_t> &result)
{
if (nodenum < 0) {
@ -527,7 +527,7 @@ void MakeFaces_r(const mbsp_t *bsp, const modelinfo_t *modelinfo, const int node
static void MakeFaces(
const mbsp_t *bsp, const modelinfo_t *modelinfo, const dmodelh2_t *model, std::vector<polylib::winding_t> &result)
{
std::vector<qplane3d> planes;
std::vector<qplane3f> planes;
MakeFaces_r(bsp, modelinfo, model->headnode[0], &planes, result);
Q_assert(planes.empty());
}

View File

@ -230,7 +230,7 @@ static void ClipInside(
bool spurious_onplane = false;
{
std::array<size_t, SIDE_TOTAL> counts =
face.w.calc_sides(splitplane, nullptr, nullptr, qbsp_options.epsilon.value());
face.w.calc_sides(splitplane.get_plane(), nullptr, nullptr, qbsp_options.epsilon.value());
if (counts[SIDE_ON] && !counts[SIDE_FRONT] && !counts[SIDE_BACK]) {
spurious_onplane = true;
@ -241,8 +241,8 @@ static void ClipInside(
/* Handle exactly on-plane faces (ignoring direction) */
if ((face.planenum ^ 1) == (clipface.planenum ^ 1) || spurious_onplane) {
const qplane3d faceplane = face.get_plane();
const qplane3d clipfaceplane = clipface.get_plane();
const qplane3d &faceplane = face.get_plane();
const qplane3d &clipfaceplane = clipface.get_plane();
const vec_t dp = qv::dot(faceplane.normal, clipfaceplane.normal);
const bool opposite = (dp < 0);

View File

@ -361,7 +361,7 @@ inline void CalculateBrushBounds(mapbrush_t &ob)
continue;
}
const auto &plane = map.get_plane(ob.faces[j].planenum ^ 1);
w = w->clip_front(plane, 0); // CLIP_EPSILON);
w = w->clip_front(plane.get_plane(), 0); // CLIP_EPSILON);
}
if (w) {

View File

@ -204,9 +204,9 @@ static std::optional<winding_t> BaseWindingForNode(const node_t *node)
for (auto *np = node->parent; np && w;) {
if (np->children[0] == node) {
w = w->clip_front(np->get_plane(), BASE_WINDING_EPSILON, false);
w = w->clip_front(np->get_plane().get_plane(), BASE_WINDING_EPSILON, false);
} else {
w = w->clip_back(np->get_plane(), BASE_WINDING_EPSILON, false);
w = w->clip_back(np->get_plane().get_plane(), BASE_WINDING_EPSILON, false);
}
node = np;