Page MenuHome

BGE: New hysteresis offset to improve LOD level transitions
ClosedPublic

Authored by Jorge Bernal (lordloki) on Dec 28 2014, 4:08 AM.

Details

Summary

This change introduces a new hysteresis parameter that it will be added or subtracted to/from the LOD distance to avoid popping when a LOD object moves close to the LOD transition continuously.

Then, we have the following:

  • a new LOD Hysteresis setting per object (default 10%) which is located in Object context --> Levels of Detail panel:

  • a new LOD Hysteresis setting per scene (default 10%) which is located in Scene context --> Level of Detail panel:

The LOD hysteresis setting per object (if active) will overwrite the hysteresis setting per scene.

For the new blends: the hysteresis setting per scene would be active by default and the per object would be inactive by default.
For the old blends: both hysteresis settings (per scene and per object) would be inactive by default. A quick way to take advantage of this feature for old blends would be to activate the hysteresis parameter in the scene context -> Level of Detail panel

Diff Detail

Repository
rB Blender
Branch
bge-patch-LOD_Hysteresis

Event Timeline

Jorge Bernal (lordloki) retitled this revision from to BGE: New hysteresis offset to improve LOD level transitions.
Jorge Bernal (lordloki) updated this object.

If the default value is 0, I don't think you need to bother with a doversion.

I feel like the UI tooltip could use some work. Perhaps something like "Minimum distance change required to transition to the previous level of detail."

What are your thoughts on changing this from a fixed distance value to a percentage based value? In other words, calculate offset as a percentage of the difference between two LoD distances. I feel like this could give us a more useful default value as it would adjust to various setups. Perhaps a default of 10%? And what do you think about changing the property to "Hysteresis" instead of "Offset"?

Jorge Bernal (lordloki) edited edge metadata.
  • Change offset name by Hysteresis
  • makes the hysteresis percentage to be in function of the 2 contiguous LOD levels
  • hysteresis value by default is 10%

Daniel, I adressed all your suggestions. I think they improve the feature.

Awesome!

I think you meant to set hysteresis to 10 in the do_version, though. Otherwise, looks good to me.

  • rna range fix
  • Update to current master

I think you meant to set hysteresis to 10 in the do_version, though. Otherwise, looks good to me.

I guess that if we set hysteresis to 10 in the do_version then old files behaviour will be modified and we will have to put a warning in release notes. Perhaps, i'm misunderstanding your comment.

Hmm . . . fair point. We don't want to force existing projects to use this new feature. If you are only setting it to zero, I am pretty sure you don't even need to bother with a do_version, as I am pretty sure it will automatically be loaded as zero (probably due to a calloc).

  • revert do_version changes as they are not needed in this case

. . . I am pretty sure you don't even need to bother with a do_version, as I am pretty sure it will automatically be loaded as zero (probably due to a calloc).

Yes, you're right. I just update the diff.

Daniel Stokes (kupoman) edited edge metadata.

Looks good to me, would be nice to get one more approval on this.

This revision is now accepted and ready to land.Jan 15 2015, 2:28 AM

There is a do_versions type thing for the startup file. We could put the change into that so all new projects will have a good default. We'll also want to add something to the release notes letting people know that they may want to try out the new default in their old projects.

I just realized this wasn't a per-scene setting which seems a little strange (one might be nice to offer global control for those that don't want per LoD control). Also, all new LoDs in a project will default to 10, which could cause some confusion and make LoDs accidentally inconsistent in old projects. Maybe we want a setting that enables hysteresis. Then all LoDs (new and old) could default to 10. Old scenes would disable the feature by default and new scenes can have it enabled by default.

Then basically (if I understand well) we would have:

  • a LOD Hysteresis setting per object (default 10%):

  • a LOD Hysteresis setting per scene (default 10%):

and the LOD hysteresis setting per object (if active) overwrite the hysteresis setting per scene.

For the new blends: the hysteresis setting per scene would be active by default and the per object would be inactive by default.
For the old blends: both hysteresis settings (per scene and per object) would be inactive by default and a note would be put in the release notes pointing how take advantage of this new feature.

Do I understand it correctly? (it is to avoid mistakes in the implementation)

I like those UI changes. It would probably be better to call the per object LoD check box "Hysteresis Override" to make it clear that it takes precedence over the global setting.

  • Added a new hysteresis scene parameter active by default
  • Hysteresis object parameter will override scene one
  • do_versions implemented

Just curious but why is this feature BGE only? couldn't it be enabled for everything in blender like Cycles and BI?

  • Update to current master
  • Ammend do_versions
  • ammend hysteresis data type
  • Update to current master
Mitchell Stokes (moguri) edited edge metadata.

I am okay with this, but I would wait on another okay from Daniel before committing.

The checkbox on the scene panel header seems a little confusing. The UI looks like it should be enabling/disabling LoDs, but the code seems to be enabling/disabling the global hysteresis setting.

I also noticed a minor style inconsistency that I noted in an inline comment.

source/gameengine/Ketsji/KX_GameObject.h
796

The style here looks inconsistent.

Jorge Bernal (lordloki) edited edge metadata.
  • Modified behaviour to correct one. This is: hysteresis setting at scene context active/deactive hysteresis. Hysteresis setting at object context only can work when the hysteresis scene setting is actived.
  • Modify the UI to follow above behaviour
  • New functions at scene level: IsActivedLodHysteresis and SetLodHysteresis
  • SetLodHysteresis at object level rename to SetLodHysteresisValue
  • Fix style inconsistency

The UI still looks like it might be inconsistent with the check box on the Scene's LoD panel header controlling the use of global hysteresis, but the header label is "Level of Detail". It looks like that check box would disable/enable the use of levels of detail instead of controlling the hysteresis setting.

  • rework the UI for Scene hysteresis
  • set up defaults values in BLO_update_defaults_startup_blend to avoid modifying the startup.blend
  • Update to current master
  • Style changes

Closing revision.

It was committed but it has not been reflected in phabricator. Maybe, related to the git issue.

Thanks for reviewing it.

This revision was automatically updated to reflect the committed changes.

Can we expose object.lodLevel ?

returns None if not set?

also, can we define a object as the center of the LOD in real time?

Sniping is tricky in the current setup.

could the LOD be set as a property in each object?

object['LOD'] ?

this would allow states to be driven using the data,

another idea.... allow states to be set directly by LOD?