qbsp: refactor out is_detail(int32_t types = CFLAGS_DETAIL_MASK) since it's going to depend on game now
This commit is contained in:
parent
47aa1f7476
commit
8c1095715c
|
|
@ -72,6 +72,12 @@ struct gamedef_generic_t : public gamedef_t
|
|||
|
||||
bool contents_are_any_detail(const contentflags_t &) const { throw std::bad_cast(); }
|
||||
|
||||
bool contents_are_detail_solid(const contentflags_t &contents) const { throw std::bad_cast(); }
|
||||
|
||||
bool contents_are_detail_fence(const contentflags_t &contents) const { throw std::bad_cast(); }
|
||||
|
||||
bool contents_are_detail_illusionary(const contentflags_t &contents) const { throw std::bad_cast(); }
|
||||
|
||||
bool contents_are_empty(const contentflags_t &) const { throw std::bad_cast(); }
|
||||
|
||||
bool contents_are_solid(const contentflags_t &) const { throw std::bad_cast(); }
|
||||
|
|
@ -213,6 +219,21 @@ struct gamedef_q1_like_t : public gamedef_t
|
|||
return ((contents.extended & CFLAGS_DETAIL_MASK) != 0);
|
||||
}
|
||||
|
||||
bool contents_are_detail_solid(const contentflags_t &contents) const
|
||||
{
|
||||
return ((contents.extended & CFLAGS_DETAIL) != 0);
|
||||
}
|
||||
|
||||
bool contents_are_detail_fence(const contentflags_t &contents) const
|
||||
{
|
||||
return ((contents.extended & CFLAGS_DETAIL_FENCE) != 0);
|
||||
}
|
||||
|
||||
bool contents_are_detail_illusionary(const contentflags_t &contents) const
|
||||
{
|
||||
return ((contents.extended & CFLAGS_DETAIL_ILLUSIONARY) != 0);
|
||||
}
|
||||
|
||||
bool contents_are_empty(const contentflags_t &contents) const
|
||||
{
|
||||
if (contents.extended & CFLAGS_CONTENTS_MASK)
|
||||
|
|
@ -539,6 +560,24 @@ struct gamedef_q2_t : public gamedef_t
|
|||
return ((contents.native & Q2_CONTENTS_DETAIL) != 0);
|
||||
}
|
||||
|
||||
bool contents_are_detail_solid(const contentflags_t &contents) const
|
||||
{
|
||||
// fixme-brushbsp: check native flag
|
||||
return ((contents.extended & CFLAGS_DETAIL) != 0);
|
||||
}
|
||||
|
||||
bool contents_are_detail_fence(const contentflags_t &contents) const
|
||||
{
|
||||
// fixme-brushbsp: check native flag
|
||||
return ((contents.extended & CFLAGS_DETAIL_FENCE) != 0);
|
||||
}
|
||||
|
||||
bool contents_are_detail_illusionary(const contentflags_t &contents) const
|
||||
{
|
||||
// fixme-brushbsp: check native flag
|
||||
return ((contents.extended & CFLAGS_DETAIL_ILLUSIONARY) != 0);
|
||||
}
|
||||
|
||||
bool contents_are_empty(const contentflags_t &contents) const
|
||||
{
|
||||
if (contents.extended & CFLAGS_CONTENTS_MASK)
|
||||
|
|
@ -1009,6 +1048,21 @@ bool contentflags_t::is_any_detail(const gamedef_t *game) const
|
|||
return game->contents_are_any_detail(*this);
|
||||
}
|
||||
|
||||
bool contentflags_t::is_detail_solid(const gamedef_t *game) const
|
||||
{
|
||||
return game->contents_are_detail_solid(*this);
|
||||
}
|
||||
|
||||
bool contentflags_t::is_detail_fence(const gamedef_t *game) const
|
||||
{
|
||||
return game->contents_are_detail_fence(*this);
|
||||
}
|
||||
|
||||
bool contentflags_t::is_detail_illusionary(const gamedef_t *game) const
|
||||
{
|
||||
return game->contents_are_detail_illusionary(*this);
|
||||
}
|
||||
|
||||
bool contentflags_t::is_empty(const gamedef_t *game) const
|
||||
{
|
||||
return game->contents_are_empty(*this);
|
||||
|
|
|
|||
|
|
@ -604,14 +604,11 @@ struct contentflags_t
|
|||
|
||||
constexpr bool operator!=(const contentflags_t &other) const { return !(*this == other); }
|
||||
|
||||
// check if these contents are marked as any (or a specific kind of) detail brush.
|
||||
constexpr bool is_detail(int32_t types = CFLAGS_DETAIL_MASK) const
|
||||
{
|
||||
return (extended & CFLAGS_DETAIL_MASK) & types;
|
||||
}
|
||||
|
||||
// is any kind of detail? (solid, liquid, etc.)
|
||||
bool is_any_detail(const gamedef_t *game) const;
|
||||
bool is_detail_solid(const gamedef_t *game) const;
|
||||
bool is_detail_fence(const gamedef_t *game) const;
|
||||
bool is_detail_illusionary(const gamedef_t *game) const;
|
||||
|
||||
bool is_empty(const gamedef_t *game) const;
|
||||
|
||||
|
|
@ -1800,6 +1797,9 @@ struct gamedef_t
|
|||
virtual contentflags_t create_sky_contents(const int32_t &cflags = 0) const = 0;
|
||||
virtual contentflags_t create_liquid_contents(const int32_t &liquid_type, const int32_t &cflags = 0) const = 0;
|
||||
virtual bool contents_are_any_detail(const contentflags_t &contents) const = 0;
|
||||
virtual bool contents_are_detail_solid(const contentflags_t &contents) const = 0;
|
||||
virtual bool contents_are_detail_fence(const contentflags_t &contents) const = 0;
|
||||
virtual bool contents_are_detail_illusionary(const contentflags_t &contents) const = 0;
|
||||
virtual bool contents_are_empty(const contentflags_t &contents) const = 0;
|
||||
virtual bool contents_are_solid(const contentflags_t &contents) const = 0;
|
||||
virtual bool contents_are_sky(const contentflags_t &contents) const = 0;
|
||||
|
|
|
|||
|
|
@ -990,11 +990,11 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
|
|||
stats.solid++;
|
||||
} else if (brush->contents.is_sky(options.target_game)) {
|
||||
stats.sky++;
|
||||
} else if (brush->contents.is_detail(CFLAGS_DETAIL)) {
|
||||
} else if (brush->contents.is_detail_solid(options.target_game)) {
|
||||
stats.detail++;
|
||||
} else if (brush->contents.is_detail(CFLAGS_DETAIL_ILLUSIONARY)) {
|
||||
} else if (brush->contents.is_detail_illusionary(options.target_game)) {
|
||||
stats.detail_illusionary++;
|
||||
} else if (brush->contents.is_detail(CFLAGS_DETAIL_FENCE)) {
|
||||
} else if (brush->contents.is_detail_fence(options.target_game)) {
|
||||
stats.detail_fence++;
|
||||
} else {
|
||||
stats.liquid++;
|
||||
|
|
|
|||
14
qbsp/csg4.cc
14
qbsp/csg4.cc
|
|
@ -262,13 +262,13 @@ static bool ShouldClipbrushEatBrush(const brush_t &brush, const brush_t &clipbru
|
|||
return false;
|
||||
}
|
||||
|
||||
if (clipbrush.contents.is_detail(CFLAGS_DETAIL_ILLUSIONARY) &&
|
||||
!brush.contents.is_detail(CFLAGS_DETAIL_ILLUSIONARY)) {
|
||||
if (clipbrush.contents.is_detail_illusionary(options.target_game) &&
|
||||
!brush.contents.is_detail_illusionary(options.target_game)) {
|
||||
/* CONTENTS_DETAIL_ILLUSIONARY never clips anything but itself */
|
||||
return false;
|
||||
}
|
||||
|
||||
if (clipbrush.contents.is_detail(CFLAGS_DETAIL_FENCE) && !brush.contents.is_detail(CFLAGS_DETAIL_FENCE)) {
|
||||
if (clipbrush.contents.is_detail_fence(options.target_game) && !brush.contents.is_detail_fence(options.target_game)) {
|
||||
/* CONTENTS_DETAIL_FENCE never clips anything but itself */
|
||||
return false;
|
||||
}
|
||||
|
|
@ -293,12 +293,12 @@ static bool ShouldClipbrushEatBrush(const brush_t &brush, const brush_t &clipbru
|
|||
(brush.contents.is_sky(options.target_game) && (!clipbrush.contents.is_solid(options.target_game) &&
|
||||
!clipbrush.contents.is_sky(options.target_game)))
|
||||
|
||||
|| (brush.contents.is_detail(CFLAGS_DETAIL) && (!clipbrush.contents.is_solid(options.target_game) &&
|
||||
!clipbrush.contents.is_sky(options.target_game) &&
|
||||
!clipbrush.contents.is_detail(CFLAGS_DETAIL)))
|
||||
|| (brush.contents.is_detail_solid(options.target_game) && (!clipbrush.contents.is_solid(options.target_game) &&
|
||||
!clipbrush.contents.is_sky(options.target_game) &&
|
||||
!clipbrush.contents.is_detail_solid(options.target_game)))
|
||||
|
||||
|| (brush.contents.is_liquid(options.target_game) &&
|
||||
clipbrush.contents.is_detail(CFLAGS_DETAIL_ILLUSIONARY))
|
||||
clipbrush.contents.is_detail_illusionary(options.target_game))
|
||||
|
||||
|| (brush.contents.is_fence() && clipbrush.contents.is_liquid(options.target_game))) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -81,9 +81,9 @@ void DetailToSolid(node_t *node)
|
|||
}
|
||||
|
||||
// We need to remap CONTENTS_DETAIL to a standard quake content type
|
||||
if (node->contents.is_detail(CFLAGS_DETAIL)) {
|
||||
if (node->contents.is_detail_solid(options.target_game)) {
|
||||
node->contents = options.target_game->create_solid_contents();
|
||||
} else if (node->contents.is_detail(CFLAGS_DETAIL_ILLUSIONARY)) {
|
||||
} else if (node->contents.is_detail_illusionary(options.target_game)) {
|
||||
node->contents = options.target_game->create_empty_contents();
|
||||
}
|
||||
/* N.B.: CONTENTS_DETAIL_FENCE is not remapped to CONTENTS_SOLID until the very last moment,
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ static std::list<face_t *> ClipFacesToTree_r(node_t *node, const brush_t *srcbru
|
|||
if (node->planenum == PLANENUM_LEAF) {
|
||||
// fixme-brushbsp: move to contentflags_t?
|
||||
if (node->contents.is_solid(options.target_game)
|
||||
|| node->contents.is_detail(CFLAGS_DETAIL)
|
||||
|| node->contents.is_detail_solid(options.target_game)
|
||||
|| node->contents.is_sky(options.target_game)) {
|
||||
// solids eat any faces that reached this point
|
||||
return {};
|
||||
|
|
|
|||
Loading…
Reference in New Issue