Page MenuHome

BGE: Add new world API KX_WorldInfo (KX_Scene)
ClosedPublic

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

Details

Summary

This Patch will add a the world API (mist, background, ambient) to KX_WorldInfo.
The new API uses now attributes.

Diff Detail

Event Timeline

The implementation looks ok to me but I'm not familiar with the BGE API conventions, so I will let the game engine developers judge if this is something they want.

Our current naming convention for the BGE Python API is a Javaesque camelCase, not the Pythonic PEP8 naming convention used by bpy (which is preferred). It would be nice to switch the naming convention, but not at the expense of breaking scripts. We do have some items in our API that break our current naming convention (e.g., LibLoad, KX_Light.lin_attenuation, KX_Light.quad_attenuation, etc.). Part of me would like to keep the naming convention is this revision as is to slowly transition naming conventions, but that would be horribly inconsistent with the rest of the API. I'll add Campbell as a reviewer so we can get his opinion.

We have a deprecation mechanism in the form of the ShowDeprecationWarning macro in PyObjectPlus.h. This macro should be used in each deprecated function so users get a warning when attempting to use the deprecated functions (this is what we used with the big API changes for 2.49).

doc/python_api/rst/bge_types/bge.types.KX_Scene.rst
90

This doc doesn't match the actual code, which only returns a single KX_WorldInfo object.

doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst
17

bge.logic.getCurrentScene() does not return a list, so leave off the indexing.

19

Shouldn't this be sce.world.mist_color?

doc/python_api/rst/bge.render.rst
80

KX_Scene should be KX_WorldInfo.

doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst
19

Yes, should be sce.world.mist_color.

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

Fixed bugs that Moguri found.
Renamed KX_Scene to KX_WorldInfo.
Add method to return word name.
If no world exist none type will be returned.

You should make sure the old bge.render API prints deprecation warnings using the ShowDeprecationWarning macro in PyObjectPlus.h.

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

Update for the actual master.

Thomas Szepe (hg1) edited edge metadata.

Update fix merge conflicts with actual master branch.

Mitchell Stokes (moguri) edited edge metadata.

Looks good to me. It might be worthwhile to explore exposing some of these as mathutils in another patch.

I'd like to have Campbell's approval before this patch is actually landed.

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

As requested from Mogury on IRC, I have changed thecolor return type to mathutils vector.

This revision was automatically updated to reflect the committed changes.