qbsp: factor out 'chops' condition in BrushGE
This commit is contained in:
parent
fb0fcfa535
commit
13612f18d0
|
|
@ -58,6 +58,8 @@ struct gamedef_generic_t : public gamedef_t
|
|||
|
||||
int32_t contents_priority(const contentflags_t &) const { throw std::bad_cast(); }
|
||||
|
||||
bool chops(const contentflags_t &) const { throw std::bad_cast(); }
|
||||
|
||||
contentflags_t create_extended_contents(const int32_t &) const { throw std::bad_cast(); }
|
||||
|
||||
contentflags_t create_empty_contents(const int32_t &) const { throw std::bad_cast(); }
|
||||
|
|
@ -169,6 +171,10 @@ struct gamedef_q1_like_t : public gamedef_t
|
|||
}
|
||||
}
|
||||
|
||||
bool chops(const contentflags_t &contents) const {
|
||||
return contents_are_solid(contents) || contents_are_sky(contents) || (contents.extended & CFLAGS_DETAIL);
|
||||
}
|
||||
|
||||
contentflags_t create_extended_contents(const int32_t &cflags) const { return {0, cflags}; }
|
||||
|
||||
contentflags_t create_empty_contents(const int32_t &cflags = 0) const
|
||||
|
|
@ -495,6 +501,13 @@ struct gamedef_q2_t : public gamedef_t
|
|||
}
|
||||
}
|
||||
|
||||
bool chops(const contentflags_t &contents) const
|
||||
{
|
||||
// TODO: ideally this could just check for Q2_CONTENTS_SOLID
|
||||
// once we implement detail as Q2_CONTENTS_SOLID|Q2_CONTENTS_DETAIL
|
||||
return contents_are_solid(contents) || (contents.extended & CFLAGS_DETAIL);
|
||||
}
|
||||
|
||||
contentflags_t create_extended_contents(const int32_t &cflags) const { return {0, cflags}; }
|
||||
|
||||
contentflags_t create_empty_contents(const int32_t &cflags) const { return {0, cflags}; }
|
||||
|
|
@ -973,6 +986,11 @@ int32_t contentflags_t::priority(const gamedef_t *game) const
|
|||
return game->contents_priority(*this);
|
||||
}
|
||||
|
||||
bool contentflags_t::chops(const gamedef_t* game) const
|
||||
{
|
||||
return game->chops(*this);
|
||||
}
|
||||
|
||||
bool contentflags_t::is_empty(const gamedef_t *game) const
|
||||
{
|
||||
return game->contents_are_empty(*this);
|
||||
|
|
|
|||
|
|
@ -632,8 +632,14 @@ struct contentflags_t
|
|||
// also match.
|
||||
bool types_equal(const contentflags_t &other, const gamedef_t *game) const;
|
||||
|
||||
// when multiple brushes contribute to a leaf, the higher priority
|
||||
// one determines the leaf contents
|
||||
int32_t priority(const gamedef_t *game) const;
|
||||
|
||||
// whether this should chop (if so, only lower priority content brushes get chopped)
|
||||
// should return true only for solid / opaque content types
|
||||
bool chops(const gamedef_t *game) const;
|
||||
|
||||
std::string to_string(const gamedef_t *game) const;
|
||||
};
|
||||
|
||||
|
|
@ -1767,6 +1773,7 @@ struct gamedef_t
|
|||
virtual contentflags_t cluster_contents(const contentflags_t &contents0, const contentflags_t &contents1) const = 0;
|
||||
virtual int32_t get_content_type(const contentflags_t &contents) const = 0;
|
||||
virtual int32_t contents_priority(const contentflags_t &contents) const = 0;
|
||||
virtual bool chops(const contentflags_t &) const = 0;
|
||||
virtual contentflags_t create_extended_contents(const int32_t &cflags = 0) const = 0;
|
||||
virtual contentflags_t create_empty_contents(const int32_t &cflags = 0) const = 0;
|
||||
virtual contentflags_t create_solid_contents(const int32_t &cflags = 0) const = 0;
|
||||
|
|
|
|||
|
|
@ -527,12 +527,7 @@ static bool BrushGE(const brush_t& a, const brush_t& b)
|
|||
{
|
||||
// only chop if at least one of the two contents is
|
||||
// opaque (solid, sky, or detail)
|
||||
if (!(a.contents.is_solid(options.target_game)
|
||||
|| b.contents.is_solid(options.target_game)
|
||||
|| a.contents.is_sky(options.target_game)
|
||||
|| b.contents.is_sky(options.target_game)
|
||||
|| a.contents.is_detail(CFLAGS_DETAIL)
|
||||
|| b.contents.is_detail(CFLAGS_DETAIL))) {
|
||||
if (!(a.contents.chops(options.target_game) || b.contents.chops(options.target_game))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue