Comments (12)
Hey! Thank you for reporting the issue. I did a quick bisect, the bug was introduced by commit b7ce8be80e6e4c2e71a5d5e3a08aca2676d7c990
. The stack trace (at the commit) is
Uncaught TypeError: v is undefined
transformVec2 Matrix.ts:223
Distance Distance.ts:173
testOverlap Distance.ts:749
update Contact.ts:584
updateContacts World.ts:977
step World.ts:809
Stack trace for main:
transformVec2 Matrix.ts:236
Distance Distance.ts:175
testOverlap Distance.ts:743
update Contact.ts:590
updateContacts World.ts:978
step World.ts:810
Will take a closer look tomorrow, I guess this should be a relatively easy fix
from planck.js.
One more option is adding combine3Vec2 function, so that we can also use it here
@zOadT Up to you, feel free to do whatever you prefer
from planck.js.
Oh yeah, combine3Vec2
is also more similar to the other matrix functions. Will open a PR tomorrow!
from planck.js.
Yes (Sorry, forgot to close it)
from planck.js.
Yes, I will in a few days, I also merged a few changes
from planck.js.
@shakiba It worked! Thank you :)
from planck.js.
The issue is caused by numeric inaccuracy. It can be solved in PolygonShape.ts
by replacing
// (A)
matrix.combineVec2(center, 1, center, triangleArea * k_inv3, e1);
matrix.combineVec2(center, 1, center, triangleArea * k_inv3, e2);
with
center.x += triangleArea * k_inv3 * e1.x + triangleArea * k_inv3 * e2.x;
center.y += triangleArea * k_inv3 * e1.y + triangleArea * k_inv3 * e2.y;
It really is just a numeric issue because the issue shows up again if you set
center.x = center.x + triangleArea * k_inv3 * e1.x + triangleArea * k_inv3 * e2.x;
center.y = center.y + triangleArea * k_inv3 * e1.y + triangleArea * k_inv3 * e2.y;
and can be solved again by setting parentheses
center.x = center.x + (triangleArea * k_inv3 * e1.x + triangleArea * k_inv3 * e2.x);
center.y = center.y + (triangleArea * k_inv3 * e1.y + triangleArea * k_inv3 * e2.y);
Could it be that maybe some sizes/masses of bodies are outside of the recommend order of magnitude because they span the entire world?
@shakiba This issue wasn't present in alpha because (A)
was
center.addCombine(triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);
In general this seems to me to be numerically more stable because the terms being combined are probably the same order of magnitude. Shall we reintroduce a matrix.addCombineVec2
function and use it where previously addCombine
was used in the entire code base? But might actually also have to check why this caused an error.
from planck.js.
Hmm, very interesting—thanks for reporting and investigating this!
How about assigning e1, e2 combination value to a temporary variable and then adding it to center?
from planck.js.
I prefer to have fewer functions in new matrix, but this seems a common use-case so I think adding a new function as you suggest is also a good idea.
from planck.js.
Is this resolved now?
from planck.js.
Thanks!
from planck.js.
@zOadT @shakiba Thank you! Could you guys make a new beta version of planck in dist? or are you waiting to release v1?
from planck.js.
Related Issues (20)
- When will version 1 be released? HOT 5
- Feature Request: Implementation of b2Draw, SetDebugDraw and DebugDraw HOT 7
- Changing a circle collider's friction doesn't make it roll slower HOT 1
- Feature Request: Add the ESM button to jsDelivr
- How to change a collider's center? HOT 5
- Why does displacement cause multiple begin and end contact events? HOT 6
- Typo in the Wiki HOT 4
- setActive(true) throwing error in v1 beta 8
- ERROR changing a collider's mass cancels its linearVelocity HOT 5
- planck's npm package is quite large HOT 8
- possible testOverlap bug HOT 2
- Undefined Reading "x" error HOT 5
- Raycasts phasing through walls HOT 6
- clarification on the determinism limitation from docs HOT 1
- pointers on how to network planck HOT 8
- inconsistent Vec2 construction throughout examples
- DistanceJoint `getReactionForce` function not working HOT 4
- Script tag: Uncaught TypeError: t is null HOT 2
- Cannot read properties of undefined (reading "x") HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from planck.js.