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>2009-03-08 14:52:42 +0000
committerStijn Buys <ingar@osirion.org>2009-03-08 14:52:42 +0000
commit974631a33120837165e6ad04bd0ff6acaec08ffa (patch)
treebf45e62947214df7c8e4fdb071e91ae95491fff7 /src/client/targets.cc
parente4618a1c7e5fb0629997d389cb941a61095490ac (diff)
target selection updates
Diffstat (limited to 'src/client/targets.cc')
-rw-r--r--src/client/targets.cc77
1 files changed, 33 insertions, 44 deletions
diff --git a/src/client/targets.cc b/src/client/targets.cc
index af49826..08c0e14 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -39,29 +39,18 @@ unsigned int current_hover = 0;
core::Entity *current_target = 0;
core::Cvar *snd_engines = 0;
-
-bool is_legal_target(core::Entity *entity)
+bool is_valid_hud_target(core::Entity *entity)
{
+
if (entity->serverside()) {
return false;
} else if (!ext_render(entity)) {
return false;
- } else if (entity == core::localplayer()->mission_target()) {
- return true;
} else if (entity == core::localcontrol()) {
return false;
- } else if (ext_render(entity)->distance() < 0.001f) {
- return false;
} else {
- if (entity->type() != core::Entity::Controlable) {
- return ext_render(entity)->visible();
-
- } else if (ext_render(entity)->distance() < core::range::visible) {
- return true;
- }
+ return ext_render(entity)->visible();
}
-
- return false;
}
core::Entity* current()
@@ -122,7 +111,7 @@ void func_target_next(std::string const &args)
// first entity
it = zone->content().begin();
- while (!is_legal_target((*it)) && it != zone->content().end())
+ while (!is_valid_hud_target((*it)) && it != zone->content().end())
it++;
} else {
@@ -136,7 +125,7 @@ void func_target_next(std::string const &args)
if (it == zone->content().end()) {
it = zone->content().begin();
}
- while (!is_legal_target((*it))) {
+ while (!is_valid_hud_target((*it))) {
it++;
if (it == zone->content().end())
it = zone->content().begin();
@@ -175,7 +164,7 @@ void func_target_prev(std::string const &args)
if (!current_target_id) {
// last entity
rit = zone->content().rbegin();
- while (!is_legal_target((*rit)) && rit != zone->content().rend())
+ while (!is_valid_hud_target((*rit)) && rit != zone->content().rend())
rit++;
} else {
// current entity
@@ -188,7 +177,7 @@ void func_target_prev(std::string const &args)
if (rit == zone->content().rend()) {
rit = zone->content().rbegin();
}
- while (!is_legal_target((*rit))) {
+ while (!is_valid_hud_target((*rit))) {
++rit;
if (rit == zone->content().rend())
rit = zone->content().rbegin();
@@ -230,7 +219,7 @@ void func_target_center(std::string const &args)
math::Vector3f v(entity->location() - render::Camera::eye());
v.normalize();
- if (is_legal_target(entity) && math::dotproduct(render::Camera::axis().forward(), v) > 0.85 ) {
+ if (is_valid_hud_target(entity) && math::dotproduct(render::Camera::axis().forward(), v) > 0.85 ) {
// calculate the distance from entity location to the line [eye - cursor]
float d = math::Vector3f::length(math::crossproduct( (center - render::Camera::eye()) , (render::Camera::eye() - entity->location()))) / math::Vector3f::length(center - render::Camera::eye());
@@ -368,36 +357,36 @@ void frame()
}
// find the current target
- if (!core::localplayer()->view() && core::localcontrol() && is_legal_target(entity)) {
+ if (!core::localplayer()->view() && core::localcontrol()) {
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());
+ // 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);
- 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;
+ // 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;
+ }
}
}
}