engine: common: use Mod_PointInLeaf in Mod_GetPVSForPoint instead of traversing nodes manually

This commit is contained in:
Alibek Omarov 2024-05-27 13:21:04 +03:00
parent 6cbac51731
commit 3ca15250e8

View file

@ -684,22 +684,11 @@ NOTE: can return NULL
*/ */
byte *Mod_GetPVSForPoint( const vec3_t p ) byte *Mod_GetPVSForPoint( const vec3_t p )
{ {
mnode_t *node; mleaf_t *leaf;
mleaf_t *leaf = NULL;
ASSERT( worldmodel != NULL ); ASSERT( worldmodel != NULL );
node = worldmodel->nodes; leaf = Mod_PointInLeaf( p, worldmodel->nodes );
while( 1 )
{
if( node->contents < 0 )
{
leaf = (mleaf_t *)node;
break; // we found a leaf
}
node = node->children[PlaneDiff( p, node->plane ) <= 0];
}
if( leaf && leaf->cluster >= 0 ) if( leaf && leaf->cluster >= 0 )
return Mod_DecompressPVS( leaf->compressed_vis, world.visbytes ); return Mod_DecompressPVS( leaf->compressed_vis, world.visbytes );