Forum

Problem with DLIGHTS > 32

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

Moderator: InsideQC Admins

Problem with DLIGHTS > 32

Postby Baker » Wed Jul 18, 2012 11:47 pm

I've looked at both Qrack and the RMQ engine to try to bump up MAX_DLIGHTS properly above 32, using 128.

1. I expanded dlightbits from int to 4 ints. (32 bytes x 4 = 128 bits) in gl_model.h
Code: Select all
NEW:   int         dlightbits[(MAX_DLIGHTS + 31) >> 5];   // mh - 128 dynamic lights
OLD:   int         dlightbits;

2. R_Marklights clears all 4 ints and sets the appropriate bit if affected by dynamic lighting.
Code: Select all
         if (surf->dlightframe != r_dlightframecount) // not dynamic until now
         {
            surf->dlightbits[0] = surf->dlightbits[1] = surf->dlightbits[2] = surf->dlightbits[3] = 0;
//            memset (surf->dlightbits, 0, sizeof (surf->dlightbits));
            surf->dlightframe = r_dlightframecount;
         }
         // mark the surf and ent for this dlight
         surf->dlightbits[num >> 5] |= 1 << (num & 31);

3. R_AddDynamicLights checks the appropriate bit in the group of 4 ints
Code: Select all
      if ( !(surf->dlightbits[lnum >> 5] & (1 << (lnum & 31))))      //MH
And I get an invalid surface that somehow gets marked on a particular demo on Warpspasm warps.bsp and it crashes with an exception. The surface looks like it has invalid texture information. The above changes are straightforward enough, I'm wondering if something in FitzQuake's gl_model.c might not be allocating memory right or at least in a way that isn't very flexible for surfaces? I'm not seeing anything like that in

msurface_t is the in memory representation of a surface. As far as I know, I should be able to add 12 bytes (3 more ints) and for the most part handle it how I want.

Any thoughts? I'm thinking my problem is related to a memory corruption and looking at gl_model.c to see how msurface_t is getting allocated and seeing how the data is filled in ...
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

Re: Problem with DLIGHTS > 32

Postby Baker » Thu Jul 19, 2012 12:05 am

Nevermind!

Wasn't aware there was a tutorial on this.

viewtopic.php?f=12&t=4257

(Sheesh ... I had omitted something stupid. No wonder it crashed .... Grrrr. Dumb mistake. Then again I wasn't using the tutorial, but still ...)
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

Re: Problem with DLIGHTS > 32

Postby taniwha » Thu Jul 19, 2012 12:55 am

Ah, but because you tried to implement it on your own, you truly understood the tutorial. And because you understood the tutorial, you know what you did wrong. Maybe next time you'll be able to avoid the same mistake :).

I'll have to take a look at the tut :)
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: Problem with DLIGHTS > 32

Postby r00k » Thu Jul 19, 2012 2:06 am

In 1.9 I blindly increased dlights without any backbone to it
Same for lightmaps I need to nix half life map support it's kinda useless and breaks demos
Except in DirectQ and dark places
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Re: Problem with DLIGHTS > 32

Postby Spike » Thu Jul 19, 2012 2:12 am

regarding extended lightstyles and demo/protocol incompatibility, just don't send/write those lightstyles if they're empty, and make sure they're properly cleared on map changes.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Problem with DLIGHTS > 32

Postby r00k » Thu Jul 19, 2012 3:53 am

I can appreciate that, i opened a book trying to make something of a better client than proquake in 2003 based on joequake. I was focusing on the QRP engine then saw QMB particles, and the flow of quakesource.com additions, and jq encompassed most. and i jumped on that codebase. I am more a quakeC coder and a player. So im kinda biased. I get first hand bitching from the player base. Mostly. mods are focal and player dont care about useability of a feature if its not focused on their game (mod).. i just get caught up with mr jones when no one knows him...
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Re: Problem with DLIGHTS > 32

Postby mh » Thu Jul 19, 2012 5:35 pm

Definitely agreed that it's great that you tried to implement it yourself. I learned so much from taking the same approach back when I started out (including when to say "OK, time to stop trying myself and copy what someone else has done!" :lol: ). Sure I made some horrible mistakes at the time, but I've no regrets about the experience.
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


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest