Skip to content

Prevent physics log spam for line/point meshes#1835

Merged
david-lively merged 3 commits into
mainfrom
physics-log-spam
May 20, 2026
Merged

Prevent physics log spam for line/point meshes#1835
david-lively merged 3 commits into
mainfrom
physics-log-spam

Conversation

@j9liu

@j9liu j9liu commented May 11, 2026

Copy link
Copy Markdown
Contributor

Description

Working with scale in Unreal has continually resulted in headaches due to the aggressive epsilon checks in code. The loudest complaints are from Chaos (the physics engine), which we previously merged #1668 for.

However, we were still coming across log spam due to some models with small glTF line primitives:

image

It turns out the workaround in UCesiumGltfPrimitiveComponent::OnCreatePhysicsState is not sufficient for line primitives, because BodyInstance.InitBody does not result in a valid body instance even with a scale of 1. You can confirm this if you add and put a breakpoint on this return:

  if (!BodyInstance.IsValidBodyInstance() &&
      BodyTransform.GetScale3D().IsNearlyZero()) {
    FTransform BodyTransformWithoutScale = BodyTransform;
    BodyTransformWithoutScale.SetScale3D(FVector(1.0));

    UBodySetup* BodySetup = GetBodySetup();
    BodyInstance.InitBody(
        BodySetup,
        BodyTransformWithoutScale,
        this,
        GetWorld()->GetPhysicsScene());
    if(!BodyInstance.IsValidBodyInstance())
        return;
    BodyInstance.UpdateBodyScale(BodyTransform.GetScale3D());
  }

So when Super::OnCreatePhysicsState is called, it seems the BodyInstance is not valid, so it will try to BodyInstance.InitBody with the original small scale. That results in the "Scale3D is (nearly) zero" warning spam.

The most elegant solution seemed to be to avoid this call chain entirely. But we need to set the bPhysicsStateCreated variable from UActorComponent to true, otherwise a check somewhere else in the code complain.

I also added this check to our points component, since I imagine something similar could happen later down the line.

Issue number or link

N/A

Author checklist

  • I have submitted a Contributor License Agreement (only needed once).
  • I have done a full self-review of my code.
  • I have updated CHANGES.md with a short summary of my change (for user-facing changes).
  • [ ] I have added or updated unit tests to ensure consistent code coverage as necessary.
    • We DO have unit tests for physics, but I'm not sure how to test whether or not a log was printed to the console.
  • I have updated the documentation as necessary.

Testing plan

Reach out to me for a testing dataset.

  1. Open 06_CesiumMetadata in the Cesium Samples.
  2. Add a tileset with many small line components to the level (best examples are from AEC).
  3. Reposition the CesiumGeoreference origin and the DynamicPawn to view the new tileset.
  4. Press Play.

The physics interactions should still work with everything else, and merely ignore the lines.

Reviewer checklist

Thank you for taking the time to review this PR. By approving a PR you are taking as much responsibility for these changes as the author.

As you review, please go through the checklist below:

  • Review and run all parts of the test plan on this branch and verify it matches expectations.
    • If the issue is a bug please make sure you can reproduce the bug in the main branch and then checkout this branch to make sure it actually solved the issue.
  • Review the code and make sure you do not have any remaining questions or concerns. You should understand the code change and the chosen approach. If you are not confident or have doubts about the code, please do not hesitate to ask questions.
  • Review the unit tests and make sure there are no missing tests or edge cases.
  • Review documentation changes and updates to CHANGES.md to make sure they accurately cover the work in this PR.
  • Verify that the Contributor License Agreement has been submitted, if needed.

@j9liu j9liu added this to the June 2026 Release milestone May 12, 2026
@j9liu j9liu self-assigned this May 12, 2026
@laurenfrederick laurenfrederick requested a review from azrogers May 12, 2026 15:23
@j9liu j9liu force-pushed the physics-log-spam branch from c3019d3 to b725e84 Compare May 19, 2026 16:13

@david-lively david-lively left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@david-lively david-lively merged commit ed42c1b into main May 20, 2026
23 checks passed
@david-lively david-lively deleted the physics-log-spam branch May 20, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants