SpiderPig Posted September 10, 2023 Share Posted September 10, 2023 The code below gives 3 different error messages (if you press ignore each time). Here's the first one; Only get the errors in debug mode. In release mode the object is shot away at speed. #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -8); camera->SetDebugPhysicsMode(true); auto light = CreateDirectionalLight(world); light->SetRotation(35, 35, 0); auto box = CreateCylinder(world, 0.5f, 1.8f); box->SetMass(1.0f); box->SetColor(0, 1, 0); auto floor = CreateBox(world, 10, .1, 10); floor->SetPosition(0, -2, 0); auto joint = CreateKinematicJoint(box->position, box); joint->SetMaxForce(100); joint->SetMaxTorque(100); auto pivot = CreatePivot(nullptr); float a = 0, y = 0; while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { pivot->AlignToVector(Vec3(0, 0, -1)); auto quat = pivot->GetQuaternion(); joint->SetPose(Vec3(0, y, 0), quat); world->Update(); world->Render(framebuffer); } return 0; } Quote Link to comment Share on other sites More sharing options...
Josh Posted September 11, 2023 Share Posted September 11, 2023 It seems to be because the target rotation is 180 degrees away from the current orientation. Maybe the solver can't decide which way to turn? Line 337 of dgCustomKinematicController.cpp: dAssert(lateralDir.DotProduct3(lateralDir) > 1.0e-6f); Simplified example: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -8); camera->SetDebugPhysicsMode(true); auto light = CreateDirectionalLight(world); light->SetRotation(35, 35, 0); auto box = CreateCylinder(world, 0.5f, 1.8f); box->SetMass(1.0f); auto joint = CreateKinematicJoint(box->position, box); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { joint->SetPose(Vec3(0, 0, 0), Vec3(0,180,0)); world->Update(); world->Render(framebuffer); } return 0; } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted September 11, 2023 Share Posted September 11, 2023 Reported here: https://github.com/MADEAPPS/newton-dynamics/issues/321 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted September 12, 2023 Share Posted September 12, 2023 I tried commenting out the assert statement. In my code below, any rotation closer to 180 causes the joint to just not react. I suppose this is better than crashing, but still not ideal. #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -4); camera->SetDebugPhysicsMode(true); auto light = CreateDirectionalLight(world); light->SetRotation(35, 35, 0); auto box = CreateCylinder(world, 0.5f, 1.8f); box->SetMass(1.0f); auto joint = CreateKinematicJoint(box->position, box); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { joint->SetPose(Vec3(0, 0, 0), Vec3(0, 178.6, 0)); } world->Update(); world->Render(framebuffer); } return 0; } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted September 15, 2023 Share Posted September 15, 2023 Newton forum is back up: http://newtondynamics.com/forum/viewtopic.php?f=12&t=9825 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted September 19, 2023 Share Posted September 19, 2023 As I suspected there is no perfect solution when the target rotation is 180 degrees opposite from the current rotation, because one degree of freedom is lost. I'm not sure at this point what should be done or if this is just the way things work. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted October 29 Solution Share Posted October 29 Fixed, with Julio's help. Quote My job is to make tools you love, with the features you want, and performance you can't live without. 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.