0 votes

I have a problem with Vector2 class in my custom C++ module. I'm trying to fill an array of PoolVector2Arrays with values. I init it with zeros and then I try to exchange the x and y values using operators [] and =:

std::array<PoolVector2Array, 6> arrs2d;
while (arrs2d.at(siz(BodyKeypoints::ALL)).size() < 33)
{
    Vector2 vi2 = {0, 0};
    arrs2d.at(siz(BodyKeypoints::ALL)).append(vi2);
    Vector3 vi3 = {0, 0, 0};
    arrs3d.at(siz(BodyKeypoints::ALL)).append(vi3);
}
while (arrs2d[siz(BodyKeypoints::ALL)].size() < 2)
{
    Vector2 iv(0.0, 0.0);
    arrs2d[siz(BodyKeypoints::ALL)].append(iv);
}
//td.keypoints == std::vector<std::vector<double>>
arrs2d[siz(BodyKeypoints::ALL)][i][0] = td.keypoints.at(i).at(0);
arrs2d[siz(BodyKeypoints::ALL)][i][1] = td.keypoints.at(i).at(1);
std::wostringstream strstr;
strstr << arrs2d[siz(BodyKeypoints::ALL)][i][0] << "/" << td.keypoints.at(i).at(0) << std::endl;
strstr << arrs2d[siz(BodyKeypoints::ALL)][i][1] << "/" << td.keypoints.at(i).at(1) << std::endl;
print_error(strstr.str().c_str());

The output is like this:

0/188.627
0/609.072

So the values are there as double but then they are not replacing the real_t values of Vector2 object. What am I missing?

Godot version 3.x
in Engine by (21 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.