-
|
Hmm, I am trying to investigate an issue, where a sphere spawned above ground and simply falling by gravity doesn't stay still after landing. This is similar to my previous #169, but that time it was my error, where I was accidentally applying additional forces. This time, I simply create a sphere (r 0.10) and drop it on a box ground (he 200x1x200). No forces applied. Sometimes it stays in place after landing, but most often it rolls in some random direction. Any ideas what may be causing this? Or is this some inherent behavior of the solver? I tried earlier Jolt versions, but that didn't seem to affect anything. 2024-10-31.13-36-41.mp4Edit: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
I've tried to reproduce your issue in an example: <!DOCTYPE html>
<html lang="en">
<head>
<title>JoltPhysics.js demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">Loading...</div>
<div id="info">JoltPhysics.js sphere demo</div>
<script src="js/three/three.min.js"></script>
<script src="js/three/OrbitControls.js"></script>
<script src="js/three/WebGL.js"></script>
<script src="js/three/stats.min.js"></script>
<script src="js/example.js"></script>
<script type="module">
// In case you haven't built the library yourself, replace URL with: https://www.unpkg.com/jolt-physics/dist/jolt-physics.wasm-compat.js
import initJolt from './js/jolt-physics.wasm-compat.js';
initJolt().then(function (Jolt) {
// Initialize this example
initExample(Jolt, null);
let convex_radius = 0; // with this it is ok: 0.05
// Create box
var shape = new Jolt.BoxShape(new Jolt.Vec3(200, 1, 200), convex_radius, null);
var creationSettings = new Jolt.BodyCreationSettings(shape, new Jolt.RVec3(0, -1, 0), Jolt.Quat.prototype.sIdentity(), Jolt.EMotionType_Static, LAYER_NON_MOVING);
let body = bodyInterface.CreateBody(creationSettings);
addToScene(body, 0xc7c7c7);
// Create sphere
shape = new Jolt.SphereShape(0.1);
creationSettings = new Jolt.BodyCreationSettings(shape, new Jolt.RVec3(0, 10, 0), Jolt.Quat.prototype.sIdentity(), Jolt.EMotionType_Dynamic, LAYER_MOVING);
creationSettings.mAllowSleeping = false; // and without this it is also ok
body = bodyInterface.CreateBody(creationSettings);
addToScene(body, 0x00ffff);
});
</script>
</body>
</html>I can reproduce the issue, but only if I set mAllowSleeping = false or when I give the box a very small convex radius. I think the issue is that the box is very large compared to the sphere, so the collision detection algorithm has some floating point precision error which results in motion. |
Beta Was this translation helpful? Give feedback.
I've tried to reproduce your issue in an example: