weird code in BSP loader

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
jikbar
Posts: 62
Joined: Wed Aug 25, 2004 4:48 pm
Location: Canada
Contact:

weird code in BSP loader

Post by jikbar »

i was looking hrough the Irrlicht source recently and i saw something weird in the Q3 BSP loader. the line was

for(i = 0; i < (numtextures+1)*(numlightmaps+1); i++)

then the code inside sets up a bunch of mesh buffers to hold geometry.

Why is this code like this? it seems that it would be allocating lots of unnecessary mesh buffers then calling lots of unnecessary code for rendering them. Wouldn't it be easier to get the amount of meshes from the BSP file? (# of meshes == # of brushes, i think)
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

I'm not familiar with bsp file format, but Irrlicht needs a mesh buffer for every different material (generally texture). I have never really ever learned exactly what Q3 brushes are, but one could definitely have multiple brushes with the same texture (thus allocating meshbuffer for every brush could actually be wasteful) and it may be possible to have multiple textures on a single brush (I just don't know if bsp format allows this).
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
jikbar
Posts: 62
Joined: Wed Aug 25, 2004 4:48 pm
Location: Canada
Contact:

Post by jikbar »

i just realized this as you were posting. i was thinking that irrlicht's BSP loader created a mehbuffer for each object (which would be a brush) in the level yet in reality it creates a meshbuffer to hold a polygon soup of every face with a certain texture/lightmap.

wow, i just realized how inexcapably terrible BSPs are. building my own level format has definately taken a step up in my game's priority
Murphy
Posts: 290
Joined: Mon Dec 13, 2004 12:06 am
Location: United States
Contact:

Post by Murphy »

It does create a lot of unused meshBuffers, but it doesn't waste time trying to render them -- they are thrown away at the end of... I think it's loadTextures().
Post Reply