DrawDebugHelpers.h outdated? Persistent lines not working


for an assignment I want to create custom collision detection, and to create my own AABB implementation I’ve been trying to look into the DrawDebugHelpers.h to visualize the box.
However, the class seems outdated as it does not look like the bool bPersistentLines does anything. The Lifetime attribute of -1 doesn’t do anything, either.

The drawn lines disappear after about a second.

This is the code I used. Both lines do not work for more than a second. Setting a breakpoint in FlushPersistentDebugLines did not seem to work either. Is there any alternative or a confirmation that this is outdated?

They should work. They are exposed to blueprint in KismetSystemLibrary and using them regularly (DrawDebugArrow). Never tried bPersistent but setting the time works,

Setting the time only works for natural numbers, really. -1 or 0 do not set the duration to infinite. Those will just make the body disappear very quickly. I just tried it via KismetSystemLibrary in blueprints, too. There surely has to be a way to properly draw permanent primitive bodies into the scene…

Why not set it to an extreme high time value? Keep in mind that stuff is debug and probably will not work in packaged game. So do not design your world with it.

Because I want to do my assignment in a more proper way. Rendering AABBs for visualization (so, not really necessary in shipped builds either) should not have a timebomb attached to it.
I mean, you are right that assigning a high duration would serve well enough for now, but if there is a bPersistent attribute to rendering those primitives, it should work as intended. Currently, it does not.

I for sure prefer the proper way as well, but it feels like I need to workaround things every day, …

If you look into the executed functions, you find that you need to set DepthPriority to SDPG_Foreground for it to work.

Draw them in actor or component Tick() and they work. No parameters for persistent or lifetime.

No parameters for persistent or lifetime just means persistent set to false and lifetime set to -1, which will render for a frame (I guess, a very short time). Drawing them in tick means drawing a new one each frame. Seems bad…

Does this fix the lifetime? If so, that would be… interesting. I will have to try this out later. If not, I will just look into FPrimitiveSceneProxy, as it looks like this is used to render the existing sphere-,boxcomponents etc.

Did not try it, but should work.
Open the DrawDebug… function and have a look youself

Everything gets drawn every frame anyway … Also any moving objects will have to update the lines vertices every frame.

There’s indeed a bug here. The persistent bool is used to pick whether to use LineBatcher or PersistentLineBatcher from the current world. Then, it adds the lines with a default lifetime of 1 second. Both line batcher components are ticked every frame, and decrement the remaining time of each line until zero, then remove them.

So making your lines persistent actually had no effect. Great!

There are 2 simple ways to fix/ work around this:

  1. Set your lines to very high lifetime. This makes it still waste cycles decrementing all the life times though.
  2. Turn off the component tick on World->PersistentLineBatcher. You can do this from anywhere in your code, or put it in a fitting engine method (like UWorld::UpdateWorldComponents).