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 TextRenderer or SpriteRenderer rendering errors #2340

Merged
merged 8 commits into from
Aug 22, 2024

Conversation

singlecoder
Copy link
Member

@singlecoder singlecoder commented Aug 20, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a dynamic text rendering feature in 3D environments, allowing text to appear one character at a time for a more engaging user experience.
    • Added a new configuration for enhanced handling of text-related cases within the end-to-end testing framework.
  • Bug Fixes

    • Improved the merging logic for areas, ensuring that modifications to the areas occur under specific conditions, enhancing overall application stability and efficiency.

Copy link

coderabbitai bot commented Aug 20, 2024

Walkthrough

The recent updates refine functionality within the rendering pipeline by modifying the _freeArea method of the PrimitiveChunk class and advancing the TypedText feature for dynamic text rendering in 3D scenes. Key changes include improved logic for area merging, streamlined variable management, and the introduction of methods for animated text display, enhancing overall clarity and maintainability in the code.

Changes

Files Change Summary
packages/core/src/RenderPipeline/... Updated _freeArea method in PrimitiveChunk to rename areas to freeAreas, streamline merging logic, and enhance readability.
e2e/case/text-typed.ts Introduced TypedText class for simulating typing effects in 3D, with methods for initiating and updating text rendering.
e2e/config.ts Added Text property in E2E_CONFIG for enhanced text handling in end-to-end tests.

Poem

🐇 In the meadow, the changes flow,
A twist in logic, a gentle glow.
Merge with care, let notMerge be,
A dance of code, so wild and free!
Hopping forward, we celebrate,
Each little tweak, a leap of fate! 🌼✨


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.

@singlecoder singlecoder added this to the 1.3 milestone Aug 20, 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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f3400c8 and b94989c.

Files selected for processing (1)
  • packages/core/src/RenderPipeline/PrimitiveChunk.ts (1 hunks)
Additional context used
GitHub Check: lint
packages/core/src/RenderPipeline/PrimitiveChunk.ts

[failure] 166-166:
Delete ·

Additional comments not posted (1)
packages/core/src/RenderPipeline/PrimitiveChunk.ts (1)

165-165: LGTM! Conditional logic improvement.

The use of the logical NOT operator to conditionally splice the areas array enhances the control flow. This change is approved.

@@ -162,7 +162,8 @@
curArea.size += size;
pool.return(preArea);
preArea = curArea;
notMerge = false;
!notMerge && areas.splice(i - 1, 1);
return ;
Copy link

Choose a reason for hiding this comment

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

Fix linting issue: Remove trailing whitespace.

There's a trailing whitespace on this line that should be removed to comply with linting rules.

-        return ;
+        return;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return ;
return;
Tools
GitHub Check: lint

[failure] 166-166:
Delete ·

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 b94989c and 882d72f.

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

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 882d72f and 76d0e79.

