From 22d6abef8b95c1ff301f657751c1f1882bca89fb Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 8 Mar 2009 15:07:56 +0000 Subject: fixes hud selection --- src/client/targets.cc | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'src/client/targets.cc') diff --git a/src/client/targets.cc b/src/client/targets.cc index 08c0e14..8a50510 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -361,35 +361,36 @@ void frame() if (entity->id() == current_target_id) { current_target = entity; + } - // check if the mouse is hovering the entity - Vector3f v(entity->location() - render::Camera::eye()); - v.normalize(); - - if (math::dotproduct(render::Camera::axis().forward(), v) > 0.75 ) { - - // calculate the distance from entity location to the line [eye - cursor] - float d = math::Vector3f::length(math::crossproduct( (cursor - render::Camera::eye()) , (render::Camera::eye() - entity->location()))) / math::Vector3f::length(cursor - render::Camera::eye()); - - float r = entity->radius() * 0.5f; - - if (ext_render(entity)->distance() > 512.0f) - math::clamp(r, 8.0f,r); - else if (ext_render(entity)->distance() > 256.0f) - math::clamp(r, 4.0f,r); - else if (ext_render(entity)->distance() > 128.0f) - math::clamp(r, 2.0f,r); + // check if the mouse is hovering the entity + Vector3f v(entity->location() - render::Camera::eye()); + v.normalize(); + + if (math::dotproduct(render::Camera::axis().forward(), v) > 0.75 ) { + + // calculate the distance from entity location to the line [eye - cursor] + float d = math::Vector3f::length(math::crossproduct( (cursor - render::Camera::eye()) , (render::Camera::eye() - entity->location()))) / math::Vector3f::length(cursor - render::Camera::eye()); - // if the cursor-beam hits the entity sphere - if (d < r) { - float myz = math::distance(cursor, entity->location()); - if (z < 0 || myz < z) { - current_hover = entity->id(); - z = myz; - } + float r = entity->radius() * 0.5f; + + if (ext_render(entity)->distance() > 512.0f) + math::clamp(r, 8.0f,r); + else if (ext_render(entity)->distance() > 256.0f) + math::clamp(r, 4.0f,r); + else if (ext_render(entity)->distance() > 128.0f) + math::clamp(r, 2.0f,r); + + // if the cursor-beam hits the entity sphere + if (d < r) { + float myz = math::distance(cursor, entity->location()); + if (z < 0 || myz < z) { + current_hover = entity->id(); + z = myz; } } } + } } -- cgit v1.2.3