{
bool IsActorHittable(Actor* actor) override
{
- return actor->GetTouchRequired() && // Does the Application or derived actor type require a touch event?
- actor->IsHittable(); // Is actor sensitive, visible and on the scene?
+ return (actor->GetTouchRequired() || actor->GetInterceptTouchRequired() || actor->IsTouchFocusable()) && // Does the Application or derived actor type require a touch event or a intercept touch event? or focusable by touch?
+ actor->IsHittable(); // Is actor sensitive, visible and on the scene?
}
bool DescendActorHierarchy(Actor* actor) override
// 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.
clippingBitPlaneMask,
rayTest));
+ // Make sure the set hit actor is actually hittable. This is usually required when we have some
+ // clipping as we need to hit-test all actors as we descend the tree regardless of whether they
+ // are hittable or not.
+ if(currentHit.actor && !hitCheck.IsActorHittable(currentHit.actor))
+ {
+ continue;
+ }
+
bool updateChildHit = false;
if(currentHit.distance >= 0.0f)
{