build perf: de-templateize texvec<T>, we only need texvecf

This commit is contained in:
Eric Wasylishen 2023-06-25 18:25:45 -06:00
parent 26dedb603f
commit 36e157254c
3 changed files with 23 additions and 24 deletions

View File

@ -2429,6 +2429,22 @@ inline void ReadQ2BSP(lump_reader &reader, T &bsp)
reader.read(Q2_LUMP_AREAPORTALS, bsp.dareaportals);
}
void texvecf::stream_read(std::istream &stream)
{
for (size_t i = 0; i < 2; i++)
for (size_t x = 0; x < 4; x++) {
stream >= this->at(i, x);
}
}
void texvecf::stream_write(std::ostream &stream) const
{
for (size_t i = 0; i < 2; i++)
for (size_t x = 0; x < 4; x++) {
stream <= this->at(i, x);
}
}
void bspdata_t::bspxentries::transfer(const char *xname, std::vector<uint8_t> &xdata)
{
entries.insert_or_assign(xname, std::move(xdata));

View File

@ -66,8 +66,7 @@ struct texdef_valve_t
}
// FIXME: merge with map.cc copy
template<typename T>
inline texdef_valve_t(const texvec<T> &in_vecs)
inline texdef_valve_t(const texvecf &in_vecs)
{
// From the valve -> bsp code,
// out->vecs[n].xyz = axis[n].xyz / scale[n];

View File

@ -371,10 +371,9 @@ struct fmt::formatter<bspversion_t>
}
};
template<typename T>
struct texvec : qmat<T, 2, 4>
struct texvecf : qmat<float, 2, 4>
{
using qmat<T, 2, 4>::qmat;
using qmat<float, 2, 4>::qmat;
template<typename T2>
constexpr qvec<T2, 2> uvs(const qvec<T2, 3> &pos) const
@ -392,31 +391,16 @@ struct texvec : qmat<T, 2, 4>
// Not blit compatible because qmat is column-major but
// texvecs are row-major
void stream_read(std::istream &stream)
{
for (size_t i = 0; i < 2; i++)
for (size_t x = 0; x < 4; x++) {
stream >= this->at(i, x);
}
}
void stream_write(std::ostream &stream) const
{
for (size_t i = 0; i < 2; i++)
for (size_t x = 0; x < 4; x++) {
stream <= this->at(i, x);
}
}
void stream_read(std::istream &stream);
void stream_write(std::ostream &stream) const;
};
// Fmt support
template<class T>
struct fmt::formatter<texvec<T>> : fmt::formatter<qmat<T, 2, 4>>
template<>
struct fmt::formatter<texvecf> : fmt::formatter<qmat<float, 2, 4>>
{
};
using texvecf = texvec<float>;
// type to store a hull index; max 256 hulls, zero is valid.
using hull_index_t = std::optional<uint8_t>;