Digital Paint Discussion Board

Paintball 2: The Game => Paintball 2 Discussion => Topic started by: jitspoe on March 19, 2004, 01:26:39 AM

Title: Wood Hopper?
Post by: jitspoe on March 19, 2004, 01:26:39 AM
Hehe, I'm working on optimizing the image rendering by using a hash table, and didn't update it on the level change, so half the stuff was using the wrong textures.  Check it out, a medieval hopper!
(http://www.planetquake.com/digitalpaint/images/devel/woodhopper.jpg)

(http://www.planetquake.com/digitalpaint/images/devel/woodhopper2.jpg)
Title: Re: Wood Hopper?
Post by: Eiii on March 19, 2004, 06:10:54 AM
lol

btw, nice pgp.
;D

is that brainstorm? w/ the lava texture instead of grass?
Title: Re: Wood Hopper?
Post by: po on March 19, 2004, 03:09:41 PM
that actually look pretty sweet
Title: Re: Wood Hopper?
Post by: Eiii on March 19, 2004, 04:27:51 PM
btw, what's a hash table?
Title: Re: Wood Hopper?
Post by: jitspoe on March 19, 2004, 05:26:27 PM
Ok, say you have a bunch of strings with thing associated with them.  In this case it's texture names and image ID's.  Say we have a list, something like this:
"grass" 5
"water" 2
"wood" 1
"rock" 3
"cement" 4

Now something comes along and says to draw cement, and we need to figure out what texture id "cement" uses.  The way quake2 does it is string compare each texture:
Is "cement" "grass"? no
Is "cement" "water"? no
Is "cement" "wood"? no
Is "cement" "rock"? no
Is "cement" "cement"? yes.  Ok, the id is 4.

I'm sure you can see why this causes slowdown.   (Fortunately it isn't actually on all the textures, just the HUD images, really).

Now, if we put everything in a table and use some algorithm to reference it, you can avoid checking every single thing in the list.  Say we use the first letter in the name as an array index:
[1] -
[2] -
[3] "cement" 4
[4] -
...
[7] "grass" 5
...
[18] "rock" 3
...
[23] "water" 2, "wood" 1
[24] -
[25] -
[26] -

Now you can just grab the first letter of "cement," get the index 3, check if "cement" is there, and you've got it.
Title: Re: Wood Hopper?
Post by: Eiii on March 20, 2004, 06:24:47 AM
accually, "cement" is "rock"...

;D
Title: Re: Wood Hopper?
Post by: Belmont on March 21, 2004, 06:53:14 PM
that does look pretty sweet