c++ - Class 2D vector problems -


alrighty. have class sphere. trying initialize coordinates uvsphere given number of subdivisions. class has 2d vector verts looks this:

std::vector<std::vector<angel::vec3>> verts; 

where vec3 struct of 3 floats

i have 2 functions

void setupsphere(); void setupraw(); 

whose implementation looks this:

void sphere::setupsphere() { float pi = std::atan(1.0f) * 4.0f; float subdivangle = 2 * pi / numsubdivide;  std::vector<angel::vec3> yvectors; yvectors.reserve(numsubdivide); (int = 0; < numsubdivide; ++) {     float curangle = subdivangle * i;     yvectors.push_back(angel::vec3(std::cos(curangle), 0.0, -std::sin(curangle))); }  int znumsubdivide = numsubdivide + 4; float zangle = 2 * pi / znumsubdivide;  (int = 1; < znumsubdivide / 2; ++) {     float curangle = pi / 2 - zangle * i;     float ycoord = std::sin(curangle);     float xzscale = std::cos(curangle);     std::vector<angel::vec3> curvector;      (int j = 0; j < numsubdivide; j ++)     {         angel::vec3 newpoint = yvectors[j] * xzscale;         newpoint.y = ycoord;         curvector.push_back(newpoint);     }     verts.push_back(curvector); }  std::cout << "size = " << verts.size() << std::endl; setupraw(); //setuptexture(); }  void sphere::setupraw() { std::cout << "testing" << std::endl; std::cout << "size = " << verts.size(); } 

when @ contents of verts @ end of setupsphere() looks great, in setupraw() crashes when try print size of verts. going on here?


Comments