Git Product home page Git Product logo

Comments (1)

just-bank avatar just-bank commented on July 24, 2024

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

from torque3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.