IGameArt
Member
Hey guys, I need some help translating some code I found online for a new feature being implemented into DopeFish, my Doom wad loader for GM.
I'm trying to utilize the gl_pvs format created originally for the Vavoom source port, however low level code like this is something I'm fairly inexperienced with.
In the buffer loaded from the wad file is a chunk of data called a lump. There are several lumps that represent several different types of data, like sprites, textures, maps, or helper nodes. GL_PVS is one of those helper nodes.
The format for finding where to look in the buffer for the results of your current subsector (chunk of the level) are all follows:
The example for how to find the visibility of a subsector i is as follows:
However, being that I am not really sure what the bitshifting operators in here are accomplishing, or how the variable
Does anyone mind pointing me in the right direction? Or have any questions that I've not already answered above?
More information on the format can be found here!
I'm trying to utilize the gl_pvs format created originally for the Vavoom source port, however low level code like this is something I'm fairly inexperienced with.
In the buffer loaded from the wad file is a chunk of data called a lump. There are several lumps that represent several different types of data, like sprites, textures, maps, or helper nodes. GL_PVS is one of those helper nodes.
So the GL_PVS lump is essentially a buffer copied to memory from within the wad file. It contains a sort of lookup table of all of the visibility states of any part of the map from any other part of the map. Having access to this table would make it so the renderer could skip over rendering any parts of the map that aren't visible from the camera's current location.glVIS is a PVS (Potentially Visible Set) builder specially designed to be used with OpenGL ports of the DOOM game engine. It extends the “GL-Friendly Nodes” with a new lump named “GL_PVS”. Basically it’s a subsector accept table designed for rendering engine to skip the subsectors that can’t be visible from viewer’s subsector.
The format for finding where to look in the buffer for the results of your current subsector (chunk of the level) are all follows:
((numsubsectors + 7) / 8) * i
The example for how to find the visibility of a subsector i is as follows:
Code:
byte *vis_data; // PVS lump
int view_sub; // Num of subsector, where the player is
byte *vis;
vis = vis_data + (((numsubsectors + 7) / 8) * view_sub);
...
if (vis[i >> 3] & (1 << (i & 7)))
{
// Subsector is visible
...
}
else
{
// Subsector is not visible
...
}
vis
seems to be accessed as if it were an array are unfortunately kinda confusing to me.Does anyone mind pointing me in the right direction? Or have any questions that I've not already answered above?
More information on the format can be found here!
It appears as though the smallest amount of data I can read from a buffer is a single byte, or 8 bits.
However, for my current project I need to be able to read 1 bit of data. I'm not entirely sure how to go about doing that if the smallest GM allows is a byte.
Do I have to use buffer_bool, then use bit shifting to get the individual values of each bit? I'm not entirely sure how to go about doing that. Any pointers?
However, for my current project I need to be able to read 1 bit of data. I'm not entirely sure how to go about doing that if the smallest GM allows is a byte.
Do I have to use buffer_bool, then use bit shifting to get the individual values of each bit? I'm not entirely sure how to go about doing that. Any pointers?
Last edited: