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 particle bugs #2256

Merged
merged 3 commits into from
Jul 23, 2024
Merged

Fix particle bugs #2256

merged 3 commits into from
Jul 23, 2024

Conversation

GuoLei1990
Copy link
Member

@GuoLei1990 GuoLei1990 commented Jul 22, 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)

Two bugs:

  • Fix alpha bug
  • Fix update multi times when use multi camera

Summary by CodeRabbit

  • New Features

    • Improved particle rendering process for enhanced visual effects.
    • Enhanced alpha transparency handling for particles, allowing for more nuanced visual transitions over time.
  • Bug Fixes

    • Resolved issues related to particle updates and rendering coherence, ensuring smoother performance.
  • Refactor

    • Simplified method naming conventions across various rendering classes, improving clarity and consistency in the rendering process.

@GuoLei1990 GuoLei1990 changed the base branch from main to dev/1.3 July 22, 2024 11:50
Copy link

coderabbitai bot commented Jul 22, 2024

Warning

Rate limit exceeded

@GuoLei1990 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 15 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between bd09bc8 and c56ba16.

Walkthrough

The changes streamline the rendering process by renaming methods and consolidating logic across multiple renderer classes. The _updateRendererShaderData method has been transformed into a simpler _update method, enhancing clarity and readability. Additionally, the shader file improvements allow for dedicated alpha transparency management, separating it from color handling. These modifications contribute to a more coherent and efficient rendering system overall.

Changes

Files Change Summary
packages/core/src/Renderer.ts Renamed _updateRendererShaderData to _update, clarifying its purpose in the rendering cycle.
packages/core/src/mesh/SkinnedMeshRenderer.ts Updated _updateRendererShaderData to _update, maintaining functionality while simplifying naming.
packages/core/src/particle/ParticleRenderer.ts Consolidated generator update logic into _update, enhancing control flow and shader preparation.
packages/core/src/shaderlib/particle/color_over_lifetime_module.glsl Replaced colorKeys with alphaKeys for clearer alpha transparency management in shader behavior.

Poem

In fields of code where particles play,
A hop and a jump, we've changed the way!
With alpha keys dancing, colors so bright,
Our rendering's clearer, a joyous sight.
So here’s to the changes, let’s give a cheer,
For the magic of shaders, we hold so dear! 🐰✨


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.

@GuoLei1990 GuoLei1990 added bug Something isn't working particle labels Jul 22, 2024
@GuoLei1990 GuoLei1990 requested a review from JujieX July 22, 2024 11: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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e3bf27e and 4b7bfab.

Files selected for processing (2)
  • packages/core/src/particle/ParticleRenderer.ts (2 hunks)
  • packages/core/src/shaderlib/particle/color_over_lifetime_module.glsl (1 hunks)
Additional comments not posted (3)
packages/core/src/shaderlib/particle/color_over_lifetime_module.glsl (1)

25-25: Verify the initialization of alphaKeys.

Ensure that alphaKeys is correctly initialized and populated before being used in this function.

Verification successful

Let's correct the previous command and search for alphaKeys initialization without specifying the file type.


Verify the initialization and population of alphaKeys.

The alphaKeys array is correctly initialized and populated in the ParticleGradient class before being used in the shader code.

  • Initialization: packages/core/src/particle/modules/ParticleGradient.ts
    • Constructor: Initializes alphaKeys if provided.
    • setKeys method: Sets alphaKeys and ensures they are correctly populated.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization and population of `alphaKeys`.

# Test: Search for the initialization of `alphaKeys`. Expect: Proper initialization and population.
rg --type glsl $'alphaKeys'

Length of output: 55


Script:

#!/bin/bash
# Description: Verify the initialization and population of `alphaKeys`.

# Test: Search for the initialization of `alphaKeys`. Expect: Proper initialization and population.
rg 'alphaKeys'

Length of output: 5863

packages/core/src/particle/ParticleRenderer.ts (2)

196-198: Ensure the generator is correctly updated.

The generator is now updated within _updateRendererShaderData. Verify that this change does not introduce any side effects.

Verification successful

The generator is correctly updated.

The _update method in the ParticleGenerator class ensures the generator is updated based on the engine's delta time. No side effects were found in the updated logic.

  • packages/core/src/particle/ParticleGenerator.ts (line 264): _update method implementation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the generator update logic.

