From: Eunki Hong Date: Thu, 28 Oct 2021 07:11:27 +0000 (-0700) Subject: Exact planeclipping for actor's hit algorithm X-Git-Tag: dali_2.0.50~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=cc5f71114816e80ffb10841ad9dc13b2710d2b61 Exact planeclipping for actor's hit algorithm rayOriginLocal is difference vector betwwen the actor and the Camera(==rayOrigin). ActorTest API's distance value is the real euclidean distance between rayOrigin and actor. But we only need difference vector's z-axis value to clipping by View Space Plane. So we get hitPointWorld and multiply ViewMatrix (get from renderTask's camera actor) and get z-coordinate value at Camera Space. Change-Id: I644fc5e9b306423d6fa58f92e492a2a7508047a6 Signed-off-by: Eunki Hong --- diff --git a/dali/internal/event/events/hit-test-algorithm-impl.cpp b/dali/internal/event/events/hit-test-algorithm-impl.cpp index 1576efe..397f2c5 100644 --- a/dali/internal/event/events/hit-test-algorithm-impl.cpp +++ b/dali/internal/event/events/hit-test-algorithm-impl.cpp @@ -193,7 +193,13 @@ HitActor HitTestWithinLayer(Actor& actor, // Finally, perform a more accurate ray test to see if our ray actually hits the actor. if(rayTest.ActorTest(actor, rayOrigin, rayDir, hitPointLocal, distance)) { - if(distance >= nearClippingPlane && distance <= farClippingPlane) + // Calculate z coordinate value in Camera Space. + const Matrix& viewMatrix = renderTask.GetCameraActor()->GetViewMatrix(); + const Vector4& hitDir = Vector4(rayDir.x * distance, rayDir.y * distance, rayDir.z * distance, 0.0f); + const float cameraDepthDistance = (viewMatrix * hitDir).z; + + // Check if cameraDepthDistance is between clipping plane + if(cameraDepthDistance >= nearClippingPlane && cameraDepthDistance <= farClippingPlane) { // If the hit has happened on a clipping actor, then add this clipping depth to the mask of hit clipping depths. // This mask shows all the actors that have been hit at different clipping depths.