Inside3D!
     

Help! What are these numbers?

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Jul 27, 2010 9:27 pm    Post subject: Help! What are these numbers? Reply with quote

Quote:
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:
   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 ...

Quote:
// 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.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Jul 27, 2010 10:05 pm    Post subject: Reply with quote

Nevermind, must be for extra edges, vertexes, etc.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Tue Jul 27, 2010 11:42 pm    Post subject: Reply with quote

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!
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
mk



Joined: 04 Jul 2008
Posts: 94

PostPosted: Wed Jul 28, 2010 1:10 am    Post subject: Reply with quote

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:
   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.
_________________
Makaqu engine blog / website.

Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Wed Jul 28, 2010 2:42 am    Post subject: Reply with quote

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 Very Happy Very Happy
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group