From c59fc7a85bf78ef249159b960e2ca29c8f0271ff Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 6 Jan 2013 21:48:03 +0000 Subject: Set aiming distance to the entity currently hovering with the mouse. --- src/client/targets.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/client/targets.cc') diff --git a/src/client/targets.cc b/src/client/targets.cc index 5ec1abe..fcd7dc6 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -475,6 +475,8 @@ void frame() cursor_aim.assign(render::Camera::eye() + render::Camera::axis().forward() * (render::FRUSTUMFRONT + 0.001)); cursor_aim -= render::Camera::axis().left() * x; cursor_aim -= render::Camera::axis().up() * y; + + float aim_distance = core::range::fxdistance; //math::Vector3f center = render::Camera::eye() + (render::Camera::axis().forward() * (render::FRUSTUMFRONT + 0.001f)); for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { @@ -501,7 +503,7 @@ void frame() // calculate the distance from entity location to the line [eye - cursor] float d = math::Vector3f::length(math::crossproduct((cursor_aim - render::Camera::eye()) , (render::Camera::eye() - entity->location()))) / math::Vector3f::length(cursor_aim - render::Camera::eye()); - float r = entity->radius() * 0.5f; + float r = entity->radius(); if (ext_render(entity)->distance() > 512.0f) math::clamp(r, 8.0f, r); @@ -511,10 +513,11 @@ void frame() math::clamp(r, 2.0f, r); // if the cursor-beam hits the entity sphere - if (d < r) { + if ((d < r) && ((current_target == entity) || (d < r * 0.75f))) { float myz = math::distance(cursor_aim, entity->location()); if (z < 0 || myz < z) { current_hover = entity->id(); + aim_distance = math::distance(render::Camera::eye(), entity->location()); z = myz; } } @@ -524,7 +527,7 @@ void frame() } } - cursor_aim = render::Camera::eye() + (cursor_aim - render::Camera::eye()) * core::range::fxdistance / math::distance(render::Camera::eye(), cursor_aim); + cursor_aim = render::Camera::eye() + (cursor_aim - render::Camera::eye()) * aim_distance / math::distance(render::Camera::eye(), cursor_aim); if (!current_target) { current_target_id = 0; -- cgit v1.2.3