Closed adil192 closed 1 year ago
Have you checked that the body doesn't fall asleep when you do such a large timestep?
Have you checked that the body doesn't fall asleep when you do such a large timestep?
The test still fails when I set allowSleep to false.
I've found with 11524c5d0934cfcca5dac751eb416d262d1a7675 that the test fails when the time step is bigger than 0.2s (not including 0.2s).
I tried to find and replace all 0.2
literals in the forge2d repo with 0.3
but this didn't help.
Does this also happen on lower velocities and the same timesteps? Maybe it hits some upper velocity limit per timestep
Good idea. I changed the velocity from 10 to 5 and the timestep error occured at 0.401 instead of 0.201
Looks like this maxTranslation
value is to blame
Edit: Looks like we commented at the same time; changing the value to e.g. 4.0
passes the test successfully
Since it is that one, I would just zoom in for the rendering and use lower velocities :) https://www.iforce2d.net/b2dtut/gotchas#speedlimit
I could simply increase this value but I don't think that actually solves the problem, but just increases the maximum time step before we see unexpected behaviour (e.g. when the user minimises and then reopens the app, the time step will be several seconds).
It seems like we should be multiplying maxTranslation
by the time step to allow it to scale properly, perhaps renaming the value to maxTranslationPerSecond
or rather just maxVelocity
?
Oh okay I'll try that
Even when I set the zoom to 10000000000.0
it's still too slow for my bullets. (After every collision, I check to see if the speed is <10% of what it's supposed to be, which is almost always true in debug mode).
Do you know if there's a way to change the maxTranslation
value without forking forge2d
?
Or maybe we could preserve the maxTranslation
value, but if we hit this limit, leave the velocity as it is?
Also my previous point about minimising and reopening the app or browser tab still stands, see this screen recording where the bullets are at almost zero velocity after returning to the tab https://github.com/flame-engine/forge2d/assets/21128619/e0b420af-1e13-4a4c-a1ab-a9e0f787f052
Even when I set the zoom to
10000000000.0
it's still too slow for my bullets. (After every collision, I check to see if the speed is <10% of what it's supposed to be, which is almost always true in debug mode). Do you know if there's a way to change themaxTranslation
value without forkingforge2d
? Or maybe we could preserve themaxTranslation
value, but if we hit this limit, leave the velocity as it is?
That sounds very strange, are you using flame_forge2d?
Also my previous point about minimising and reopening the app or browser tab still stands, see this screen recording where the bullets are at almost zero velocity after returning to the tab https://github.com/flame-engine/forge2d/assets/21128619/e0b420af-1e13-4a4c-a1ab-a9e0f787f052
You have to either pause the engine or just discard too big dt
s when that happens.
Do you know if there's a way to change the maxTranslation value without forking forge2d?
That variable is mutable, you should be able to just change it directly.
That sounds very strange, are you using flame_forge2d?
Yep I'm using flame_forge2d: ^0.14.1
You have to either pause the engine or just discard too big dts when that happens.
I feel like this should be part of the physics engine, e.g. if the dt is bigger than some threshold, break it up into 0.1s increments. Edit: I'm making a PR in the flame_forge2d repo
Do you know if there's a way to change the maxTranslation value without forking forge2d?
That variable is mutable, you should be able to just change it directly.
import 'package:forge2d/src/settings.dart' as physics_settings;
physics_settings.maxTranslation = Bullet.speed;
This works perfectly albeit with this warning:
Import of a library in the 'lib/src' directory of another package.
Try importing a public library that exports this library, or removing the import.dart[implementation_imports](https://dart-lang.github.io/linter/lints/implementation_imports.html)
Description
Added a (failing) test that bodies with no linear damping shouldn't slow down over time.
If you'd like me to close this PR and just make a regular bug report issue, please let me know :)
Checklist
fix:
,feat:
,docs:
etc).docs
and added dartdoc comments with///
.examples
.Breaking Change
Related Issues
https://github.com/adil192/ricochlime/issues/1
Other info
`flutter doctor --verbose`
``` [✓] Flutter (Channel stable, 3.10.6, on macOS 14.0 23A5286i darwin-x64, locale en-GB) • Flutter version 3.10.6 on channel stable at /Users/adilhanney/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f468f3366c (4 weeks ago), 2023-07-12 15:19:05 -0700 • Engine revision cdbeda788a • Dart version 3.0.6 • DevTools version 2.23.1 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) • Android SDK at /Users/adilhanney/Library/Android/sdk • Platform android-33, build-tools 33.0.2 • Java binary at: /usr/local/opt/openjdk/bin/java • Java version OpenJDK Runtime Environment Homebrew (build 20.0.1) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14E300c • CocoaPods version 1.12.1 [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [!] Android Studio • Android Studio at /Users/adilhanney/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.9923731/Android Studio Preview.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio. [!] Android Studio • Android Studio at /Users/adilhanney/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10023527/Android Studio Preview.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio. [✓] VS Code (version 1.80.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.70.0 [✓] Connected device (1 available) • macOS (desktop) • macos • darwin-x64 • macOS 14.0 23A5286i darwin-x64 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 3 categories. ```