hkpAabbPhantom castRay wont accept hkpShapeRayCastInput

hkpAabbPhantom castRay wont accept hkpShapeRayCastInput

From the documentation (pg332,Notes On The Cast Ray Function)"We provide both an input hkpShapeRayCastInputstructure and a collector hkpShapeRayCastOutput structure."
I'm trying to limit the area that is raycasted.I'm using a hkpAabbPhantom to do this.Its constructed like this.hkAabb info; info.m_min = hkVector4( -mPhantomSide, -mPhantomSide, -mPhantomSide); info.m_max = hkVector4( mPhantomSide, mPhantomSide, mPhantomSide) ; mPhantomShape = new hkpAabbPhantom(info);I then calculate the ray, and try and call mPhantomShape->castRay(), only to be told there are no overloads for the arguments.It expects the worldInputs and outputs.mRay = mCameraSystem->GetCamera()->getCameraToViewportRay(mCrosshairX, mCrosshairY); direction = mRay.getDirection(); endItem = direction * mPickupRayDistance; hkpShapeRayCastInput input; input.m_from.setTransformedInversePos( mCharacterController->GetHavokCharacter()->getRigidBody()->getTransform(), UtilityFunctions::toHKVec(start)); input.m_to.setTransformedInversePos( mCharacterController->GetHavokCharacter()->getRigidBody()->getTransform(), UtilityFunctions::toHKVec(endItem)); hkpShapeRayCastOutput output; if(mItem == NULL) { mPhantomShape->castRay(input,output);I'm obviously doing something silly. What is it?

publicaciones de 6 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

NowmPhantomShape->getCollidable()->getShape()->castRay(input,output);does get me the method I want , but as I knew before I did it, hkpAabbPhantom returns NULL when queried for its shape. Leads me to the question, do I add a shape to it? Seems kinda weird to do that.

Best Reply

hkpAabbPhantom does not actually associate a shape with it's collidable (to prevent you from doing exactly that :P). You already set it up correctly with an hkAabb.
You want to use hkpWorldRayCastInput and hkpWorldRayCastOutput (or an hkpRayHitCollector) instead. This is because hkpAabbPhantom is generally a used to replace hkpWorld::rayCast() for frequent, short ray casts.Cheers,Tyler

Thanks, probably most users could see that. Add me to the "Found that passage in the documentation, confusing pile".

Final thing, how can I move the ray into the hkpAabb's local space when I can't callmPhantomShape->getCollidable()->getTransform()Theres a special exception to tell me thats a bad idea.

The ray should be in world space. Sorry if my previous wording was misleading (now edited to change "local" to "short").Cheers,Tyler

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya