# Havok Physics : "hkQuaternionf not normalized/invalid!" when hkpWorld::stepMultithreaded()

My havok version is 2014.1.0-r1 (x86 SIMD version), and I'm using Visual Studio 2012 on Windows 8.

My problem is, that once I add a rigid body to the world, the next time I call hkpWorld::stepMultithreaded(), it breaks in some SSE math related function and gives me this error message through my error report function.

C:\NightlyJobs\09-07-Sun-01\Source\Common/Base/Math/Vector/Sse/hkSseVector4Util. inl(307): [0x1FF88F0E] Assert: hkQuaternionf not normalized/invalid!

Here's the stack trace:

(null)(0):'hkDefaultError::message'
(null)(0):'hkError::messageAssert'
(null)(0):'hkVector4UtilImpl::convertQuaternionToRotation'
(null)(0):'hkRotationf::set'
(null)(0):'hkTransformf::setRotation'
(null)(0):'hkSweptTransformUtil::calcTransAtT1'
(null)(0):'hkSweptTransformUtil::_stepMotionState'
(null)(0):'hkRigidMotionUtilApplyForcesAndStep'
(null)(0):'integrateJob'
(null)(0):'hkJobQueue::processAllJobs'

Here's how I create and add the rigid body.
It's so basic that I didn't think there would be any room for bizarre error in it...

hkpSphereShape* sphere = new hkpSphereShape(radius);  // radius is 10.0f here.

hkpRigidBodyCinfo rigidBodyInfo;
rigidBodyInfo.m_shape = sphere;

m_RigidBody = new hkpRigidBody(rigidBodyInfo);

world->markForWrite();
world->unmarkForWrite();
m_RigidBody->removeReference();


I don't set position or rotation of the rigid body myself, so why it breaks in some quaternion related function is beyond me.

I speculated it might be one of those multithreading-related bizarre errors, so I tried changing

m_WorldInfo.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_MULTITHREADED;


to

m_WorldInfo.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_DISCRETE;


and

m_World->stepMultithreaded(m_JobQueue, m_CpuThreadPool, timeStep);


to

m_World->stepDeltaTime(timeStep);


but the problem persisted.

Do you know something that I could be doing wrong ?
Please tell me in the comments if you need to see some of my other code to help!
Any help would be greatly appreciated, thanks!

• I changed my havok to non-SIMD version, and the problem is gone. I tried 16-byte aligned allocations of hkpSphereShape and hkpRigidBody too (instead of just new), so I don't really understand the problem. Aug 9 '15 at 22:08

It appears that if you're using the SIMD-enabled version of havok, you need to define HK_CONFIG_SIMD=1.
Whichever version of havok you're using, if you encounter SSE-related crashes or errors, make sure you're not accidentally defining or not defining HK_CONFIG_SIMD in your code or in the project settings in your IDE.