Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look into empty light type #50

Open
DavidWyand-GG opened this issue Oct 2, 2012 · 1 comment
Open

Look into empty light type #50

DavidWyand-GG opened this issue Oct 2, 2012 · 1 comment
Labels

Comments

@DavidWyand-GG
Copy link
Member

With Pull Request #19 an empty light type was added to T3D. We should remove this empty light type in a manner that stills allows T3D to compile on Windows and Linux.

@just-bank
Copy link
Contributor

Sorry, was seek for some time, now I'm back...

Okay, after a bit of research (mostly by looking back in time on why this change has been done), here is a result:

First of all, yes, it does create an empty light type with index 0 (zero), but it doesn't used anywhere at all, as - skipped:

void LightInfo::packExtended( BitStream *stream ) const
{
   for ( U32 i = 0; i < mExtended.size(); i++ )
      if ( mExtended[ i ] ) 
         mExtended[ i ]->packUpdate( stream );
}

When this bit of code is called (like from the ScatterSky::packUpdate(), it will call the pack function for all non-empty lights.

And it is possible to build the T3D on Linux without this change, but...

Second, lightShadowMap.cpp and lightMapParams.cpp are link-order-dependent as it uses global c-tors (right for LightInfoExType).

So, it's possible that on one platform the ShadowMapParams is constructed before LightMapParams, and on another - in different order. In this case those two builds will crash upon connect, as one will assume it is sending data for ShadowMapParams (index=0), but the other retrieving it as LightMapParams (but in this build ShadowMapParams has index=1 as linked in reversed order).
So it will either try to read more from the stream in unpack, or the unpacked data will be corrupted (as it used for wrong light type), anyway at some moment it will crash.

To sum up everything:

It can be left as is now, with empty light type (at index zero), as it doesn't add any overhead at all and there are no objects created with empty type.

Or, we can refactor the code not to construct LightInfoExType globally, and change it to be pointer instead and create it by using MODULEs.

As far as I remember, the whole "MODULE__" system in T3D was implemented exactly for this - to avoid such problems in the code. And I believe the _LightInfoExType* is the only thingy left unchanged.

@DavidWyand-GG you can see my initial post about this problem here: http://www.garagegames.com/community/forums/viewthread/110087/3#comment-737441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants