Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-01-06 21:48:03 +0000
committerStijn Buys <ingar@osirion.org>2013-01-06 21:48:03 +0000
commitc59fc7a85bf78ef249159b960e2ca29c8f0271ff (patch)
tree2e1d6cae4a7464819c15b7105d3035f75cdb11f9 /src/client/targets.cc
parentd5b69e209b462577e048e3fb93c2e9fe3266f5f9 (diff)
Set aiming distance to the entity currently hovering with the mouse.
Diffstat (limited to 'src/client/targets.cc')
-rw-r--r--src/client/targets.cc9
1 files changed, 6 insertions, 3 deletions
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;