Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transform parent dirty error when added as root entity #2311

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

cptbtptpbcptdtptp
Copy link
Collaborator

@cptbtptpbcptdtptp cptbtptpbcptdtptp commented Aug 6, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Other information:

Summary by CodeRabbit

  • New Features

    • Enhanced transformation state management for entities in the scene, improving rendering accuracy for non-root entities.
  • Bug Fixes

    • Streamlined transformation state propagation through the entity hierarchy to ensure accurate updates.
  • Tests

    • Added new test case titled "Parent Dirty" to verify the behavior of transformations in hierarchical structures.

@cptbtptpbcptdtptp cptbtptpbcptdtptp self-assigned this Aug 6, 2024
Copy link

coderabbitai bot commented Aug 6, 2024

Walkthrough

The recent changes enhance the Entity and Scene classes by improving the management of transformation states within the entity hierarchy. The introduction of the _setTransformDirty method ensures that any updates in a parent entity’s transformation are propagated to its children. Additionally, the Scene class has been modified to ensure that non-root entities are marked as dirty, facilitating accurate updates. The test suite has also been revised to validate these changes, focusing on parent-child relationships and transformation behaviors.

Changes

File Path Change Summary
packages/core/src/Entity.ts Introduced _setTransformDirty method for better transformation management; previous implementation removed.
packages/core/src/Scene.ts Added logic to mark non-root entities as dirty in their transformation state.
tests/src/core/Transform.test.ts Updated entity creation logic; added new test for parent-child transformation relationships.

Sequence Diagram(s)

sequenceDiagram
    participant Parent as Parent Entity
    participant Child as Child Entity
    participant Scene as Scene Manager

    Parent->>Child: Add as child
    Parent->>Parent: Mark as dirty
    Parent->>Child: Call _setTransformDirty
    Child->>Scene: Check world position
    Scene-->>Child: Update position based on Parent
Loading

🐰 In the world of code, where entities dance,
A twist in the tale, a new chance!
Transformations ripple, like waves in the sea,
Parent and child, in harmony be.
With every change, our game grows bright,
Hooray for the updates, oh what a delight! 🍃✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cptbtptpbcptdtptp cptbtptpbcptdtptp added the bug Something isn't working label Aug 6, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f01c996 and 2ecce79.

Files selected for processing (3)
  • packages/core/src/Entity.ts (2 hunks)
  • packages/core/src/Scene.ts (1 hunks)
  • tests/src/core/Transform.test.ts (3 hunks)
Additional comments not posted (4)
tests/src/core/Transform.test.ts (2)

15-16: Verify scene assignment logic.

The scene is now assigned from engine.sceneManager.scenes[0] instead of engine.sceneManager.activeScene. Ensure that this change is intentional and does not affect other tests relying on the active scene.


29-48: LGTM! Consider adding more assertions.

The test case effectively validates the transformation propagation. Consider adding more assertions to cover edge cases or different transformation scenarios.

packages/core/src/Scene.ts (1)

366-366: LGTM! Verify the impact on performance.

The addition of _setTransformDirty for non-root entities ensures accurate transformation updates. Verify that this change does not introduce any performance regressions, especially in scenes with a large number of entities.

packages/core/src/Entity.ts (1)

589-600: LGTM! Ensure unit tests cover this method.

The method _setTransformDirty ensures accurate propagation of transformation changes. Ensure that unit tests cover this method to validate its functionality.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2ecce79 and c12827e.

Files selected for processing (1)
  • packages/core/src/Scene.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/Scene.ts

@GuoLei1990 GuoLei1990 merged commit 17ccfb4 into galacean:main Aug 7, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants