Can't see DrawDebugBox

Hi,

I’ve read in another topic it could be anisotropic, but this is not my case.

I’m developing an editor plugin. The user should be able to place Boxes as he clicks in the scene. I was using PDI’s DrawPoint in the first place, but I need the box size to be consistent with world dimensions and DrawPoint’s entities change the size as I zoom in the scene.

My plugin’s tool class inherits from UMeshSurfacePointTool and overrides OnUpdateDragMethod, this adds elements to the container:



void UPainterTool::OnUpdateDrag(const FRay& Ray)
{
    FHitResult OutHit;
    if (HitTest(Ray, OutHit))
    {
            auto halfThickness = Settings->Thickness / 2;
            v1.SetX(OutHit.ImpactPoint.X - halfThickness);
            v1.SetY(OutHit.ImpactPoint.Y - halfThickness);
            v1.SetZ(OutHit.ImpactPoint.Z - halfThickness);

            Vector v2;
            v2.SetX(OutHit.ImpactPoint.X + halfThickness);
            v2.SetY(OutHit.ImpactPoint.Y + halfThickness);
            v2.SetZ(OutHit.ImpactPoint.Z + halfThickness);

            //add element to container
             m_childInterface->Hit(&v1, &v2, (void*)&Settings->Thickness);


The elements are rendered in the tool’s render class, looping through the container:



DrawDebugBox(GetWorld(), FVector(elem->m_min->X(), elem->m_min->Y(), elem->m_min->Z()), FVector(elem->m_max->X(), elem->m_max->Y(), elem->m_max->Z()), outColor.ToFColor(false), false, 1, 1.0f);

elem = m_childInterface->GetNext();


I’ve been trying rendering options in the editor without any luck

Any ideas?
Best regards.

I figured out what was happening

I was using GetWorld() which I don’t know what the hell it is, but It’s not the editor world
Apart from that, I was passing min and max coordinates to DrawDebugBox, but this funcion expects a center a extents

UWorld* currentWorld = GEditor->GetEditorWorldContext().World();
DrawDebugBox(currentWorld, center, extent, fColor, true, -1);

Wasted lot of time, I hope this is useful for someone

1 Like

I guess if I’m painting every frame it should be something like this, but it flickers
DrawDebugBox(currentWorld, center, extent, fColor, false, FApp::GetDeltaTime());

Changing the line thickness should fix flickering I think. We use DrawDebugLine() a lot and everywhere in code line thickness is set to 2.0.