Skip to content

feat(physics): Interpolation#1563

Open
joaomanita wants to merge 1 commit intomainfrom
1459-fix-localtoworld-update-and-smooth-physics-movement
Open

feat(physics): Interpolation#1563
joaomanita wants to merge 1 commit intomainfrom
1459-fix-localtoworld-update-and-smooth-physics-movement

Conversation

@joaomanita
Copy link
Contributor

things

Description

Add Interpolated{} to entities to interpolate them.
Example in distance constraint sample.

Checklist

  • Self-review changes.
  • Evaluate impact on the documentation.
  • Ensure test coverage.
  • [ x] Write new samples.
  • Add entry to the changelog's unreleased section.

@joaomanita joaomanita linked an issue Jun 21, 2025 that may be closed by this pull request
@github-actions github-actions bot added B-Collisions B-Physics B-Transform P-Urgent This issue is a big priority, and it would be good to close it ASAP S-Triage Issues whose priority still has to be figured out labels Jun 21, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jun 21, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://GameDevTecnico.github.io/cubos/preview/pr-1563/

Built to branch gh-pages at 2025-09-04 17:22 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link

codecov bot commented Jun 21, 2025

Codecov Report

❌ Patch coverage is 0% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.60%. Comparing base (c1ec1e2) to head (20c626c).
⚠️ Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
engine/src/interpolation/plugin.cpp 0.00% 53 Missing ⚠️
engine/src/physics/solver/integration/plugin.cpp 0.00% 6 Missing ⚠️
.../src/physics/solver/distance_constraint/plugin.cpp 0.00% 1 Missing ⚠️
...c/physics/solver/penetration_constraint/plugin.cpp 0.00% 1 Missing ⚠️
engine/src/physics/solver/plugin.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1563      +/-   ##
==========================================
- Coverage   51.98%   51.60%   -0.38%     
==========================================
  Files         497      500       +3     
  Lines       27029    27303     +274     
  Branches     2512     2557      +45     
==========================================
+ Hits        14051    14091      +40     
- Misses      12978    13212     +234     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@RiscadoA RiscadoA left a comment

Choose a reason for hiding this comment

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

Ty for working on this! Will be very very useful for online multiplayer too 👀
I'm not very familiar with the physics code, but I have two doubts regarding this implementation:

  • why would Interpolated be optional? Shouldn't it always be used? I don't see a reason to use physics without interpolation.
  • the whole interpolation mechanism should be independent from the physics plugin. It should be a separate plugin, outside the physics directory. Of course, the physics plugin would depend on it. This would allows us to use it for other stuff such as online multiplayer without necessarily enabling physics.

Copy link
Contributor

@fallenatlas fallenatlas left a comment

Choose a reason for hiding this comment

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

Sorry for thanking so long to review and thank you for working on this! 🙏 Overall, I think this works well for what we want, I only have a couple concerns.

@fallenatlas
Copy link
Contributor

Ty for working on this! Will be very very useful for online multiplayer too 👀 I'm not very familiar with the physics code, but I have two doubts regarding this implementation:

  • why would Interpolated be optional? Shouldn't it always be used? I don't see a reason to use physics without interpolation.

I think it reduces the necessity of the dev knowing that exists at the start and yeah, ideally we'd always want it I think. I guess it isn't for the same reasons as the solver and stuff also isn't included with the physics which, tbh, I think we should also change those as it doesn't make a lot of sense.

  • the whole interpolation mechanism should be independent from the physics plugin. It should be a separate plugin, outside the physics directory. Of course, the physics plugin would depend on it. This would allows us to use it for other stuff such as online multiplayer without necessarily enabling physics.

Having in account that fixed step is also not part of the physics plugin I think this would make sense yes. I'm worried about how it would work having multiple plugins writing to the same thing and having it work well. But, the biggest problem I see is that, this interpolation is strictly for fixedStep, if we had for example servers running outside of fixedStep I'm not sure if this plugin would be good for that.

@joaomanita joaomanita force-pushed the 1459-fix-localtoworld-update-and-smooth-physics-movement branch from 9568356 to f045a50 Compare July 16, 2025 18:55
Copy link
Member

@RiscadoA RiscadoA left a comment

Choose a reason for hiding this comment

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

LGTM other than what I just pointed out!


CUBOS_REFLECT_IMPL(cubos::engine::Interpolated)
{
return cubos::core::ecs::TypeBuilder<Interpolated>("cubos::engine::Interpolated").build();
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to not include reflection for the struct's fields?

@joaomanita joaomanita force-pushed the 1459-fix-localtoworld-update-and-smooth-physics-movement branch from f045a50 to 17379de Compare August 17, 2025 16:34
@joaomanita joaomanita force-pushed the 1459-fix-localtoworld-update-and-smooth-physics-movement branch from 17379de to 11eb603 Compare August 23, 2025 09:39
@joaomanita joaomanita requested a review from fallenatlas August 23, 2025 09:40
Copy link
Contributor

@fallenatlas fallenatlas left a comment

Choose a reason for hiding this comment

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

Just a couple more things.

Also, I have a doubt. Do we have a guarantee that Position is nextPosition when a fixedStep starts? We need it to make sure that the physics remain independent from the framerate.

Comment on lines +41 to +46
/// @ingroup interpolation-plugin
/// @brief Interpolates position, rotation and scale of entities with the @ref Interpolated component in between
/// fixed updates.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these comments meant to be here this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What could be different? That there is no rotation interpolation yet?

@joaomanita joaomanita force-pushed the 1459-fix-localtoworld-update-and-smooth-physics-movement branch from 11eb603 to c3b4b44 Compare August 26, 2025 19:00
@joaomanita joaomanita force-pushed the 1459-fix-localtoworld-update-and-smooth-physics-movement branch from c3b4b44 to 20c626c Compare September 4, 2025 17:19
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment on lines +32 to +36
if (timer.value >= step.value)
{
return true;
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-simplify-boolean-expr ⚠️
redundant boolean literal in conditional return statement

Suggested change
if (timer.value >= step.value)
{
return true;
}
return false;
return timer.value >= step.value;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-Collisions B-Physics B-Transform P-Urgent This issue is a big priority, and it would be good to close it ASAP S-Triage Issues whose priority still has to be figured out

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix localToWorld update and smooth physics movement.

3 participants