#### Archived

This topic is now archived and is closed to further replies.

# Quake 2 PVS information

This topic is 5961 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello there, After reading through the Flipcode article on Quake2 BSP files, I decided to write my own level viewer. Things started well, and I can display all the faces in technicolour glory. However, there is a slight, slight problem (there always is). The PVS information doesn''t seem to make sense. No matter what formula I use to extract the PVS information for a single cluster, it refuses to make sense. Mostly it looks okay, except when stairs suddenly disappear when walking along a corridoor! I know it en''t the map because the map loads fine in other map viewers. So please, could somebody please elaborate on how the actual PVS info is stored. Aparantly it is a bit vector with 0s run length encoded, but that produces erroneous results! here is my loading code, because that''s the only place I can think of that might be wrong:

// get to start of visibility section

// get number of visibility clusters

fread( &m_Visibility_Cluster_Count, sizeof( UINT ), 1, pFile );

m_pVisibility_Clusters = new BSP_Vis_Offset[m_Visibility_Cluster_Count];
fread( m_pVisibility_Clusters, sizeof(BSP_Vis_Offset), m_Visibility_Cluster_Count, pFile );

remaining_bytes -= sizeof(UINT);
remaining_bytes -= sizeof(BSP_Vis_Offset)*m_Visibility_Cluster_Count;

m_pPVS_Array = new BYTE[remaining_bytes];
fread( m_pPVS_Array, sizeof(BYTE), remaining_bytes, pFile );

// prepare uncompressed storage space for one cluster

m_pCurrent_PVS = new BYTE[m_Visibility_Cluster_Count];
memset(m_pCurrent_PVS, 0, m_Visibility_Cluster_Count);

I have been stuck with this for ages! Any help would be appreciated.

##### Share on other sites
Eheheheh......... these gamedev forums are like some mystical pool of wisdom. One only needs to peer in to seek knowledge, and gaze into thy reflection, and the answer will reveal itself.

At least, it seems like that sometimes. You see, only _after_ making myself look like a fool on these forums can I solve my problems.

The problem was indeed the loading code, however it was my fault for assuming that an offset of zero would point to the start of an array =)

Just for anyone who''s curious, it goes like this:

The BSP_Vis_Offset struct contains a field "pvs" which is an offset into the m_pPVS_Array. Now instead of making a pvs of 0 refer to the beginning of this array, they take into account everything that came before this in the lump (in my example, this would be the m_Visibility_Cluster_Count, and all the BSP_Vis_Offsets).

Grr.. it''s annoying loading a file format when you don''t have intimate knowledge of it.

Anyway, I thank the mysterious master who shined enlightenment upon me.

1. 1
Rutin
25
2. 2
JoeJ
20
3. 3
4. 4
5. 5

• 9
• 9
• 46
• 41
• 23
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002051
×