Placeable visibility range - an experiment

The new SetObjectVisibleDistance() function allows us to overcome that annoying problem with dynamic placeables and doors disappearing beyond 45m or so.

Quite rightly, it comes with dire warnings about performance. However, for SP, I wondered what would happen if I turned it on universally. It’s early days, but so far the results are stunning, with no obvious degradation.

The following code is one-shot OnClientEnter:

const float  FOREVER          = 1000000000000.0; 
// Override dynamic object visibility
// This may degrade performance - if so, apply selectively
void zSetObjectVisibleDistance()
  object oArea            = GetFirstArea();
  object oObject;
  int    nObjectType;
  float  fVisibilityRange = FOREVER;

  while (GetIsObjectValid(oArea))
      oObject = GetFirstObjectInArea(oArea);

      while (GetIsObjectValid(oObject))
          nObjectType = GetObjectType(oObject);

          if ((nObjectType == OBJECT_TYPE_PLACEABLE)
          ||  (nObjectType == OBJECT_TYPE_DOOR))
            SetObjectVisibleDistance(oObject, fVisibilityRange);

          oObject = GetNextObjectInArea(oArea);

      oArea  = GetNextArea();
1 Like

It really depends on the number and what the placeables are. If you have a lot (thousands, tens of thousands) of them, then the loading time will be longer (although with the recent 100x improvements there, it might not matter).

Additionally, having that many non-static objects will impact serverside performance (remember, in SP the same program runs both server and client) when it comes to calculating updates. So the impact scales with number of players.

Render performance is the least of concerns. It depends on what the object is, but usually it’s not relevant unless we’re talking about thousands of ultra high poly, fancymapped things.

In patch 36 (currently in preview) there’s tools that let you measure this quite accurately, like so:

I recommend turning this on and then comparing where time is spent before/after you run your script.

1 Like

Wish it could be enabled globally via .2da, tho, like setting grass distance.