V_1.0.0 Posted June 29, 2018 Share Posted June 29, 2018 I have 2 objects: 1) with physics 2) without physics I rotate both objects on: mesh_impostor.rotate (new BABYLON.Vector3 (0, 1, 0), Math.PI + Math.PI / 2); mesh_impostor.rotate (new BABYLON.Vector3 (1, 0, 0), Math.PI / 3); and I get a different result: rotationQuaternion: {x: -0.3535533905932737, y: 0.6123724356957946, z: -0.35355339059327373, w: -0.6123724356957945} physicsImpostor.physicsBody.orientation {x: 0.3535533905932736, y: -0.6123724356957946, z: -0.3535533905932737, w: 0.6123724356957945} demo: https://playground.babylonjs.com/indexStable.html#MARWS6#1 Quote Link to comment Share on other sites More sharing options...
Guest Posted June 29, 2018 Share Posted June 29, 2018 Hello, several quaternions can represent the same rotation and I think this is what you witness here V_1.0.0 1 Quote Link to comment Share on other sites More sharing options...
V_1.0.0 Posted June 29, 2018 Author Share Posted June 29, 2018 But they are in different positions. I see it Quote Link to comment Share on other sites More sharing options...
Guest Posted June 29, 2018 Share Posted June 29, 2018 Right Let me ping our Physics mastermind: @RaananW V_1.0.0 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 30, 2018 Share Posted June 30, 2018 Hi guys. https://playground.babylonjs.com/indexStable.html#MARWS6#2 Looks like it is an Oimo-only issue. CannonJS looks fine. Welcome to the forum, v100! Thx for the report. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 30, 2018 Share Posted June 30, 2018 Hi again. A bit more help for Raanan and the pros... perhaps. https://playground.babylonjs.com/#MARWS6#3 There... is the same playground again... Oimo active, and I have inserted a "bootleg" Oimo plugin into the playground. The Oimo plugin code you are seeing... is ALMOST the same as what is installed in core... but it adds/honors the "belongsTo" and "collidesWith" parameters... two parameters not normally addressed by our current Oimo plugin. Not important (except for making human leg joints). In that #3 playground above... look at the aligned shapes. Look at the MATCHING numbers at console. How was this done? (Okay, okay, the SIGN of the 'w' or 's' value doesn't always match in the 2 console reports. I'm not sure if that matters. The x/y/z values and signs are perfect, though.) Within line 64's generatePhysicsBody() function... check out lines 115 and 116. Line 115 is the original, line 116 is modified. I added .negate() I just bet... some work/mods (sort-of-) recently happened... on the Quaternion.toEulerAngles() function. .toEulerAngles() is one of those "slippery" functions... where every 45 days, somebody re-designs it. Ok, I don't know if anything useful got done here, but this might "heat-up the trail" to the actual problem. V_1.0.0 1 Quote Link to comment Share on other sites More sharing options...
V_1.0.0 Posted June 30, 2018 Author Share Posted June 30, 2018 Forgive me, but it's quite difficult for me, I can not solve this task myself. Oimo.js and babylon.js (v3.2.0 and v3.3.0-alpha.9) have this problem. I found the old version v3.2.0-alpha7 (null engine) on which everything worked correctly for my project and I will use it. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 30, 2018 Share Posted June 30, 2018 Yeah, no problems, v100... we'll figure this out. Thanks again for the report/find. My previous post was for helping other troubleshooters find the issue quicker. For fun, it might be interesting to compare Quaternion.toEulerAngles() code... across all 3 of those BJS versions. See if you see differences. Okay, that might NOT be fun. heh. Try to be patient.... we'll get this updated soon. I'm glad you found a work-around... good job on that. V_1.0.0 1 Quote Link to comment Share on other sites More sharing options...
adam Posted July 1, 2018 Share Posted July 1, 2018 I'd bet that Quaternion.toEulerAngles is not the issue. The last change was over a year ago: https://github.com/BabylonJS/Babylon.js/blame/master/src/Math/babylon.math.ts#L3522 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
adam Posted July 1, 2018 Share Posted July 1, 2018 I started to look at this on the debug PG, but didn't get far because of an error with OIMO: https://playground.babylonjs.com/debug.html#MARWS6#4 Quote Link to comment Share on other sites More sharing options...
Guest Posted July 2, 2018 Share Posted July 2, 2018 Pinging @RaananW Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 7, 2018 Share Posted July 7, 2018 Hi. Does anyone have any (change-of) status reports, on this? Get the BJSOIMO issue first? Work-in-progress? (thx) Update: Not sure if helpful, but I assembled a playground with ALL THREE applicable physics classes... into the playground code, gathered from the latest BJS distribution. All three are active in this PG. https://playground.babylonjs.com/#MARWS6#7 PhysicsEngine, physicsImpostor, and OimoJSPlugin classes... all on-board, ready for experimenting. All are VERY fresh and default. Some reports are going to console, reporting the problem. An unwanted difference in signs... for some of the values in the last two reported lines. The problem: After physicsImpostor is added to mesh (lines 1201+ area)... ...physics_mesh.rotationQuaternion (a BJS Quat class) does NOT match physics_mesh.physicsImpostor.physicsBody.orientation (an OimoJS Quat class, likely) It should, I suspect. The act-of adding the physics impostor.... rotated the mesh. It should not do that. Not only boxImpostor. Same problem if/when sphereImpostor is chosen. Wingnut-tested. I think issue might be in lines 126-130 area, or nearby. Line 126 is not MY comment. Another coder, likely rahhhh-nin Lines 187 and 189 are points of interest, too. All assistance welcome, all ideas welcome, all play welcome. Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 9, 2018 Share Posted July 9, 2018 As wingnut said, it is an oimo issue. Since we moved to a build earlier than the one we used before, I had to change the way rotation is calculated, which seems to be wrong. I will work on that tomorrow and submit a PR. Wingnut and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 10, 2018 Share Posted July 10, 2018 PR submitted - https://github.com/BabylonJS/Babylon.js/pull/4722 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 10, 2018 Share Posted July 10, 2018 Thanks Raanan! From the PR... // set the quaternion, ignoring the previously defined (euler) rotation impostor.physicsBody.resetQuaternion(globalQuaternion); // update with delta 0, so the body will receive the new rotation impostor.physicsBody.updatePosition(0); That's cool! Last line... sync the shape with the impostor... with a 0 timeStep (do it now). Perhaps the Oimo author SHOULD have made two update functions, one for position and one for orientation [rotation]. Instead, the Oimo updatePosition() func syncs/updates both position AND orientation. Sweet fix and good learning opportunity for all of us. Well done! Raanan gets free drinks for the next 24 hours! Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 10, 2018 Share Posted July 10, 2018 Oimo is not that quick in accepting fixes (see - https://github.com/lo-th/Oimo.js/pull/70 from March). So, this is the best way to do it updatePosition with 0 delta means 0 ms passed, but - please update the body's position and rotation. It is not needed if the body has a mass, but a mass - 0 means the body is technically sleeping and doesn't have its position updated. What drinks do I get? Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 12, 2018 Share Posted July 12, 2018 *nod* Your choice on drinks, but... no gold malts or diamond soup, eh? Just send bill to BJS Forum Comptroller. I'm wondering if the new build was done or if the PG "latest" was updated. https://playground.babylonjs.com/#MARWS6#7 I still see the issue. (after I cleared history and did unconditional reloads). ---------------------- @RaananW/others... do you have any information about @adam's debug error? https://playground.babylonjs.com/debug.html#MARWS6#4 I show... this.BJSOIMO is undefined Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 12, 2018 Share Posted July 12, 2018 Seems like oimo is loaded incorrectly on debug mode. We'll take care of this soon. About the bug - it should already be integrated, I will check and update here. Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 13, 2018 Share Posted July 13, 2018 it is integrated already, the demo you provided had the physics plugin redefined. see here - https://playground.babylonjs.com/#MARWS6#10 about the debug mode - a fix will be merged soon. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.