Files ignored due to path filters (1)
  • e2e/fixtures/originImage/Text_text-typed.jpg is excluded by !**/*.jpg
Files selected for processing (2)
  • e2e/case/text-typed.ts (1 hunks)
  • e2e/config.ts (1 hunks)
Additional comments not posted (6)
e2e/case/text-typed.ts (5)

6-19: Imports and setup look good.

The imports and initial setup are appropriate for the functionality being implemented.


24-28: Camera setup is appropriate.

The camera is positioned correctly for viewing the scene.


29-35: Text entity and renderer configuration is suitable.

The text renderer is configured correctly for the intended display.


37-72: TypedText class implementation is well-structured.

The class effectively implements the text typing animation and uses private variables appropriately.


75-78: End-to-end test setup is appropriate.

The test setup ensures the TypedText functionality is tested effectively.

e2e/config.ts (1)

211-216: TypedText configuration addition is consistent.

The new configuration follows the existing pattern and correctly adds the necessary details for testing.

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 76d0e79 and 99f3cec.

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

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: 1

Outside diff range, codebase verification and nitpick comments (1)
packages/core/src/RenderPipeline/PrimitiveChunk.ts (1)

141-144: Clarify the initialization of freeAreas.

The initialization logic for freeAreas is clear, but consider adding a comment to explain the purpose of this initialization step for future maintainability.

+    // Initialize with the first free area if none exist
    if (areaLen === 0) {
      freeAreas.push(area);
      return;
    }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 99f3cec and 1613830.

Files selected for processing (1)
  • packages/core/src/RenderPipeline/PrimitiveChunk.ts (1 hunks)
Additional comments not posted (3)
packages/core/src/RenderPipeline/PrimitiveChunk.ts (3)

156-159: Ensure correct insertion logic for non-connected areas.

The logic correctly inserts the area when it is not connected and to the left of the current free area. Ensure this logic is tested for edge cases.

Consider verifying the insertion logic with test cases where multiple non-connected areas are inserted in sequence.


160-166: Correct merging logic for left-connected areas.

The merging logic for areas connected on the left is clear and correctly implemented.

The changes improve readability and maintainability.


181-183: Verify the logic for non-connected right areas.

The logic for handling areas to the right and not connected is correct. Ensure this logic is covered in tests for various scenarios.

Consider verifying with test cases where areas are added to the right in a non-connected manner.

packages/core/src/RenderPipeline/PrimitiveChunk.ts Outdated Show resolved Hide resolved
@GuoLei1990 GuoLei1990 requested a review from johanzhu August 22, 2024 08:50
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

Outside diff range, codebase verification and nitpick comments (3)
packages/core/src/RenderPipeline/PrimitiveChunk.ts (3)

141-144: Improve early return logic.

The early return logic for an empty freeAreas array is clear, but consider using a more descriptive comment.

    const areaLen = freeAreas.length;
    if (areaLen === 0) {
+     // If no free areas exist, simply add the new area.
      freeAreas.push(area);
      return;
    }

156-159: Clarify the insertion logic for non-connected areas.

The logic for inserting a non-connected area is correct, but the comment could be more descriptive.

      if (end < curStart) {
-       // The area to be freed is to the left of the current free area and is not connected
+       // Insert the area to the left of the current free area as they are not connected.
        freeAreas.splice(i, 0, area);
        break;
      }

181-183: Clarify the logic for non-connected right areas.

The logic for handling areas that are not connected on the right is correct, but the comment could be more descriptive.

      } else if (start > curEnd) {
-       // The area to be freed is to the right of the current free area and is not connected
+       // Append the area to the end if it's not connected to the right of any existing area.
        i + 1 === areaLen && freeAreas.push(area);
      }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1613830 and b288145.

Files selected for processing (1)
  • packages/core/src/RenderPipeline/PrimitiveChunk.ts (1 hunks)
Additional comments not posted (2)
packages/core/src/RenderPipeline/PrimitiveChunk.ts (2)

166-178: Optimize the merging logic for right-connected areas.

The logic for merging areas connected on the right is correctly implemented. Consider optimizing by reducing the number of conditional checks.

      } else if (start === curEnd) {
        // The area to be freed is to the right of the current free area and is connected.
        curFreeArea.size += size;
        pool.return(area);
        const nextIndex = i + 1;
        if (nextIndex < areaLen) {
          const nextFreeArea = freeAreas[nextIndex];
          if (end === nextFreeArea.start) {
            // The cur free area after merge is to the left of the next free area and is connected.
            curFreeArea.size += nextFreeArea.size;
            freeAreas.splice(nextIndex, 1);
            pool.return(nextFreeArea);
          }
        }
        break;
      }

160-165: Optimize the merging logic for left-connected areas.

The merging logic for areas connected on the left is correctly implemented. Consider optimizing by reducing the number of operations.

      } else if (end === curStart) {
        // Merge the area to the left of the current free area.
        curFreeArea.start = start;
        curFreeArea.size += size;
        pool.return(area);
        break;
      }

Likely invalid or redundant comment.

Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review.

Project coverage is 69.49%. Comparing base (f3400c8) to head (18110eb).
Report is 4 commits behind head on main.

Files Patch % Lines
packages/core/src/RenderPipeline/PrimitiveChunk.ts 82.75% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2340      +/-   ##
==========================================
- Coverage   69.50%   69.49%   -0.02%     
==========================================
  Files         524      524              
  Lines       27405    27412       +7     
  Branches     4100     4102       +2     
==========================================
+ Hits        19049    19051       +2     
- Misses       6852     6859       +7     
+ Partials     1504     1502       -2     

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

break;
} else if (start > curEnd) {
// The area to be freed is to the right of the current free area and is not connected
i + 1 === areaLen && freeAreas.push(area);
Copy link
Member

Choose a reason for hiding this comment

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

Waste performance,use fallback mode: if not success, push it at end

Copy link
Member Author

Choose a reason for hiding this comment

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

done

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 b288145 and 38ac37f.

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

@GuoLei1990 GuoLei1990 merged commit a2fee5f into galacean:main Aug 22, 2024
7 checks passed
@cptbtptpbcptdtptp cptbtptpbcptdtptp added the bug Something isn't working label Aug 22, 2024
@cptbtptpbcptdtptp cptbtptpbcptdtptp changed the title Fix primitive chunk free area error Fix TextRenderer or SpriteRenderer rendering errors Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2D bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants