Sign in to follow this  
m4gnus

read acces error on vector=...

Recommended Posts

m4gnus    240
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> >[i]) 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
m4gnus    240
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[i];
std::vector<ngTriangle> adjFaces=adjInfo.getAdjacentFaces(Indices[i]);
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[i].x=avgNormal.x;
vertexnormals[i].y=avgNormal.y;
vertexnormals[i].z=avgNormal.z;
} //User Breakpoint error?! wtf?


}



regards,
m4gnus

Share this post


Link to post
Share on other sites
Bregma    9214
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
m4gnus    240
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this