Max Logic Steps: is it per-world or global?

In the world settings, under physics, there is the max logic steps:


This would imply it is per-world.

But then if you look at the API there is: “bge.logic.setMaxLogicFrame(maxlogic)” which implies it is a global/game level setting.

I can’t think of any good way to test this either. So does anyone know if the logic sub-steps are global or per-world?

I never looked at that parameters.

Logic Steps
The description is a bit ambiguous to me. I know a maxLogicFrame that tells how many logic frames can be processed without a render. In other words, regardless how the frames take after maxLogicFrame there will be a forced render.

This is what the first part of the description says.

Maximum number of logic frame per game frame if graphics slows down the game,

This does not sound like a relation to physics, but render and logic (this is bge.logic.getMaxLogicFrame()). So I would not expect it in the physics panel. Wouldn’t a logic panel be a better fitting place?

The second part is related to physics:

higher value allows better synchronization with physics

Unfortunately this does not tell me what the relationship between logic and physics is. Just now I do not know if that is this is bge.logic.getMaxLogicFrame() or something else.

Physics Steps
The other parameter “Max” seams to describe a better description of the relationship:

Maximum number of physics step per game frame if graphics slows down the game, higher value allows physics to keep up with realtime

I guess the last part means the speed of the logic.

Nevertheless I can’t tell if scenes can have different settings on that parameters. I do not think so, but the current architecture would allow that as all scenes are processed one after the other. A look at the source code might help.

I have no idea, first of all. But I did a simple test here:

PhysicsTest.blend (1.52 MB)

This simulates a cube falling onto a plane. If you get rid of all the code in the scenes, then for one world change the logic substeps whereas keep the substeps the same for another world, you can constantly see a (slight) rise in the processing of the physics of one world vs the next (because of the substeps increase).

The code basically tests the “carry over” effect of setting the maxLogicSteps as well as the physics steps. And according to the test, using those blender doc functions do carry over regardless of what world you are in.

So basically what I’m trying to say is, each world will have an independent max logic step and physics sub-steps, but
modifying “max logic substeps” through code will change it for all worlds (I’m pretty sure both of your presumptions were correct).

I think sdfgeoff is talking about the “max” of the logic steps.

I slightly modified your demo file to show the MaxPhysicsFrame and MaxLogicFrame only (rather than setting them). I could not see that physics substeps are accessible via BGE API, so I wasn’t able to verify that as well.

I changed Logic Steps/Max to 1 in “Scene” and to 5 in “Scene.001”. Then I let the scenes switch to the other.

It turns out the settings are used from within the scene the game session started from and does not change when switching to another scene. It does not matter that there are different “world settings” the start-up parameters are used similar to the render settings (Multitexture/GLSL).

Lets look at the semantics.

The logic step - max parameter is used when the game session hits the timing limits (the overall processing exceeds the time available for a single frame). The system automatically reduces the processing time by skipping the render step. When max numbers of frames without render are reached the next frame will get a render (otherwise the user would remain to see the last rendered image until the processing time is reduced or the game session ends). You do not know if a frame exceeds the limit before the frame is completely processed. As far as I remember the BGE looks if the previous frame exceeded the processing time, trying to speed up the current frame.

I do not really know what that means for Physics Steps - max.

Maximum number of physics step per game frame if graphics slows down the game, higher value allows physics to keep up with realtime

I can imagine “game frame” means “a frame of the logic”. But this seams strange as it indicates that the physics would perform 5 frames while logic performs one. That makes not much sense.
I guess “game frame” means “a render frame” similar to the “logic game frame”.
My conclusion:

I still do not see what will happen on lags. Will the minimum of logic steps max and physics steps max take place? Will a physics step be skipped. Will the number of physics substeps be reduced to the max number?

I never changed this settings, therefore I did not thought about this topic that much.

Nevertheless, what would happen if the settings are scene local?
If there is only one scene, it would be fine. You might get a better lag handling in one scene as in the other (with different settings).
If there are multiple scenes (overlay/background), it would be possible to skip the render of a single scene, as they are rendered independent from each other. So yes the settings could be processed by scene. Maybe there are other arguments against it.

To answer sdgeoff’s question. It looks like it is a game session global setting. The settings from the startup scene will take place until they get overridden by python.

I think sdfgeoff is talking about the “max” of the logic steps.

Correct me if I’m wrong, but isn’t that what bge.logic.getMaxLogicFrame() and bge.logic.setMaxLogicFrame(…) are about, as I’ve mentioned?

I changed Logic Steps/Max to 1 in “Scene” and to 5 in “Scene.001”. Then I let the scenes switch to the other.

It turns out the settings are used from within the scene the game session started from and does not change when switching to another scene. It does not matter that there are different “world settings” the start-up parameters are used similar to the render settings (Multitexture/GLSL).

Ah thanks Monster I forgot to clarify this important detail I’ve noticed which I want to bring to your guys’ attention: changing the actual max logic physics step/frame will not come into effect for alternating worlds/scenes, I believe, in some cases (as in the file I sent). This is because it is talking about a “maximum” - that does not mean it will take effect immediately. But, changing the physics substeps will create a change in performance, because it is not a maximum - it is the actual calculation.

Note that the description of “max physics step” says “…IF the game graphics slow down the game…”. So I think different scenes or worlds may in fact hold different settings which take effect. This is why I used code - to test that “max” theory. What do you think?

Here is the modified file (without the code) (note the physics processing time on “Scene” and “Scene.001” - the one in “Scene.001” is higher than the one in “Scene”): [ATTACH]460783[/ATTACH]

I do not really know what that means for Physics Steps - max.

According to my understanding, the physics steps max is the limit that the number of physics calculations that can execute in a given game logic frame if game graphics slows the game frame rate down. Increasing this value comes at a cost though - the calculations may come higher, and that should increase processing time (potentially).

I want to make sure I’m understanding something. One game frame consists of: (physics frame calculations >= 0 [times (or other operation) physics substeps]) + (logic frame calculations >= 0) + (render frame calculations >= 0) +… etc.

True or False?

My understanding is that:

A Game Frame: An iterative event containing at least one render, logic and physics step
Max Physics Steps: The maximum number of physics steps allowed in a game frame in an attempt to keep the physics real-time if the rendering is slow.
Max Logic Steps: The maxumum number of logic iterations allowed in a game frame to try keep the logic running at 60FPS regardless of graphical frame-rate.

I believe that if the physics steps are more frequent than the logic steps then the sensible thing (ie collisions) are passed to the logic based on all the events in the logic steps. It does make me wonder what happens with functions like applyForce. Are they applied each physics step or each logic step? Fascinating!

So here’s why I’m asking.
I have a particularly logic heavy scene. Say, an RTS with hundred of units. And I have an overlay scene with an interface. If the max logic substeps is per-scene, then the logic in the interface overlay scene could be made to run and refresh faster than the logic of the logic heavy scene.
In actuality, the “logic heavy scene” was running at about 10FPS, and things like button presses are getting lost. The obvious (but not so easy) solution is to make that other scene run faster, but that may not be possible (Actually it is, the issue has been mostly resolved and this question is now out of interest than for any actual reason).

Ahaha, I feel so silly. I actually think Monster’s explanation is correct. I went a bit off-course when I was talking about physics substeps, but I did not actually confirm a world-to-world max logic change (only the python modification).

I have tested the blender file again with the code which simply obtains the max logic steps. It is as Monster says:

The settings from the startup scene will take place until they get overridden by python.

This is true regardless of the current world.

My bad, as Monster pointed out, for rambling on about physics substeps.

Thanks all.