Use index references

This commit is contained in:
Pascal Serrarens 2024-04-19 14:43:33 +02:00
parent 6dea063a4a
commit f6a38aaa04
2 changed files with 15 additions and 11 deletions

View File

@ -9,11 +9,14 @@
#include "LinearAlgebra/Angle8.h" #include "LinearAlgebra/Angle8.h"
#include "LinearAlgebra/Spherical.h" #include "LinearAlgebra/Spherical.h"
void NetworkSync::SendVector3(unsigned char *data, unsigned int startIndex, void NetworkSync::SendVector3(unsigned char *data, unsigned char *startIndex,
const Vector3 v) { const Vector3 v) {
SendSingle100(data, startIndex, v.x); SendSingle100(data, *startIndex, v.x);
SendSingle100(data, startIndex += 4, v.y); (*startIndex) += 4;
SendSingle100(data, startIndex += 4, v.z); SendSingle100(data, *startIndex, v.y);
(*startIndex) += 4;
SendSingle100(data, *startIndex, v.z);
(*startIndex) += 4;
} }
void NetworkSync::SendQuaternion(unsigned char *data, const int startIndex, void NetworkSync::SendQuaternion(unsigned char *data, const int startIndex,
@ -52,7 +55,7 @@ void NetworkSync::SendSpherical(unsigned char *data, int startIndex,
// SendSingle100(data, startIndex += 4, s.distance); // SendSingle100(data, startIndex += 4, s.distance);
// } // }
void NetworkSync::SendQuat32(unsigned char *data, int startIndex, void NetworkSync::SendQuat32(unsigned char *data, unsigned char *startIndex,
const Quaternion q) { const Quaternion q) {
unsigned char qx = (char)(q.x * 127 + 128); unsigned char qx = (char)(q.x * 127 + 128);
unsigned char qy = (char)(q.y * 127 + 128); unsigned char qy = (char)(q.y * 127 + 128);
@ -65,10 +68,10 @@ void NetworkSync::SendQuat32(unsigned char *data, int startIndex,
qw = -qw; qw = -qw;
} }
// Serial.printf(" (%d) %d:%d:%d:%d ", startIndex, qx, qy, qz, qw); // Serial.printf(" (%d) %d:%d:%d:%d ", startIndex, qx, qy, qz, qw);
data[startIndex++] = qx; data[(*startIndex)++] = qx;
data[startIndex++] = qy; data[(*startIndex)++] = qy;
data[startIndex++] = qz; data[(*startIndex)++] = qz;
data[startIndex++] = qw; data[(*startIndex)++] = qw;
} }
void NetworkSync::SendAngle8(unsigned char *data, unsigned int startIndex, void NetworkSync::SendAngle8(unsigned char *data, unsigned int startIndex,

View File

@ -62,7 +62,7 @@ protected:
// const float value); // const float value);
// void SendAngle32(unsigned char *data, unsigned int startIndex, // void SendAngle32(unsigned char *data, unsigned int startIndex,
// const float value); // const float value);
void SendVector3(unsigned char *data, unsigned int startIndex, void SendVector3(unsigned char *data, unsigned char *startIndex,
const Vector3 v); const Vector3 v);
void SendQuaternion(unsigned char *data, const int startIndex, void SendQuaternion(unsigned char *data, const int startIndex,
const Quaternion q); const Quaternion q);
@ -71,7 +71,8 @@ protected:
void SendSpherical(unsigned char *data, int startIndex, Spherical s); void SendSpherical(unsigned char *data, int startIndex, Spherical s);
// void SendSpherical16(unsigned char *data, int startIndex, Spherical s); // void SendSpherical16(unsigned char *data, int startIndex, Spherical s);
// void SendSpherical32(unsigned char *data, int startIndex, Spherical s); // void SendSpherical32(unsigned char *data, int startIndex, Spherical s);
void SendQuat32(unsigned char *data, int startIndex, const Quaternion q); void SendQuat32(unsigned char *data, unsigned char *startIndex,
const Quaternion q);
}; };
} // namespace RoboidControl } // namespace RoboidControl