I have a shape and I'd like to remember its initial location by saving its vertex data to the fixture's userdata...
…but when I later go to retrieve the vertices array I can't seem to get the array back. i would think it would work something like the following…
…but i can't seem to get old_vertices to be what the fixtures original shape vertices were.
all guidance appreciated! (btw the xf transform is from code above the snippets i've pasted - i'm using the transformed vertices array for other stuff and it's all working great - just can't seem to save off and retrieve a vertex array via userdata)
i know i probably have to cast what i get back from getuserdata but my limited c++ skills are failing me - as have a couple hours on stackoverflow and trying just about every casting variation i could dream up. 😮
Code:
b2PolygonShape* poly = (b2PolygonShape*)fixture->GetShape();
int32 vertexCount = poly->GetVertexCount();
b2Vec2 vertices[b2_maxPolygonVertices];
for (int32 i = 0; i < vertexCount; ++i){
vertices[i] = b2Mul(xf, poly->GetVertex(i));
}
fixture->SetUserData(vertices);
int32 vertexCount = poly->GetVertexCount();
b2Vec2 vertices[b2_maxPolygonVertices];
for (int32 i = 0; i < vertexCount; ++i){
vertices[i] = b2Mul(xf, poly->GetVertex(i));
}
fixture->SetUserData(vertices);
…but when I later go to retrieve the vertices array I can't seem to get the array back. i would think it would work something like the following…
Code:
b2Vec2 old_vertices[b2_maxPolygonVertices];
old_vertices = fixture->GetUserData();
old_vertices = fixture->GetUserData();
…but i can't seem to get old_vertices to be what the fixtures original shape vertices were.
all guidance appreciated! (btw the xf transform is from code above the snippets i've pasted - i'm using the transformed vertices array for other stuff and it's all working great - just can't seem to save off and retrieve a vertex array via userdata)
i know i probably have to cast what i get back from getuserdata but my limited c++ skills are failing me - as have a couple hours on stackoverflow and trying just about every casting variation i could dream up. 😮