applyLinearImpulse crash

applyLinearImpulse crash


I want to make a simple controler for my game but I encountered strange behaviour.I want to apply linear impulse to my object read from file with use of hkpConvexVerticesShape. Before I will explain what's happening here's the code:

creation of hkpConvexVerticesShape:

hkpConvexVerticesShape* HavokCore::CreatehConvexVerticeShape(hkReal *vertices, int numVerts)
    hkpConvexVerticesShape::BuildConfig config;
    config.m_convexRadius = 0.01f;
    hkStridedVertices stridedVerts;
        stridedVerts.m_numVertices = numVerts;
        stridedVerts.m_striding = sizeof(hkReal)*3;
        stridedVerts.m_vertices = vertices;
    hkpConvexVerticesShape* shape = new hkpConvexVerticesShape(stridedVerts, config);
    return shape;

Initialization code:

    hkpConvexVerticesShape *s = HavokCore::CreatehConvexVerticeShape(ball->getVertices(), ball->getVertCount());
    pBall = HavokCore::CreateRigidBody(s);
    hkQuaternion rotationHavok;
    rotationHavok.setAxisAngle( hkVector4(0.0, 1.0, 0.0), -90 * ( 3.1415f / 180.0f ) );
//later in the update loop:

Ok, so the problem is: When I don't use apply linear impulse (or point impulse, force, etc.), everything works fine. But when I have apply linear impulse in my code, costructor of hkpConvexVerticesShape throws exception "Invalid faces count". Any ideas what could be wrong?

I also lock and unclock the world, I remove reference from shape after creation of rigid body.

5 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Hi Adam--

Do you get any sort of call stack when running this in debug? Also, can you try padding your vertices to be a 4-wide? Try adding a zero after every three values and change the striding:

stridedVerts.m_striding = sizeof(hkReal)*4;



Hi Tim,

I tried that and error still occurs. I tried looking for mistakes in my code, tried to use different types of shapes, It's always crashing. I found a workaround that works, i am doing it like that:


Well, the funny thing is that when I use applyLinearImpulse on hkpRigidBody created using shape hkpSphereShape, when I look at stack trace it points to hkpConvexVerticesShape constructor - why this is happening is beyond me. If the method I use right now is ok I can live with that.

Hi Adam--

It's not clear to me what you're seeing in the stack, but the code you provided does construct hkpConvexVerticesShapes, not an hkpSphereShape.

Applying an impulse should work, and the fact it's not may indicate a problem that will become a problem down the road. Can you please provide the callstack at the time of your exception, and any messages written to the log? Thanks!


Sorry, wong thread

Amy Developer Support Engineer Havok

Accedere per lasciare un commento.