Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bundles/robot_simulation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"three": "^0.181.0"
},

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link

Choose a reason for hiding this comment

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

Bug: The code accesses result.toi, which was renamed to result.timeOfImpact in the upgraded rapier library, causing distance to be undefined at runtime.
Severity: CRITICAL

Suggested Fix

In src/bundles/robot_simulation/src/engine/Physics.ts, replace the property access result.toi with result.timeOfImpact. The corresponding test mock in src/bundles/robot_simulation/src/engine/__tests__/Physics.test.ts should also be updated to use timeOfImpact to reflect the new API.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/bundles/robot_simulation/package.json#L8

Potential issue: The upgrade of the rapier physics library to v0.19.3 introduces a
breaking change where the `toi` property on ray casting results was renamed to
`timeOfImpact`. The code in `src/bundles/robot_simulation/src/engine/Physics.ts`
accesses `result.toi` when processing a ray cast result. At runtime, this will evaluate
to `undefined`, causing the `distance` field in the function's return value to be
`undefined`. This will lead to incorrect physics calculations or errors in downstream
code expecting a number. The issue is not caught by tests because the rapier library is
fully mocked.

Did we get this right? 👍 / 👎 to inform future reviews.

"devDependencies": {
"@dimforge/rapier3d-compat": "^0.11.2",
"@dimforge/rapier3d-compat": "^0.19.0",

This comment was marked as outdated.

"@sourceacademy/modules-buildtools": "workspace:^",

This comment was marked as outdated.

"@types/three": "^0.181.0",
"typescript": "^5.8.2"
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/RobotSimulation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@blueprintjs/core": "^6.0.0",
"@dimforge/rapier3d-compat": "^0.11.2",
"@dimforge/rapier3d-compat": "^0.19.0",
"@sourceacademy/bundle-robot_simulation": "workspace:^",
"@sourceacademy/modules-lib": "workspace:^",
"react": "^18.3.1",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2051,10 +2051,10 @@ __metadata:
languageName: node
linkType: hard

"@dimforge/rapier3d-compat@npm:^0.11.2":
version: 0.11.2
resolution: "@dimforge/rapier3d-compat@npm:0.11.2"
checksum: 10c0/41cabb96219f493000a8785a003dd7dee007f8f2983bae4703c9862bb24328b2ec69255187f3d9a244ac28b390bddf55949f6dbf09db6a051a90d3db2915df3a
"@dimforge/rapier3d-compat@npm:^0.19.0":
version: 0.19.3
resolution: "@dimforge/rapier3d-compat@npm:0.19.3"
checksum: 10c0/e056552cbfe07d7036485241b803ee3cb094e178021e27b0e33b2a9c9b1afa9c13e8d6d6825f21e37b75f60fa1ee80640becb5e75040b0245ec2c453b305c679
languageName: node
linkType: hard

Expand Down Expand Up @@ -4248,7 +4248,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@sourceacademy/bundle-robot_simulation@workspace:src/bundles/robot_simulation"
dependencies:
"@dimforge/rapier3d-compat": "npm:^0.11.2"
"@dimforge/rapier3d-compat": "npm:^0.19.0"
"@sourceacademy/modules-buildtools": "workspace:^"
"@sourceacademy/modules-lib": "workspace:^"
"@types/three": "npm:^0.181.0"
Expand Down Expand Up @@ -4807,7 +4807,7 @@ __metadata:
resolution: "@sourceacademy/tab-RobotSimulation@workspace:src/tabs/RobotSimulation"
dependencies:
"@blueprintjs/core": "npm:^6.0.0"
"@dimforge/rapier3d-compat": "npm:^0.11.2"
"@dimforge/rapier3d-compat": "npm:^0.19.0"
"@sourceacademy/bundle-robot_simulation": "workspace:^"
"@sourceacademy/modules-buildtools": "workspace:^"
"@sourceacademy/modules-lib": "workspace:^"
Expand Down
Loading