feat(input): capturing handler's distance is halved
This commit is contained in:
@@ -170,10 +170,16 @@ impl InputMethod {
|
|||||||
.add(self as *const InputMethod as usize, &method_alias);
|
.add(self as *const InputMethod as usize, &method_alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compare_distance(&self, to: &Field) -> f32 {
|
fn compare_distance(&self, to: &InputHandler) -> f32 {
|
||||||
self.specialization
|
let distance = self
|
||||||
|
.specialization
|
||||||
.lock()
|
.lock()
|
||||||
.compare_distance(&self.spatial, to)
|
.compare_distance(&self.spatial, &to.field);
|
||||||
|
if self.captures.contains(to) {
|
||||||
|
distance * 0.5
|
||||||
|
} else {
|
||||||
|
distance
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn true_distance(&self, to: &Field) -> f32 {
|
fn true_distance(&self, to: &Field) -> f32 {
|
||||||
self.specialization.lock().true_distance(&self.spatial, to)
|
self.specialization.lock().true_distance(&self.spatial, to)
|
||||||
@@ -253,7 +259,7 @@ pub struct DistanceLink {
|
|||||||
impl DistanceLink {
|
impl DistanceLink {
|
||||||
fn from(method: Arc<InputMethod>, handler: Arc<InputHandler>) -> Self {
|
fn from(method: Arc<InputMethod>, handler: Arc<InputHandler>) -> Self {
|
||||||
DistanceLink {
|
DistanceLink {
|
||||||
distance: method.compare_distance(&handler.field),
|
distance: method.compare_distance(&handler),
|
||||||
method,
|
method,
|
||||||
handler,
|
handler,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user