light: add _lightgrid_hint point entity key for customizing lightgrid bounds
use it as a info_null key: "_lightgrid_hint" "1"
This commit is contained in:
parent
7b8e55f594
commit
48fe527955
|
|
@ -194,6 +194,17 @@ public:
|
|||
|
||||
constexpr value_type size() const { return maxs() - mins(); }
|
||||
|
||||
constexpr bool valid() const {
|
||||
value_type our_size = size();
|
||||
|
||||
if (our_size[0] < static_cast<V>(0)
|
||||
|| our_size[1] < static_cast<V>(0)
|
||||
|| our_size[2] < static_cast<V>(0)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
constexpr aabb grow(const value_type &size) const { return {mins() - size, maxs() + size}; }
|
||||
|
||||
constexpr value_type &operator[](const size_t &index) { return m_corners[index]; }
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ public:
|
|||
void ResetLightEntities();
|
||||
std::string TargetnameForLightStyle(int style);
|
||||
std::vector<std::unique_ptr<light_t>> &GetLights();
|
||||
const std::vector<entdict_t> &GetEntdicts();
|
||||
std::vector<sun_t> &GetSuns();
|
||||
std::vector<entdict_t> &GetRadLights();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@
|
|||
#include <common/bsputils.hh>
|
||||
#include <common/parallel.hh>
|
||||
|
||||
std::vector<std::unique_ptr<light_t>> all_lights;
|
||||
std::vector<sun_t> all_suns;
|
||||
std::vector<entdict_t> entdicts;
|
||||
std::vector<entdict_t> radlights;
|
||||
static std::vector<std::unique_ptr<light_t>> all_lights;
|
||||
static std::vector<sun_t> all_suns;
|
||||
static std::vector<entdict_t> entdicts;
|
||||
static std::vector<entdict_t> radlights;
|
||||
static std::vector<std::pair<std::string, int>> lightstyleForTargetname;
|
||||
static std::vector<std::unique_ptr<light_t>> surfacelight_templates;
|
||||
static std::ofstream surflights_dump_file;
|
||||
|
|
@ -60,6 +60,11 @@ std::vector<std::unique_ptr<light_t>> &GetLights()
|
|||
return all_lights;
|
||||
}
|
||||
|
||||
const std::vector<entdict_t> &GetEntdicts()
|
||||
{
|
||||
return entdicts;
|
||||
}
|
||||
|
||||
std::vector<sun_t> &GetSuns()
|
||||
{
|
||||
return all_suns;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,30 @@ static std::vector<uint8_t> StringToVector(const std::string &str)
|
|||
return result;
|
||||
}
|
||||
|
||||
static aabb3f LightGridBounds(const mbsp_t &bsp)
|
||||
{
|
||||
aabb3f result;
|
||||
|
||||
// see if `_lightgrid_hint` entities are in use
|
||||
for (auto &entity : GetEntdicts()) {
|
||||
if (entity.get_int("_lightgrid_hint")) {
|
||||
qvec3d point{};
|
||||
entity.get_vector("origin", point);
|
||||
result += point;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.valid()) {
|
||||
auto size = result.size();
|
||||
if (size[0] > 0 && size[1] > 0 && size[2] > 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = Model_BoundsOfFaces(bsp, bsp.dmodels[0]);
|
||||
return result;
|
||||
}
|
||||
|
||||
void LightGrid(bspdata_t *bspdata)
|
||||
{
|
||||
if (!light_options.lightgrid.value())
|
||||
|
|
@ -60,9 +84,9 @@ void LightGrid(bspdata_t *bspdata)
|
|||
|
||||
auto &bsp = std::get<mbsp_t>(bspdata->bsp);
|
||||
|
||||
auto faces_size = Model_BoundsOfFaces(bsp, bsp.dmodels[0]);
|
||||
const qvec3f grid_maxs = faces_size.maxs();
|
||||
const qvec3f grid_mins = faces_size.mins();
|
||||
const auto grid_bounds = LightGridBounds(bsp);
|
||||
const qvec3f grid_maxs = grid_bounds.maxs();
|
||||
const qvec3f grid_mins = grid_bounds.mins();
|
||||
const qvec3f world_size = grid_maxs - grid_mins;
|
||||
|
||||
// number of grid points on each axis
|
||||
|
|
|
|||
|
|
@ -306,6 +306,18 @@ static void WriteLeafVolumes(const std::vector<portal_t *> &leakline, std::strin
|
|||
WriteBspBrushMap(filename_suffix, volumes_to_write);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this entity allowed to be in the void without causing a leak?
|
||||
*/
|
||||
static bool IsNofillEntity(const entdict_t &edict)
|
||||
{
|
||||
if (edict.get_int("_nofill"))
|
||||
return true;
|
||||
if (edict.get_int("_lightgrid_hint"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
FindOccupiedLeafs
|
||||
|
|
@ -323,7 +335,7 @@ static void MarkOccupiedClusters(node_t *headnode)
|
|||
continue;
|
||||
|
||||
// skip nofill entities
|
||||
if (entity.epairs.has("_nofill") && entity.epairs.get_int("_nofill")) {
|
||||
if (IsNofillEntity(entity.epairs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue