Page MenuHome

BGE: Code clean up for world (mist, background, ambient)
ClosedPublic

Authored by Thomas Szepe (hg1) on Dec 29 2013, 4:10 PM.

Details

Summary

Code clean up for BGE world mist, background and global ambient color.
Move mist render update to BlenderWolrdInfo

Diff Detail

Event Timeline

Looks good to me, except the quadratic => exponential thing as mentioned in D74 and D149, but this is a code cleanup commit so it's not really relevant.

source/gameengine/Converter/BlenderWorldInfo.cpp
58–60

I personally wouldn't put these in member variables, you never know when some code is added that might make these change dynamically, generally I wouldn't copy that kind of state around when I can avoid it.

source/gameengine/Converter/BlenderWorldInfo.cpp
58–60

UpdateBackGround() and UpdateWorldSettings() is called every frame (necessary if we have multiple scenes running).
So calling KX_GetActiveEngine()->GetRasterizer()->SetFog(...) will be much slower.
May be the best would be to make these variables constant.

Thomas Szepe (hg1) updated this revision to Unknown Object (????).Jan 8 2014, 11:14 PM

Update necessary about D148 update (setUseMist()).

source/gameengine/Converter/BlenderWorldInfo.cpp
58–60

It actually wont be that slow to do the calls. Modern processors and compilers handle functions calls pretty well these days. Having the drawtype fixed at construction is particularly problematic, as this does change during execution for shadows.

source/gameengine/Ketsji/KX_KetsjiEngine.cpp
313

Do we really need to call into BlenderWorldInfo this much? Can we not just call one update that handles all the bf_gpu calls once per frame per scene?

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
219

Are these being called for GLSL mode too? Does GLSL mode use fixed function fog? If not, we should avoid fixed function calls that we don't need. I guess by moving them here we at least avoid calling them every frame, but can we be sure that these state variables are not being screwed up by someone?

source/gameengine/Converter/BlenderWorldInfo.cpp
58–60

OK. I will change that.

source/gameengine/Ketsji/KX_KetsjiEngine.cpp
313

Yes the four calls are are necessary. Actually the are only per frame per scene.

  1. Is when dome render is enabled.
  2. Is for normal render.
  3. Is when the stereo mode is enabled.
  4. Is for the image texture render.
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
219

Yes text objects has no material and without the text will not display with fog.
If sometime someone add a material patch for text objects, we only need to add a check in UpdateWorldSettings().

Thomas Szepe (hg1) updated this revision to Unknown Object (????).Jul 19 2014, 7:21 PM

Update for the actual master.

Thomas Szepe (hg1) edited edge metadata.

Update fix merge conflicts with actual master branch.

Mitchell Stokes (moguri) requested changes to this revision.Feb 21 2015, 10:03 PM
Mitchell Stokes (moguri) edited edge metadata.

Overall looks good. Just some minor cleanup needed to BlenderWorldInfo.h.

source/gameengine/Converter/BlenderWorldInfo.h
36

I see no need to include KX_KetsjiEngine.h or RAS_IRasterizer.h.

41

The KX_KetsjiEngine nor the RAS_IRasterizer forward declarations appear to be used anywhere. Also, I don't know if the use of const is correct in a forward declaration.

This revision now requires changes to proceed.Feb 21 2015, 10:03 PM
Mitchell Stokes (moguri) edited edge metadata.

Looks BlenderWorldInfo.h is removed in D156, so this looks good to me.

This revision is now accepted and ready to land.Feb 21 2015, 10:57 PM
Thomas Szepe (hg1) edited edge metadata.

Update for current master

This revision was automatically updated to reflect the committed changes.