Author Topic: Wood Hopper?  (Read 1794 times)

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Wood Hopper?
« on: March 19, 2004, 12: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!



Eiii

  • Autococker
  • Posts: 4595
Re: Wood Hopper?
« Reply #1 on: March 19, 2004, 05:10:54 AM »
lol

btw, nice pgp.
;D

is that brainstorm? w/ the lava texture instead of grass?
« Last Edit: March 19, 2004, 05:11:45 AM by eiii »

po

  • PGP
  • Posts: 8
Re: Wood Hopper?
« Reply #2 on: March 19, 2004, 02:09:41 PM »
that actually look pretty sweet

Eiii

  • Autococker
  • Posts: 4595
Re: Wood Hopper?
« Reply #3 on: March 19, 2004, 03:27:51 PM »
btw, what's a hash table?

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Wood Hopper?
« Reply #4 on: March 19, 2004, 04: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.

Eiii

  • Autococker
  • Posts: 4595
Re: Wood Hopper?
« Reply #5 on: March 20, 2004, 05:24:47 AM »
accually, "cement" is "rock"...

;D

Belmont

  • Stingray
  • Posts: 73
Re: Wood Hopper?
« Reply #6 on: March 21, 2004, 05:53:14 PM »
that does look pretty sweet