# Test: Search for the `_update` method in `ParticleGenerator`. Expect: Correct update logic.
rg --type ts $'ParticleGenerator._update'

Length of output: 40


Script:

#!/bin/bash
# Search for the ParticleGenerator class and list its methods
ast-grep --lang typescript --pattern $'class ParticleGenerator {
  $$$
}'

Length of output: 100721


199-201: Ensure correct handling of no particles to render.

The condition to check if there are no particles to render has been moved to _updateRendererShaderData. Verify that this change does not introduce any side effects.

Verification successful

The condition to check if there are no particles to render is correctly handled within _updateRendererShaderData.

  • The condition if (generator._firstActiveElement === generator._firstFreeElement) { return; } is present in the _updateRendererShaderData method in ParticleRenderer.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the condition to check if there are no particles to render.

# Test: Search for the `_firstActiveElement` and `_firstFreeElement` in `ParticleGenerator`. Expect: Correct handling of no particles to render.
rg --type ts $'_firstActiveElement|_firstFreeElement'

Length of output: 3298


Script:

#!/bin/bash
# Description: Verify the condition to check if there are no particles to render in `_updateRendererShaderData`.

# Test: Search for the `_updateRendererShaderData` method definition and inspect its implementation.
rg --type ts '_updateRendererShaderData' -A 20

Length of output: 8137

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 4b7bfab and bd09bc8.

Files selected for processing (3)
  • packages/core/src/Renderer.ts (2 hunks)
  • packages/core/src/mesh/SkinnedMeshRenderer.ts (2 hunks)
  • packages/core/src/particle/ParticleRenderer.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/particle/ParticleRenderer.ts
Additional comments not posted (2)
packages/core/src/mesh/SkinnedMeshRenderer.ts (1)

Line range hint 157-213:
LGTM! But verify the method usage in the codebase.

The renaming of the method _updateRendererShaderData to _update simplifies the method name while retaining its functionality. The internal call to the superclass method has been updated accordingly. The logic and control flow remain intact.

However, ensure that all method calls to _updateRendererShaderData have been updated to _update.

Verification successful

All instances of _updateRendererShaderData have been successfully updated to _update.

The renaming of the method _updateRendererShaderData to _update has been comprehensively applied across the codebase.

  • No occurrences of _updateRendererShaderData were found in the TypeScript files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `_updateRendererShaderData` have been updated to `_update`.

# Test: Search for the method usage. Expect: Only occurrences of the new method name.
rg --type typescript -A 5 $'_updateRendererShaderData'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify all method calls to `_updateRendererShaderData` have been updated to `_update`.

# Test: Search for the method usage. Expect: Only occurrences of the new method name.
rg --type ts -A 5 $'_updateRendererShaderData'

Length of output: 45

Tools
Biome

[error] 154-154: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

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

413-416: LGTM! But verify the method usage in the codebase.

The renaming of the method _updateRendererShaderData to _update simplifies the method name while retaining its functionality. The internal call to the method has been updated accordingly. The logic and control flow remain intact.

However, ensure that all method calls to _updateRendererShaderData have been updated to _update.

Verification successful

All references to _updateRendererShaderData have been updated to _update.

The renaming of the method has been correctly applied throughout the codebase. There are no remaining references to _updateRendererShaderData.

  • packages/core/src/Renderer.ts: Verified usage of _update.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `_updateRendererShaderData` have been updated to `_update`.

# Test: Search for the method usage. Expect: Only occurrences of the new method name.
rg --type typescript -A 5 $'_updateRendererShaderData'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify all method calls to `_updateRendererShaderData` have been updated to `_update`.

# Test: Search for the method usage. Expect: Only occurrences of the new method name.
rg '_updateRendererShaderData'

Length of output: 30


Script:

#!/bin/bash
# Description: Verify the usage of the new method name `_update` in the codebase.

# Test: Search for the method usage. Expect: Occurrences of the new method name.
rg '_update'

Length of output: 37725

@GuoLei1990 GuoLei1990 changed the title Fix particle bug Fix particle bugs Jul 22, 2024
@GuoLei1990 GuoLei1990 merged commit 63203db into galacean:dev/1.3 Jul 23, 2024
6 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 particle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants