Example #1
0
void CVradStaticPropMgr::Shutdown()
{
	// Remove all static props from the tree
	for (int i = m_StaticProps.Size(); --i >= 0; )
	{
		RemovePropFromTree( i );
	}

	// Remove all static prop model data
	for (int i = m_StaticPropDict.Size(); --i >= 0; )
	{
		studiohdr_t *pStudioHdr = m_StaticPropDict[i].m_pStudioHdr;
		if ( pStudioHdr )
		{
			if ( pStudioHdr->pVertexBase )
			{
				free( pStudioHdr->pVertexBase );
			}
			free( pStudioHdr );
		}
	}

	m_pBSPTreeData->Shutdown();

	m_StaticProps.Purge();
	m_StaticPropDict.Purge();
}
bool CVradStaticPropMgr::ClipRayToStaticPropsInLeaf( PropTested_t& propTested, Ray_t const& ray, int leaf )
{
	EnumContext_t ctx;
	ctx.m_pRay = &ray;
	ctx.m_pPropTested = &propTested;

	return !m_pBSPTreeData->EnumerateElementsInLeaf( leaf, this, (int)&ctx );
}
void CVradStaticPropMgr::RemovePropFromTree( int propIndex )
{
	// Release the tree handle
	if (m_StaticProps[propIndex].m_Handle != TREEDATA_INVALID_HANDLE)
	{
		m_pBSPTreeData->Remove( m_StaticProps[propIndex].m_Handle );
		m_StaticProps[propIndex].m_Handle = TREEDATA_INVALID_HANDLE;
	}
}
bool CVradStaticPropMgr::ClipRayToStaticProps( PropTested_t& propTested, Ray_t const& ray )
{
	StartRayTest( propTested );

	EnumContext_t ctx;
	ctx.m_pRay = &ray;
	ctx.m_pPropTested = &propTested;

	// If it got through without a hit, it returns true
	return !m_pBSPTreeData->EnumerateLeavesAlongRay( ray, this, (int)&ctx );
}
void CVradStaticPropMgr::Shutdown()
{
	// Remove all static props from the tree
	for (int i = m_StaticProps.Size(); --i >= 0; )
	{
		RemovePropFromTree( i );
	}

	m_pBSPTreeData->Shutdown();

	m_StaticProps.Purge();
	m_StaticPropDict.Purge();
}
Example #6
0
bool CVradStaticPropMgr::ClipRayToStaticPropsInLeaf( PropTested_t& propTested, Ray_t const& ray, int leaf )
{
	if ( m_bIgnoreStaticPropTrace )
	{
		// as if the trace passes right through
		return false;
	}

	EnumContext_t ctx;
	ctx.m_pRay = &ray;
	ctx.m_pPropTested = &propTested;

	return !m_pBSPTreeData->EnumerateElementsInLeaf( leaf, this, (int)&ctx );
}
Example #7
0
bool CVradStaticPropMgr::ClipRayToStaticProps( PropTested_t& propTested, Ray_t const& ray )
{
	if ( m_bIgnoreStaticPropTrace )
	{
		// as if the trace passes right through
		return false;
	}

	StartRayTest( propTested );

	EnumContext_t ctx;
	ctx.m_pRay = &ray;
	ctx.m_pPropTested = &propTested;

	// If it got through without a hit, it returns true
	return !m_pBSPTreeData->EnumerateLeavesAlongRay( ray, this, (int)&ctx );
}
void CVradStaticPropMgr::Init()
{
	CreateInterfaceFn physicsFactory = GetPhysicsFactory();
	if ( !physicsFactory )
		Error( "Unable to load vphysics DLL." );
		
	s_pPhysCollision = (IPhysicsCollision *)physicsFactory( VPHYSICS_COLLISION_INTERFACE_VERSION, NULL );
	if( !s_pPhysCollision )
	{
		Error( "Unable to get '%s' for physics interface.", VPHYSICS_COLLISION_INTERFACE_VERSION );
		return;
	}

	m_pBSPTreeData->Init( ToolBSPTree() );

	// Read in static props that have been compiled into the bsp file
	UnserializeStaticProps();
}
void CVradStaticPropMgr::InsertPropIntoTree( int propIndex )
{
	CStaticProp& prop = m_StaticProps[propIndex];

	StaticPropDict_t& dict = m_StaticPropDict[prop.m_ModelIdx];

	// Compute the bbox of the prop
	if ( dict.m_pModel )
	{
		s_pPhysCollision->CollideGetAABB( prop.m_mins, prop.m_maxs, dict.m_pModel, prop.m_Origin, prop.m_Angles );
	}
	else
	{
		VectorAdd( dict.m_Mins, prop.m_Origin, prop.m_mins );
		VectorAdd( dict.m_Maxs, prop.m_Origin, prop.m_maxs );
	}

	// add the entity to the tree so we will collide against it
	prop.m_Handle = m_pBSPTreeData->Insert( propIndex, prop.m_mins, prop.m_maxs );
}
// ISpatialLeafEnumerator
bool CVradStaticPropMgr::EnumerateLeaf( int leaf, int context )
{
	return m_pBSPTreeData->EnumerateElementsInLeaf( leaf, this, context );
}