Miglioramento precisione rotazioni

This commit is contained in:
2026-05-31 12:47:46 +02:00
parent 57412060b5
commit 28abf04232
12 changed files with 29 additions and 50 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ class JointInterface{
public:
std::vector<rb::Vector3> offset;
std::vector<rb::Vector3_s> rotOffset;
std::vector<rb::Vector3> rotOffset;
PieceInterface* father;
std::vector<PieceInterface*> childs;
+2 -2
View File
@@ -5,9 +5,9 @@ class PivotJoint : public JointInterface {
void rotate(unsigned int id) override;
void traslate(unsigned int id) override;
rb::Vector3_s oldRot;
rb::Vector3 oldRot;
rb::Vector3 pivot;
std::vector<rb::Vector3_s> oldCRot;
std::vector<rb::Vector3> oldCRot;
//possono servire per calcolare l'offset rispetto alla posizione precedente
rb::Vector3 oldPos;
+5 -5
View File
@@ -3,9 +3,9 @@
#define ZERO_INT 0.00001
void PivotJoint::rotate(unsigned int id){
rb::Vector3_s fRot = father->body.getRot();
rb::Vector3 fRot = father->body.getRot();
rb::Vector3 fPos = father->body.getPos();
rb::Vector3_s cRot = childs[id]->body.getRot();
rb::Vector3 cRot = childs[id]->body.getRot();
//// sposto l'origine passivamente su tutti gli assi ////
@@ -75,7 +75,7 @@ PivotJoint::PivotJoint(PieceInterface* father,std::vector<PieceInterface*> child
this->childs = childs;
this->father = father;
rb::Vector3 fCoords = father->globalPos + father->body.getPos();
rb::Vector3_s fRot = father->body.getRot();
rb::Vector3 fRot = father->body.getRot();
pivot = pivotPoint;
rb::Vector3 pivotCenter = father->body.getPos() + pivot;
@@ -83,7 +83,7 @@ PivotJoint::PivotJoint(PieceInterface* father,std::vector<PieceInterface*> child
/*
float sign = pivot[2] >= 0 ? 1 : -1;
float r = sqrt(pow(pivot[0],2)+pow(pivot[2],2));
rotOffset.push_back( rb::Vector3_s{0,0,_Float16( acos(sign * pivot[0]/r) )} );
rotOffset.push_back( rb::Vector3{0,0,_Float16( acos(sign * pivot[0]/r) )} );
*/
@@ -97,7 +97,7 @@ PivotJoint::PivotJoint(PieceInterface* father,std::vector<PieceInterface*> child
/*
float r = sqrt(pow(tmpCoords[0],2)+pow(tmpCoords[2],2));
oldCRot.push_back( rb::Vector3_s{0,0,_Float16( acos(tmpCoords[0]/r) )} );
oldCRot.push_back( rb::Vector3{0,0,_Float16( acos(tmpCoords[0]/r) )} );
*/
oldCRot.push_back(c->body.getRot());
+4 -4
View File
@@ -5,8 +5,8 @@
//using namespace glm;
void RigidJoint::rotate(unsigned int id){
rb::Vector3_s fRot = father->body.getRot();
rb::Vector3_s fRotOld = childs[id]->body.getRot() - rotOffset[id];
rb::Vector3 fRot = father->body.getRot();
rb::Vector3 fRotOld = childs[id]->body.getRot() - rotOffset[id];
rb::Vector3 fPos = father->body.getPos();
rb::Vector3 cPos = childs[id]->body.getPos();
@@ -65,7 +65,7 @@ RigidJoint::RigidJoint(PieceInterface* father,std::vector<PieceInterface*> child
this->childs = childs;
this->father = father;
rb::Vector3 fCoords = father->globalPos + father->body.getPos();
rb::Vector3_s fRot = father->body.getRot();
rb::Vector3 fRot = father->body.getRot();
@@ -73,7 +73,7 @@ RigidJoint::RigidJoint(PieceInterface* father,std::vector<PieceInterface*> child
//mi calcolo l'offset per ogni child rispetto al padre
for(PieceInterface* c : childs){
rb::Vector3 tmpCoords;
rb::Vector3_s tmpRot;
rb::Vector3 tmpRot;
rb::Vector3 cCoords = c->globalPos + c->body.getPos();