read acces error on vector=...

Started by
4 comments, last by m4gnus 18 years, 1 month ago
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
"There are 10 types of people in the world... those who understand binary and those who don't."
Advertisement
You should prolly be obtaining a reference to the vector you are getting from the 2D array not a value copy.
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
"There are 10 types of people in the world... those who understand binary and those who don't."
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.



Stephen M. Webb
Professional Free Software Developer

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
"There are 10 types of people in the world... those who understand binary and those who don't."
*bump*

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

regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."

This topic is closed to new replies.

Advertisement