简体   繁体   中英

C++ | Exception thrown...Access violation reading location ERROR

I'm trying to implement Newton physics inside of a little project I'm working on. I wrote a parser to implement it inside of Half-Life 1.

When I try to use it in a map, it throws an Access violation error. Its' location is 0xFFFFFFF0.

When I tried to use Debug in Visual Studio 2015 it pointed me to here.

bmodels[ modelNum ] =   NewtonCreateConvexHull( m_pWorld, numVerts, ( float* )&verts[ 0 ][ 0 ], 12, NULL );

So I'm at a loss. The full function can be found here on http://pastebin.com/W6NAs2hM .

Based on a really quick at your code and based off the error you described it looks like you are accessing your array out of bounds.

You start your initial for loop with an index of 1 , ie, modelNum = 1

for( int modelNum = 1; modelNum < m_iNumModels; modelNum++ )

and then in the line

bmodels[ modelNum ] =   NewtonCreateConvexHull( m_pWorld, numVerts, ( float* )&verts[ 0 ][ 0 ], 12, NULL ); 

you try to access bmodels[1] , but really it should be bmodels[0] since 0 is always the first index of an array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM