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

Remove unused physX function and update wasm with NO_DYNAMIC_EXECUTION #2490

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

luzhuang
Copy link
Contributor

@luzhuang luzhuang commented Jan 7, 2025

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

  • Refactor

    • Removed getter methods for linear and angular damping in physics-related interfaces and classes.
    • Updated PhysX library script URLs for JavaScript and WebAssembly runtime modes.
  • Bug Fixes

    • Simplified error handling for unsupported physics methods in lightweight physics implementation.

@luzhuang luzhuang added physics Engine's physical system ignore for release ignore for release labels Jan 7, 2025
@luzhuang luzhuang added this to the 1.4 milestone Jan 7, 2025
@luzhuang luzhuang requested a review from GuoLei1990 January 7, 2025 03:07
Copy link

coderabbitai bot commented Jan 7, 2025

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • packages/physics-physx/libs/physx.release.downgrade.js

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request involves removing getter methods for linear damping, angular damping, and maximum depenetration velocity across multiple physics-related files. The changes impact the IDynamicCollider interface in the design package and implementation classes in both physics-lite and physics-PhysX packages. Additionally, the PhysX physics initialization script URLs have been updated for both JavaScript and WebAssembly runtime modes.

Changes

File Change Summary
packages/design/src/physics/IDynamicCollider.ts Removed getLinearDamping() and getAngularDamping() method declarations
packages/physics-lite/src/LiteDynamicCollider.ts Removed getAngularDamping(), getLinearDamping(), and getMaxDepenetrationVelocity() methods
packages/physics-physx/src/PhysXDynamicCollider.ts Removed getLinearDamping(), getAngularDamping(), and getMaxDepenetrationVelocity() methods
packages/physics-physx/src/PhysXPhysics.ts Updated PhysX script URLs for JavaScript and WebAssembly runtime modes

Possibly related PRs

  • Support get contact points and get closest point on shape from a point #2458: This PR involves the removal of methods related to getting contact points and closest points on shapes, which aligns with the removal of getLinearDamping() and getAngularDamping() methods in the main PR, indicating a broader change in how certain physics properties are accessed across different classes.

Suggested labels

bug

Suggested reviewers

  • GuoLei1990
  • zhuxudong

Poem

🐰 Damping methods, farewell and adieu!
Interfaces trimmed, clean and new
PhysX scripts dance with updated grace
Lighter, faster - physics embrace!
Hop along, code, with streamlined might! 🚀


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

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

🧹 Nitpick comments (1)
packages/physics-physx/src/PhysXPhysics.ts (1)

93-93: Consider adding integrity checks and fallback URLs for external scripts

The script URLs have been updated, but there are several security and reliability concerns:

  1. No integrity checks (SRI) for externally loaded scripts
  2. No version pinning in URLs
  3. No fallback URLs if the CDN is unavailable

Consider implementing the following improvements:

 if (runtimeMode == PhysXRuntimeMode.JavaScript) {
-  script.src = `https://mdn.alipayobjects.com/rms/afts/file/A*yYWPSZFhS_0AAAAAAAAAAAAAARQnAQ/physx.no-wasm.js`;
+  script.src = PRIMARY_CDN + '/physx.no-wasm.js';
+  script.integrity = 'sha384-...'; // Add SRI hash
+  script.crossOrigin = 'anonymous';
+  script.onerror = () => {
+    script.src = FALLBACK_CDN + '/physx.no-wasm.js';
+  };
 } else if (runtimeMode == PhysXRuntimeMode.WebAssembly) {
-  script.src = `https://mdn.alipayobjects.com/rms/afts/file/A*WoEgTJ2foH4AAAAAAAAAAAAAARQnAQ/physx.release.js`;
+  script.src = PRIMARY_CDN + '/physx.release.js';
+  script.integrity = 'sha384-...'; // Add SRI hash
+  script.crossOrigin = 'anonymous';
+  script.onerror = () => {
+    script.src = FALLBACK_CDN + '/physx.release.js';
+  };
 }

Also applies to: 95-95

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07c6475 and d832313.

⛔ Files ignored due to path filters (1)
  • packages/physics-physx/libs/physx.release.wasm is excluded by !**/*.wasm
📒 Files selected for processing (4)
  • packages/design/src/physics/IDynamicCollider.ts (0 hunks)
  • packages/physics-lite/src/LiteDynamicCollider.ts (0 hunks)
  • packages/physics-physx/src/PhysXDynamicCollider.ts (0 hunks)
  • packages/physics-physx/src/PhysXPhysics.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • packages/design/src/physics/IDynamicCollider.ts
  • packages/physics-physx/src/PhysXDynamicCollider.ts
  • packages/physics-lite/src/LiteDynamicCollider.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build (22.x, windows-latest)
  • GitHub Check: codecov
  • GitHub Check: e2e (22.x)
🔇 Additional comments (1)
packages/physics-physx/src/PhysXPhysics.ts (1)

93-96: Verify compatibility with the new PhysX script versions

The URLs point to new script versions which could introduce breaking changes. Please ensure:

  1. The new scripts are compatible with the current implementation
  2. All removed getter methods (mentioned in PR title) are properly handled
  3. Add tests to verify the integration still works as expected

Run the following script to check for any usage of the removed getter methods:

✅ Verification successful

Implementation is compatible with new PhysX script versions

The codebase is already adapted to work without the getter methods:

  • Only setter methods are implemented in PhysXDynamicCollider
  • All examples and tests use property access syntax
  • No deprecated method calls found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to the removed getter methods
rg -i "getLinearDamping|getAngularDamping|getMaxDepenetrationVelocity"

Length of output: 72


Script:

#!/bin/bash
# Find all PhysX-related files
fd -e ts -e js physx -i

# Search for method calls in PhysX-related files
ast-grep --pattern 'physx.$_($_)'

# Look for test files
fd -e spec.ts -e test.ts physx -i

Length of output: 1362


Script:

#!/bin/bash
# Check dynamic collider implementation
cat packages/physics-physx/src/PhysXDynamicCollider.ts

# Search for damping-related code
rg -i "damping|velocity" packages/physics-physx/src/

# Look for property access patterns
ast-grep --pattern '$_.linearDamping'
ast-grep --pattern '$_.angularDamping'

Length of output: 13395

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 68.89%. Comparing base (42d0927) to head (15bead1).
Report is 8 commits behind head on dev/1.4.

Files with missing lines Patch % Lines
packages/physics-physx/src/PhysXPhysics.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           dev/1.4    #2490      +/-   ##
===========================================
+ Coverage    68.42%   68.89%   +0.47%     
===========================================
  Files          923      923              
  Lines        95904    96007     +103     
  Branches      8138     8138              
===========================================
+ Hits         65621    66145     +524     
+ Misses       30029    29608     -421     
  Partials       254      254              
Flag Coverage Δ
unittests 68.89% <50.00%> (+0.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@GuoLei1990 GuoLei1990 merged commit ac6f5f5 into galacean:dev/1.4 Jan 7, 2025
7 of 9 checks passed
@GuoLei1990 GuoLei1990 changed the title Remove unused physX function Remove unused physX function and update wasm with no dynamic Jan 7, 2025
@GuoLei1990 GuoLei1990 changed the title Remove unused physX function and update wasm with no dynamic Remove unused physX function and update wasm with NO_DYNAMIC_EXECUTION Jan 7, 2025
singlecoder pushed a commit to singlecoder/engine that referenced this pull request Jan 8, 2025
* refactor: remove unused physx function

* feat: update downgrade version
@coderabbitai coderabbitai bot mentioned this pull request Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore for release ignore for release physics Engine's physical system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants