Skip to content

Fix camera changing position during microbe rotation#6966

Draft
dligr wants to merge 1 commit intomasterfrom
fix_weird_rotation
Draft

Fix camera changing position during microbe rotation#6966
dligr wants to merge 1 commit intomasterfrom
fix_weird_rotation

Conversation

@dligr
Copy link
Copy Markdown
Member

@dligr dligr commented May 1, 2026

Brief Description of What This PR Does

Apparently, microbe cells were rotated around their center of mass instead of their position, while the camera followed their normal position. This caused the bug that this PR is marked as fixing.

Now that the camera follows the center of mass, there is a side effect; it follows colonies' center instead of the lead cell. Let me know if this is undesirable; there might be an alternate solution

Related Issues

Fix #4696

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

  • PR author has checked that this PR works as intended and doesn't
    break existing features:
    https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
    (this is important as to not waste the time of Thrive team
    members reviewing this PR). This includes gameplay testing by the PR author.
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    styleguide.

Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.

@dligr dligr added this to the Release 1.1.0 milestone May 1, 2026
@dligr dligr requested review from a team May 1, 2026 14:43
@dligr dligr added the review label May 1, 2026
@github-project-automation github-project-automation Bot moved this to In progress in Thrive Planning May 1, 2026
@ChevyLevi
Copy link
Copy Markdown
Contributor

ChevyLevi commented May 1, 2026

it follows colonies' center instead of the lead cell.

From my personal point of view, this solution might be confusing for players. I think it's quite important for the lead cell to stay in the center of screen.
As about the workflow: I think this solution is actually changing the original design, and it should only happen when the game designer say so (i.e. programmers should not change the design by themselves)
Is it possible to rotate the cell / cells from their position in jolt?
edit: find this from the suggestion site:https://suggestions.revolutionarygamesstudio.com/posts/8/center-the-camera-on-the-entire-colony-instead-of-the-player-cell , the most voted suggestion at the site

Copy link
Copy Markdown

@ImanProductions ImanProductions left a comment

Choose a reason for hiding this comment

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

my game freezes when I try to start a new playthrew

@dligr dligr marked this pull request as draft May 2, 2026 18:56
@hhyyrylainen
Copy link
Copy Markdown
Member

There was some additional context for this PR in Discord. And also there has been player requests for centering the camera on the center of a cell colony. So fundamentally I think this would be a good change. Though there are quite many considerations with other code. But still I think this is a good approach to take as if our physics engine applies rotation on the center of mass rather than local origin of a physics body, this logic fix will make things easier.

However one quite key point is that right now cell orientation is set based on a look vector from entity origin to a world position, so if the camera centering point is changed then the look position point algorithm or cell rotation target algorithm has to be updated to match, otherwise rotation will get really hard to manage if the camera is a significant distance away from the entity origin.


(position.Position, position.Rotation) = physicalWorld.ReadBodyPosition(body);

physics.CenterOfMassPosition = physicalWorld.ReadBodyCenterOfMassPosition(body);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rather than constantly reading and saving this in Physics component, I think this should either be cached in the physics shape wrapper or just directly re-read by the systems that really need this.

Because I think re-reading this for each body on each frame in the base position system is a major waste of processing power.

{
const JPH::Body& body = lock.GetBody();

positionReceiver = body.GetCenterOfMassPosition();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

An interesting note here: Jolt internally stores bodie's positions as the center of mass position. However, our normal read does internally in Jolt a reverse translation to get the origin: mPosition - mRotation * mShape->GetCenterOfMass();

So in effect to get the center of mass, we can take the position we read back already and apply the center of mass and rotation to it from the physics shape. Thus I believe that while this method is useful to exist, we should probably structure this PR for performance reasons to have a cached shape center of mass that exists on our C# shape wrapper for easy access. And then we should be able to just use the shape + WorldPosition to get the center of mass: position.Position + position.Rotation * shape.CenterOfMass (shape.CenterOfMass would be a new property here).

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

Labels

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Rotating the camera now causes the cell position to change

4 participants