diff --git a/build/bin/mainV4 b/build/bin/mainV4 index ebbeafb..a9c625f 100755 Binary files a/build/bin/mainV4 and b/build/bin/mainV4 differ diff --git a/src/joints/headers/joint_interface.hpp b/src/joints/headers/joint_interface.hpp index 54d90cd..8bf0718 100644 --- a/src/joints/headers/joint_interface.hpp +++ b/src/joints/headers/joint_interface.hpp @@ -21,7 +21,7 @@ class JointInterface{ public: std::vector offset; - std::vector rotOffset; + std::vector rotOffset; PieceInterface* father; std::vector childs; diff --git a/src/joints/headers/pivot_joint.hpp b/src/joints/headers/pivot_joint.hpp index 31e0707..4a202a2 100644 --- a/src/joints/headers/pivot_joint.hpp +++ b/src/joints/headers/pivot_joint.hpp @@ -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 oldCRot; + std::vector oldCRot; //possono servire per calcolare l'offset rispetto alla posizione precedente rb::Vector3 oldPos; diff --git a/src/joints/methods/pivot_joint_class.cpp b/src/joints/methods/pivot_joint_class.cpp index 077b4dd..209bb97 100644 --- a/src/joints/methods/pivot_joint_class.cpp +++ b/src/joints/methods/pivot_joint_class.cpp @@ -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 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 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 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()); diff --git a/src/joints/methods/rigid_joint_class.cpp b/src/joints/methods/rigid_joint_class.cpp index fb09a74..60f0f98 100644 --- a/src/joints/methods/rigid_joint_class.cpp +++ b/src/joints/methods/rigid_joint_class.cpp @@ -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 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 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(); diff --git a/src/pieces/methods/caviglia_class.cpp b/src/pieces/methods/caviglia_class.cpp index 0818c5e..b7cc4c8 100644 --- a/src/pieces/methods/caviglia_class.cpp +++ b/src/pieces/methods/caviglia_class.cpp @@ -22,7 +22,7 @@ void Caviglia::update(sf::Clock cl){ sf::Shape* Caviglia::draw(ReferencePlane plane){ rb::Vector3 tmpPos = body.getPos(); - rb::Vector3_s tmpRot = body.getRot(); + rb::Vector3 tmpRot = body.getRot(); switch (plane) { diff --git a/src/pieces/methods/coscia_class.cpp b/src/pieces/methods/coscia_class.cpp index 14f5ffa..4684921 100644 --- a/src/pieces/methods/coscia_class.cpp +++ b/src/pieces/methods/coscia_class.cpp @@ -20,7 +20,7 @@ void Coscia::update(sf::Clock cl){ sf::Shape* Coscia::draw(ReferencePlane plane){ rb::Vector3 tmpPos = body.getPos(); - rb::Vector3_s tmpRot = body.getRot(); + rb::Vector3 tmpRot = body.getRot(); switch (plane) diff --git a/src/pieces/methods/sensore_class.cpp b/src/pieces/methods/sensore_class.cpp index aa16df0..c223161 100644 --- a/src/pieces/methods/sensore_class.cpp +++ b/src/pieces/methods/sensore_class.cpp @@ -61,7 +61,7 @@ void Sensore::update(sf::Clock cl){ sf::Shape* Sensore::draw(ReferencePlane plane){ - rb::Vector3_s tmpRot = body.getRot(); + rb::Vector3 tmpRot = body.getRot(); rb::Vector3 tmpPos = body.getPos(); switch (plane) @@ -105,7 +105,7 @@ void Sensore::calcRotWithG(unsigned int index){ // calcolo rotazione con valori float tmpAY = acos(tmpSinY); float tmpAZ = acos(tmpSinZ); - body.setRot(rb::Vector3_s{_Float16( tmpAY),_Float16( tmpAX),_Float16( tmpAZ) }); + body.setRot(rb::Vector3{tmpAY, tmpAX, tmpAZ }); } /* diff --git a/src/pieces/methods/torso.cpp b/src/pieces/methods/torso.cpp index ec82add..b2074b9 100644 --- a/src/pieces/methods/torso.cpp +++ b/src/pieces/methods/torso.cpp @@ -20,7 +20,7 @@ void Torso::update(sf::Clock cl){ sf::Shape* Torso::draw(ReferencePlane plane){ - rb::Vector3_s tmpRot = body.getRot(); + rb::Vector3 tmpRot = body.getRot(); rb::Vector3 tmpPos = body.getPos(); diff --git a/src/rigidbody/headers/rb.hpp b/src/rigidbody/headers/rb.hpp index 93c51ad..9e7b315 100644 --- a/src/rigidbody/headers/rb.hpp +++ b/src/rigidbody/headers/rb.hpp @@ -7,14 +7,14 @@ namespace rb{ typedef std::vector Vector3; - typedef std::vector<_Float16> Vector3_s; + //typedef std::vector<_Float16> Vector3; class rigidbody { private: Vector3 vel = {0,0,0}; Vector3 acc = {0,0,0}; - Vector3_s rot = {0,0,0}; + Vector3 rot = {0,0,0}; Vector3 tanAcc = {0,0,0}; _Float16 mass = 1; @@ -40,9 +40,9 @@ Vector3 getPos(); - Vector3_s getRot(); + Vector3 getRot(); void setPos(const Vector3 Npos); - void setRot(const Vector3_s Nrot); + void setRot(const Vector3 Nrot); void setVel(const Vector3 Nacc); void setAcc(const Vector3 Nvel); void step(const sf::Clock time); @@ -76,30 +76,9 @@ v1[2] - v2[2] }; } - - inline rb::Vector3_s operator+(const rb::Vector3_s& v1, const rb::Vector3_s& v2) { - if (v1.size() != 3 || v2.size() != 3) { - throw std::invalid_argument("I vettori devono avere esattamente 3 elementi."); - } - return rb::Vector3_s{ - v1[0] + v2[0], - v1[1] + v2[1], - v1[2] + v2[2] - }; - } - - inline rb::Vector3_s operator-(const rb::Vector3_s& v1, const rb::Vector3_s& v2) { - if (v1.size() != 3 || v2.size() != 3) { - throw std::invalid_argument("I vettori devono avere esattamente 3 elementi."); - } - return rb::Vector3_s{ - v1[0] - v2[0], - v1[1] - v2[1], - v1[2] - v2[2] - }; - } + /* - inline bool operator!=(const rb::Vector3_s& v1, const rb::Vector3_s& v2) { + inline bool operator!=(const rb::Vector3& v1, const rb::Vector3& v2) { if (v1.size() != 3 || v2.size() != 3) { throw std::invalid_argument("I vettori devono avere esattamente 3 elementi."); } diff --git a/src/rigidbody/methods/rb_class.cpp b/src/rigidbody/methods/rb_class.cpp index a88ff08..21382f8 100755 --- a/src/rigidbody/methods/rb_class.cpp +++ b/src/rigidbody/methods/rb_class.cpp @@ -21,8 +21,8 @@ rigidbody::~rigidbody() Vector3 rigidbody::getPos(){ return Vector3 {coords}; } -Vector3_s rigidbody::getRot(){ - return Vector3_s {rot}; +Vector3 rigidbody::getRot(){ + return Vector3 {rot}; } void rigidbody::setPos(Vector3 Npos){ @@ -47,7 +47,7 @@ void rigidbody::setAcc(const Vector3 Nacc){ } -void rigidbody::setRot(const Vector3_s Nrot){ +void rigidbody::setRot(const Vector3 Nrot){ if (Nrot.size() != 3) throw "Vel vector must be 3 in lenght!"; int i = 0; diff --git a/src/sfml_util.cpp b/src/sfml_util.cpp index e40a525..c0c74db 100644 --- a/src/sfml_util.cpp +++ b/src/sfml_util.cpp @@ -112,10 +112,10 @@ void handle(const sf::Event::MouseMoved &mouseMoved, State &gs) gs.pieces[gs.selected]->body.setPos({tmp[0]+ (offset.x * px),tmp[1]+ (offset.x * py),tmp[2]+offset.y}); } if (gs.selected != -1 && gs.rot_Piece){ - rb::Vector3_s tmp = gs.pieces[gs.selected]->body.getRot(); + rb::Vector3 tmp = gs.pieces[gs.selected]->body.getRot(); - _Float16 nrot = _Float16(offset.x)/100; - gs.pieces[gs.selected]->body.setRot({tmp[0]+(nrot*_Float16(py)),tmp[1]+(nrot*_Float16(px)),tmp[2]}); + float nrot = float(offset.x)/100; + gs.pieces[gs.selected]->body.setRot({tmp[0]+(nrot*py),tmp[1]+(nrot*px),tmp[2]}); //printf("Rotation : %f,%f,%f \n",gs.pieces[gs.selected]->body.getRot()[0],gs.pieces[gs.selected]->body.getRot()[1],gs.pieces[gs.selected]->body.getRot()[2]); }