Jump to content
  • Advertisement
Sign in to follow this  
m4gnus

read acces error on vector=...

This topic is 4487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a simple line of code but i keep on getting read acces errors there and i have no clue why. I have a vector of a vector(vector< vector <int> >) and want to get one of those int-vectors seperated(vector<int>=vector< vector <int> >) and that's exactly where the error happens. the code: std::vector<int> adjFaces=adjacentFaces[vertexindex]; //read acces violation! this line is in a loop and the error occurs when vertexindex is 260, the line worked without an error for other indices. adjacentFaces is ca 1500 elements large. regards, m4gnus

Share this post


Link to post
Share on other sites
Advertisement
You should prolly be obtaining a reference to the vector you are getting from the 2D array not a value copy.

Share this post


Link to post
Share on other sites
ok that error is fixed but now get a user breakpoint error on a line that just contains a "}".
Where could that come from?

The call stack:

nGin.exe!_CrtIsValidHeapPointer(const void * pUserData=0x093d5260) Line 1807 C
nGin.exe!_free_dbg(void * pUserData=0x093d5260, int nBlockUse=1) Line 1132 + 0x9 C
nGin.exe!operator delete(void * pUserData=0x093d5260) Line 54 + 0x10 C++
nGin.exe!std::allocator<ngTriangle>::deallocate(ngTriangle * _Ptr=0x093d5260, unsigned int __formal=4) Line 132 + 0x9 C++
nGin.exe!std::vector<ngTriangle,std::allocator<ngTriangle> >::_Tidy() Line 797 C++
nGin.exe!std::vector<ngTriangle,std::allocator<ngTriangle> >::~vector<ngTriangle,std::allocator<ngTriangle> >() Line 389 C++
> nGin.exe!ngMesh::calculateNormals() Line 397 + 0x1b C++
nGin.exe!ngMesh::createBuffers() Line 348 C++
nGin.exe!ngMesh::loadMesh(ngEngine * engine=0x004788a8, char * filename=0x004683e0) Line 126 C++
nGin.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00132cb8, int nCmdShow=1) Line 100 C++
nGin.exe!WinMainCRTStartup() Line 251 + 0x30 C



calculateNormals is the function in which the compiler says the error occured on "}"

the calclulateNormals function:

void ngMesh::calculateNormals()
{
//ok the follwing function is not really the perfect way of getting vertexnormals(does it all multiple times per vertex) but at least it (should) work(s)

int sz=Indices.size();
vertexnormals.resize(Verts.size());
for(int i=0;i<Indices.size();i++)
{
short index=Indices;
std::vector<ngTriangle> adjFaces=adjInfo.getAdjacentFaces(Indices);
ngVector3 avgNormal(0.0f,0.0f,0.0f);
for(int j=0;j<adjFaces.size();j++)
{
avgNormal=avgNormal+adjFaces[j].getNormal();

}
int size=adjFaces.size();
avgNormal=avgNormal/size;
vertexnormals.x=avgNormal.x;
vertexnormals.y=avgNormal.y;
vertexnormals.z=avgNormal.z;
} //User Breakpoint error?! wtf?


}



regards,
m4gnus

Share this post


Link to post
Share on other sites
Quote:
Original post by m4gnus
ok that error is fixed but now get a user breakpoint error on a line that just contains a "}".
Where could that come from?


Usually from the destructor of a local variable of automatic storage duration.



Share this post


Link to post
Share on other sites
Quote:

Usually from the destructor of a local variable of automatic storage duration.


a variable of automatic storage duration?
does that mean a variable which is automatically deleted after needed?
and why is there an error? where's the problem with that?



regards,
m4gnus

Share this post


Link to post
Share on other sites
*bump*

c'mon somebody surely knows something about my last questions.
plz help

regards,
m4gnus

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!