The "position" result of sweep scene query's initial overlap.

Hi,

I am using sweep scene query to check an attack is whether hitted, and I want to display damage effect in the position of the contact point. It works well expect the case of initial overlap.

Using PxHitFlag::eMTD can generate the initial overlap hit, and the “position” result is a point on the sweep geometry object. But to display a damage effect I need the position of a point on the “hitted” geometry object(better be closest to the center of the sweep geometry object).

It can be sloved by an overlap query before the sweep query but I wonder if there is some better method to do it smarter.

Thanks for advise.

If you get the contact position on the surface of the sweep shape (e.g. the sphere), and you want the position on the mesh, you should be able to approximate this by taking the impact “point”, the reported “normal” and the “distance” and doing something like:

surfacePoint = point + normal * PxMin(distance, 0.f);

You may need a -normal rather than a +normal (I don’t recall which direction the normal points).

If the distance is negative, it means that the shapes are penetrated and this value is the penetration depth along the reported normal. You can correct the penetration by translating the swept shape from its initial configuration along the normal by distance.

If the distance is positive, it means that the shapes were separated and the distance defines how far along the sweep direction the shapes touch. In this case, the reported point should be on the surface of both shapes (within some small tolerance) so you don’t need to adjust the impact point.

Hope this helps.

Thanks kstorey !

I will try it and reply the result to you.

Hi kstorey,

I have checked the result of this case and I found that the default “point” is on the surface of the queried shape(not the sweep shape). So it is not need to do the caculation.
I must apologize for did not check the result before posting this topic, but the document of eMTD should be modified.