Forum

Help! What are these numbers?

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Help! What are these numbers?

Postby Baker » Tue Jul 27, 2010 9:27 pm

model.c(655): out = Hunk_AllocName ( (count+8)*sizeof(*out), loadname); // Manoel Kasimier - skyboxes - extra for skybox // Code taken from the ToChriS engine - Author: Vic (vic@quakesrc.org) (http://hkitchen.quakesrc.org/)
model.c(720): out = Hunk_AllocName ( (count + 13) * sizeof(*out), loadname); // Manoel Kasimier - skyboxes - extra for skybox // Code taken from the ToChriS engine - Author: Vic (vic@quakesrc.org) (http://hkitchen.quakesrc.org/)
model.c(750): out = Hunk_AllocName ( (count+6)*sizeof(*out), loadname); // Manoel Kasimier - skyboxes - extra for skybox // Code taken from the ToChriS engine - Author: Vic (vic@quakesrc.org) (http://hkitchen.quakesrc.org/)
model.c(869): out = Hunk_AllocName ( (count+6)*sizeof(*out), loadname); // Manoel Kasimier - skyboxes - extra for skybox // Code taken from the ToChriS engine - Author: Vic (vic@quakesrc.org) (http://hkitchen.quakesrc.org/)
model.c(1209): out = Hunk_AllocName ( (count+24)*sizeof(*out), loadname); // Manoel Kasimier - skyboxes - extra for skybox // Code taken from the ToChriS engine - Author: Vic (vic@quakesrc.org) (http://hkitchen.quakesrc.org/)
model.c(1236): out = Hunk_AllocName ( (count+6)*sizeof(*out), loadname); // Manoel Kasimier - skyboxes - extra for skybox // Code taken from the ToChriS engine - Author: Vic (vic@quakesrc.org) (http://hkitchen.quakesrc.org/)


I'm going to play with using Sajt's palettization code to see if I can get "WinQuake" to load a 24-bit TGA skybox and reduce it to the current 256-color palette (I would say "Quake palette" but mods can use their own palette so that isn't quite technically true.)

Stage 1 is of course is to simply load a PCX skybox.

But what are these extra +6, +24 and stuff.

HunkAlloc plus code like this ...

Code: Select all
   for ( i=0 ; i<count ; i++, in++, out++)
   {
      bits = 0;
      for (j=0 ; j<3 ; j++)
      {
         out->normal[j] = LittleFloat (in->normal[j]);
         if (out->normal[j] < 0)
            bits |= 1<<j;
      }

      out->dist = LittleFloat (in->dist);
      out->type = LittleLong (in->type);
      out->signbits = bits;
   }


... freaks me out if the Hunk_Alloc isn't the right size for obvious reasons.

This one in particular bothers me in Mod_LoadPlanes ...

// out = Hunk_AllocName ( count*2*sizeof(*out), loadname);
out = Hunk_AllocName ( (count+6)*sizeof(*out), loadname); // Manoel Kasimier - skyboxes - extra for skybox // Code taken from the ToChriS engine - Author: Vic (vic@quakesrc.org) (http://hkitchen.quakesrc.org/)


Where the "*2" mysteriously has disappeared.

I may answer my own question and reply to my own post ... but I don't want to risk forgetting this question.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Baker » Tue Jul 27, 2010 10:05 pm

Nevermind, must be for extra edges, vertexes, etc.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Tue Jul 27, 2010 11:42 pm

6 faces, 4 vertexes per face (6 x 4 = 24), 8 vertexes total, not sure about the "13", definitely loading extra stuff for hacking in more BSP content later on. It would be interesting to compare with the Q2 software renderer. The * 2 disappearing from Mod_LoadPlanes freaks me too, but then again it also freaks me that it's there in the first place!
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby mankrip » Wed Jul 28, 2010 1:10 am

The 13 is 1+12 edges, since the original code also adds an extra edge.

I'm not sure why the need for an extra edge, but the renderer does add a dummy surface upon loading, and uses it to set the unused areas of the display buffer to r_clearcolor upon drawing the world's scanlines.

I'm also not sure about the *2 in Mod_LoadPlanes, but its usage in the original code does seem weird. I'm putting it back now, just in case:
Code: Select all
   out = Hunk_AllocName ( (count+6)*2*sizeof(*out), loadname); // Manoel Kasimier - skyboxes - extra for skybox // Code taken from the ToChriS engine - Author: Vic (vic@quakesrc.org) (http://hkitchen.quakesrc.org/)

Thanks Baker.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby Baker » Wed Jul 28, 2010 2:42 am

mk wrote:I'm also not sure about the *2 in Mod_LoadPlanes, but its usage in the original code does seem weird. I'm putting it back now, just in case


If you're putting it back, I'm sure as hell gonna put it back too :D :D
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest