You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into some blocking bugs with Oimo's kinematic bodies. It seems particularly problematic with rotated kinematic bodies. Code to reproduce is included below. The code can be pasted into Oimo's demo editor.
Steps to reproduce:
The first bug appears immediately after you run the code for the first time. The smallest boxes rendered by the test code represent the contact points returned by getContact.
BUG1 Oimo reports incorrect contact points between kinematic bodies the very first time the world is stepped, even if the bodies are not actually in contact.
To workaround the stepping issue, set stepTwice to true in the code. This will run world.step() twice before each test case is rendered.
When the output updates, see that no contact points are shown at first. This is correct.
Click on the demo output area and press the spacebar to test the next case.
The blue box moves into the red box and some approximately correct contact points are shown.
Press the space bar again.
BUG2 The blue box moves to the edge of the red box and now two of the contact points are incorrect.
I realize this library isn't actively maintained anymore, but I thought I'd post this bug for anyone else running into these issues.
varstationaryBody,stationaryMesh,movingBody,movingMesh;varcontactPointMeshes;vartestStep=0;// Press SPACE to step through the test cases.// Test parameters:varstepTwice=false;varstationaryBodyRotation=10;varmovingBodyRotation=-10;functiondemo(){cam(40,20,15);world=newOIMO.World();view.hideGrid();varstationaryBodyOptions={size: [10,10,10],rot: [0,stationaryBodyRotation,0],move: true,noSleep: true,kinematic: true,};stationaryBody=world.add(stationaryBodyOptions);stationaryMesh=view.add(stationaryBodyOptions);stationaryMesh.material=newTHREE.MeshStandardMaterial({color: "red",transparent: true,opacity: 0.5});varmovingBodyOptions={size: [2,2,2],rot: [0,movingBodyRotation,0],move: true,noSleep: true,kinematic: true,};movingBody=world.add(movingBodyOptions);movingMesh=view.add(movingBodyOptions);movingMesh.material=newTHREE.MeshStandardMaterial({color: "blue"});contactPointMeshes=[view.add({size: [1,1,1]}),view.add({size: [1,1,1]}),view.add({size: [1,1,1]}),view.add({size: [1,1,1]}),];contactPointMeshes[0].material=newTHREE.MeshStandardMaterial({color: "green"});contactPointMeshes[1].material=newTHREE.MeshStandardMaterial({color: "orange"});contactPointMeshes[2].material=newTHREE.MeshStandardMaterial({color: "yellow"});contactPointMeshes[3].material=newTHREE.MeshStandardMaterial({color: "violet"});runTestStep();}varkeyWasDown=false;functionupdate(){if(!keyWasDown&&user.key[4]){runTestStep();keyWasDown=true;}if(!user.key[4]){keyWasDown=false;}}functionrunTestStep(){console.log(testStep);switch(testStep){case0:
movingBody.setPosition({x: 0,y: 0,z: 8});break;case1:
movingBody.setPosition({x: 0,y: 0,z: 5});break;case2:
movingBody.setPosition({x: 5,y: 0,z: 5});break;}world.step();if(stepTwice)world.step();movingMesh.position.copy(movingBody.getPosition());updateContacts();testStep=(testStep+1)%3;}functionupdateContacts(){contactPointMeshes.forEach((m)=>(m.visible=false));constcontact=world.getContact(stationaryBody,movingBody);if(contact){console.log(contact.points.map((p)=>[p.position.x.toFixed(2),p.position.y.toFixed(2),p.position.z.toFixed(2)].join(", ")).join(" | "));for(leti=0;i<contact.points.length;i++){contactPointMeshes[i].visible=true;contactPointMeshes[i].position.copy(contact.points[i].position);}}}
The text was updated successfully, but these errors were encountered:
I've run into some blocking bugs with Oimo's kinematic bodies. It seems particularly problematic with rotated kinematic bodies. Code to reproduce is included below. The code can be pasted into Oimo's demo editor.
Steps to reproduce:
getContact
.stepTwice
totrue
in the code. This will runworld.step()
twice before each test case is rendered.I realize this library isn't actively maintained anymore, but I thought I'd post this bug for anyone else running into these issues.
The text was updated successfully, but these errors were encountered: