c++ - Bullet Physics First Chance Exception When Creating New btConvexHullShape -
when create new btconvexhullshape first chance exception. code is:
btconvexhullshape* m_collisionshapes; m_collisionshapes = static_cast<btconvexhullshape*>(malloc(sizeof(btconvexhullshape)* max_body_count)); new (&m_collisionshapes[m_activebodycount]) btconvexhullshape();
i tried:
std::vector<btconvexhullshape> m_hulls; m_hulls.resize(max_body_count);
the exception occurs @ new
call , resize
call. exception is:
unhandled exception @ 0x0102c983 in useful_engine.exe: 0xc0000005: access violation reading location 0xffffffff.
and occurs inside of bullet source code at:
/**@brief return elementwise product of 2 vectors */ simd_force_inline btvector3 operator*(const btvector3& v1, const btvector3& v2) { #if defined(bt_use_sse_in_api) && defined (bt_use_sse) return btvector3(_mm_mul_ps(v1.mvec128, v2.mvec128)); #elif defined(bt_use_neon) return btvector3(vmulq_f32(v1.mvec128, v2.mvec128)); #else return btvector3( v1.m_floats[0] * v2.m_floats[0], v1.m_floats[1] * v2.m_floats[1], v1.m_floats[2] * v2.m_floats[2]); #endif }
is known problem ?
it looks memory alignment problem. keep in mind bullet data types aligned. bullet overrides "new" operators them. using malloc , vectors dangerous bullet types. instead of using vectors, should use btalignedobjectarray. if need allocate memory manually, can try use aligned allocation. memory allocation bullet uses btalignedalloc. or can create array in following way:
btalignedobjectarray<btconvexhullshape> m_hulls; m_hulls.resize(max_body_count);
Comments
Post a Comment