From 926c64c69101cf5a17837c7e5f559e15ee7fba43 Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Thu, 30 Mar 2023 17:54:33 +0200 Subject: [PATCH] Add angle check for triggers touched by hand --- Projects/Android/jni/OpenJK/code/game/g_active.cpp | 8 ++++++++ Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Projects/Android/jni/OpenJK/code/game/g_active.cpp b/Projects/Android/jni/OpenJK/code/game/g_active.cpp index b12c66e..c8b650f 100644 --- a/Projects/Android/jni/OpenJK/code/game/g_active.cpp +++ b/Projects/Android/jni/OpenJK/code/game/g_active.cpp @@ -1385,6 +1385,14 @@ void G_TouchTriggersWithHand( gentity_t *ent, vec3_t src, vec3_t vf ) { continue; } + // In case touching button-like entity via use gesture, check activation angle here. + // Existing check in g_trigger.cpp Touch_Multi is problematic because we do not have + // there information by which hand was entity triggered. + if ( DotProduct( hit->movedir, vf ) < 0.5 ) { + //Not Within 45 degrees + continue; + } + touched[i] = qtrue; memset( &trace, 0, sizeof(trace) ); if ( hit->e_TouchFunc != touchF_NULL ) { diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp index 5e37f43..afd6f9b 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/g_active.cpp @@ -856,6 +856,14 @@ void G_TouchTriggersWithHand( gentity_t *ent, vec3_t src, vec3_t vf ) { continue; } + // In case touching button-like entity via use gesture, check activation angle here. + // Existing check in g_trigger.cpp Touch_Multi is problematic because we do not have + // there information by which hand was entity triggered. + if ( DotProduct( hit->movedir, vf ) < 0.5 ) { + //Not Within 45 degrees + continue; + } + touched[i] = qtrue; memset( &trace, 0, sizeof(trace) ); if ( hit->e_TouchFunc != touchF_NULL ) {