somebody help me? about havok RayCast

somebody help me? about havok RayCast

Can I use hkpWorldRayCaster for finding visible objects  in the outdoor scene? if do, it will raycast many rays form the viewpoint, such as 32 *32 rays ,for better accurate result. Will this affect the efficiency of program execution?   Thanks for advance!

I'm sorry for my poor English.

 

6 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Hi Cunqi,

I think hkpWorldRayCaster::castRaysFromSinglePoint(...) is what you are looking for. See Demo/Demos/Physics/Api/Collide/RayCasting/OptimizedWorldRaycast for an example of how to use it (as well as some other options for raycatsing multiple rays).

More raycasts means more work for the program. For small numbers of raycasts you won't notice the difference but as the number gets larger the program will slow down. Havok uses some optimisations for the different options in the OptimizedWorldRaycastDemo which may allow you to use 32x32 raycasts. However 32x32 is alot of raycasts and without any optimisations will be very slow so you should try some of the options from the OptimizedWorldRaycastDemo in your own program to see if it is fast enough for you, if it is too slow you will need to use a smaller number of rays.

Amy

Amy Developer Support Engineer Havok www.havok.com

Thanks Havok_Amy for your explanation.
I have made an experiment using hkpWorldRayCaster::castRaysFromSinglePoint(...), for 32x32 rays int the scene.  The outdoor scene contains a big terrain mesh and many scene addornings. It takes about 0.008s, not very fast for me. Beacuse it takes total frame time about half time(the frame takes about 0.0149s). Next, I also test 16x16 rays. The result that it takes about 0.002s is acceptive for me. But This result may be not accurate. I can use frame coherency to get all visible Objects. 
So, now the question is that I want to know how does Havok do about raycasting? I didn't find some theories about this on the Use Guide. could you give me some hints or airticles about raycasting in havok system? Thanks in advance.

Hi Cunqi,

Havok will first raycast against the AABB of all objects in the scene, then only the objects whose AABBs were hit are tested further.
If the object has a bounding volume tree it will raycast through the tree until it reaches a leave node. Eventually this process comes down to raycasting against a single simple shape, e.g. sphere, triangle. Some of the options in the OptimizedWorldRaycastDemo also use a smaller set of AABBs in a hkpBroadPhaseAabbCache instead of the entire scene to reduce the number of initial tests to do. Hopefully this answers your question.

Amy Developer Support Engineer Havok www.havok.com

朋友是中国人么?

Thanks Havok_Amy again. This is very helpful for me.

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen