Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Adding RigidBody to Physics Engine

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 Medo3337   Members   

891
Like
0Likes
Like

Posted 04 July 2012 - 07:31 AM

I am trying to use the following code to add RigidBody to Havok Physics, but I am getting 'Access violation reading location' error:
First-chance exception at 0x016141b6 in DirectX Level.exe: 0xC0000005: Access violation reading location 0x0000002c.

File: hkThreadLocalData.h

I need someone to update the following code to make it work:
static void HK_CALL errorReport(const char* msg, void* userContext)
{
     using namespace std;
     printf("%s", msg);
}

HavokManager::HavokManager()
{
     hkMallocAllocator baseMalloc;
     // Need to have memory allocated for the solver. Allocate 1mb for it.
     memoryRouter = hkMemoryInitUtil::initDefault(
     &baseMalloc, hkMemorySystem::FrameInfo(1024 * 1024) );
hkBaseSystem::init( memoryRouter, errorReport );
     {
          // object for custom information about the world
          hkpWorldCinfo info;

          // e.g. set manually the gravity (try to tune this parameter!)
          info.m_gravity.set( 0,-9.8f,0);

          // use default information (try to use our "info" object)
          m_world = new hkpWorld( hkpWorldCinfo() );

          // Register all collision agents (before adding entities, try doing the opposite!)
          hkpAgentRegisterUtil::registerAllAgents( m_world->getCollisionDispatcher() );
     }
}

void HavokManager::AddEntity(ENTITY *entity)
{
D3DXVECTOR4 dimensions(50.0f, 50.0f, 50.0f, 0.0f);
D3DXVECTOR4 pos(0.0f, 0.0f, 0.0f, 0.0f);

hkVector4 hDim(dimensions.x/2,
  dimensions.y/2,
  dimensions.z/2,
  dimensions.w);

hkVector4 hPos(pos.x,
  pos.y,
  pos.z,
  pos.w);

hkpConvexShape* shape = new hkpBoxShape(hDim, 0);

hkpRigidBodyCinfo rigidBodyInfo;

rigidBodyInfo.m_motionType = hkpMotion::MOTION_FIXED;
rigidBodyInfo.m_shape      = shape;
rigidBodyInfo.m_position   = hPos;
rigidBodyInfo.m_allowedPenetrationDepth = 0;

hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);

m_world->lock();
m_world->addEntity(rigidBody);

rigidBody->removeReference();
shape->removeReference();

m_world->unlock();
}


#2 Hodgman   Moderators   

50610
Like
0Likes
Like

Posted 04 July 2012 - 07:42 AM

I am trying to use the following code to add RigidBody to Havok Physics, but I am getting 'Access violation reading location' error:
First-chance exception at 0x016141b6 in DirectX Level.exe: 0xC0000005: Access violation reading location 0x0000002c.

This usually means that you've tried to use a NULL pointer, which is a general C++ coding error unrelated to any API. Your debugger should stop on the specific line of code which was using this pointer, at which point, you can inspect the values of your variables to see which pointer is invalid. Which line does it stop on?

Edited by Hodgman, 04 July 2012 - 07:43 AM.


#3 Medo3337   Members   

891
Like
0Likes
Like

Posted 04 July 2012 - 08:46 AM

The problem occur when the following line get executed:
hkpSphereShape *sphereShape = new hkpSphereShape(100.0f);





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.