lightpreview: fix bmodel rendering when vis culling is in use
This commit is contained in:
parent
7b83aa5976
commit
9f7ba65758
|
|
@ -719,6 +719,25 @@ std::unordered_map<int, std::vector<uint8_t>> DecompressAllVis(const mbsp_t *bsp
|
|||
return result;
|
||||
}
|
||||
|
||||
static void BSP_VisitAllLeafs_R(
|
||||
const mbsp_t &bsp, const int nodenum, const std::function<void(const mleaf_t &)> &visitor)
|
||||
{
|
||||
if (nodenum < 0) {
|
||||
auto *leaf = BSP_GetLeafFromNodeNum(&bsp, nodenum);
|
||||
visitor(*leaf);
|
||||
return;
|
||||
}
|
||||
|
||||
const bsp2_dnode_t &node = bsp.dnodes.at(nodenum);
|
||||
BSP_VisitAllLeafs_R(bsp, node.children[0], visitor);
|
||||
BSP_VisitAllLeafs_R(bsp, node.children[1], visitor);
|
||||
}
|
||||
|
||||
void BSP_VisitAllLeafs(const mbsp_t &bsp, const dmodelh2_t &model, const std::function<void(const mleaf_t &)> &visitor)
|
||||
{
|
||||
BSP_VisitAllLeafs_R(bsp, model.headnode[0], visitor);
|
||||
}
|
||||
|
||||
bspx_decoupled_lm_perface BSPX_DecoupledLM(const bspxentries_t &entries, int face_num)
|
||||
{
|
||||
auto &lump_bytes = entries.at("DECOUPLED_LM");
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ int LeafnumToVisleaf(int leafnum);
|
|||
void DecompressVis(const uint8_t *in, const uint8_t *inend, uint8_t *out, uint8_t *outend);
|
||||
std::unordered_map<int, std::vector<uint8_t>> DecompressAllVis(const mbsp_t *bsp, bool trans_water = false);
|
||||
|
||||
void BSP_VisitAllLeafs(const mbsp_t &bsp, const dmodelh2_t &model, const std::function<void(const mleaf_t &)> &visitor);
|
||||
|
||||
bspx_decoupled_lm_perface BSPX_DecoupledLM(const bspxentries_t &entries, int face_num);
|
||||
std::optional<bspxfacenormals> BSPX_FaceNormals(const mbsp_t &bsp, const bspxentries_t &entries);
|
||||
|
||||
|
|
|
|||
|
|
@ -396,16 +396,22 @@ void GLView::updateFaceVisibility()
|
|||
std::vector<uint8_t> face_flags;
|
||||
face_flags.resize(face_visibility_width, 0);
|
||||
|
||||
// check all leafs
|
||||
// FIXME: only world?
|
||||
|
||||
for (auto &leaf : bsp.dleafs) {
|
||||
// visit all world leafs: if they're visible, mark the appropriate faces
|
||||
BSP_VisitAllLeafs(bsp, bsp.dmodels[0], [&](const mleaf_t &leaf) {
|
||||
if (leaf_sees(&leaf)) {
|
||||
for (int ms = 0; ms < leaf.nummarksurfaces; ++ms) {
|
||||
int fnum = bsp.dleaffaces[leaf.firstmarksurface + ms];
|
||||
face_flags[fnum] = 16;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// set all bmodel faces to visible
|
||||
for (int mi = 1; mi < bsp.dmodels.size(); ++mi) {
|
||||
auto &model = bsp.dmodels[mi];
|
||||
for (int fi = model.firstface; fi < (model.firstface + model.numfaces); ++fi) {
|
||||
face_flags[fi] = 16;
|
||||
}
|
||||
}
|
||||
|
||||
setFaceVisibilityArray(face_flags.data());
|
||||
|
|
|
|||
Loading…
Reference in New Issue