diff --git a/core/src/objects/joint/rotate.cpp b/core/src/objects/joint/rotate.cpp index da05a12..10b7ce3 100644 --- a/core/src/objects/joint/rotate.cpp +++ b/core/src/objects/joint/rotate.cpp @@ -2,6 +2,7 @@ #include "objects/jointsservice.h" #include "objects/part.h" #include "objects/workspace.h" +#include "rendering/renderer.h" #include Rotate::Rotate(): JointInstance(&TYPE) { @@ -9,6 +10,7 @@ Rotate::Rotate(): JointInstance(&TYPE) { Rotate::~Rotate() { } +static CFrame XYZToZXY(glm::vec3(0, 0, 0), -glm::vec3(1, 0, 0), glm::vec3(0, 0, 1)); void Rotate::buildJoint() { // Only if both parts are set, are not the same part, are part of a workspace, and are part of the same workspace, we build the joint @@ -22,19 +24,18 @@ void Rotate::buildJoint() { // Update Part1's rotation and cframe prior to creating the joint as reactphysics3d locks rotation based on how it // used to be rather than specifying an anchor rotation, so whatever. - CFrame newFrame = part0.lock()->cframe * (c1.Inverse() * c0); + CFrame newFrame = part0.lock()->cframe * (c0 * c1.Inverse()); part1.lock()->cframe = newFrame; workspace->SyncPartPhysics(part1.lock()); - - rp::HingeJointInfo jointInfo(part0.lock()->rigidBody, part1.lock()->rigidBody, (c0.Inverse() * c1).Position(), (part0.lock()->cframe * c0).LookVector().Unit().Abs()); + // Do NOT use Abs() in this scenario. For some reason that breaks it + rp::HingeJointInfo jointInfo(part0.lock()->rigidBody, part1.lock()->rigidBody, newFrame.Position(), -(part0.lock()->cframe * c0).LookVector().Unit()); this->joint = dynamic_cast(workspace->physicsWorld->createJoint(jointInfo)); jointWorkspace = workspace; - part1.lock()->rigidBody->getCollider(0)->setCollideWithMaskBits(0b10); - part1.lock()->rigidBody->getCollider(0)->setCollisionCategoryBits(0b10); - part0.lock()->rigidBody->getCollider(0)->setCollideWithMaskBits(0b01); - part0.lock()->rigidBody->getCollider(0)->setCollisionCategoryBits(0b01); - printf("Bits set\n"); + // part1.lock()->rigidBody->getCollider(0)->setCollideWithMaskBits(0b10); + // part1.lock()->rigidBody->getCollider(0)->setCollisionCategoryBits(0b10); + // part0.lock()->rigidBody->getCollider(0)->setCollideWithMaskBits(0b01); + // part0.lock()->rigidBody->getCollider(0)->setCollisionCategoryBits(0b01); } // !!! REMINDER: This has to be called manually when parts are destroyed/removed from the workspace, or joints will linger diff --git a/core/src/objects/workspace.cpp b/core/src/objects/workspace.cpp index b9354df..0798ade 100644 --- a/core/src/objects/workspace.cpp +++ b/core/src/objects/workspace.cpp @@ -86,7 +86,7 @@ void Workspace::SyncPartPhysics(std::shared_ptr part) { part->rigidBody->setLinearVelocity(part->velocity); // part->rigidBody->setMass(density * part->size.x * part->size.y * part->size.z); - printf("Bits unset\n"); + // printf("Bits unset\n"); part->rigidBody->setUserData(&*part); }