Changeset 9443 for code/branches/spaceNavigation/src/modules/overlays
- Timestamp:
- Nov 12, 2012, 4:37:08 PM (12 years ago)
- Location:
- code/branches/spaceNavigation/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
r9434 r9443 71 71 this->setFont("Monofur"); 72 72 this->setTextSize(0.05f); 73 this->setNavMarkerSize(0.0 5f);73 this->setNavMarkerSize(0.03f); 74 74 this->setAimMarkerSize(0.02f); 75 75 … … 180 180 unsigned int markerCount = 0; 181 181 bool closeEnough = false; // only display objects that are close enough to be relevant for the player 182 182 183 183 184 for (std::list<std::pair<RadarViewable*, unsigned int> >::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++markerCount, ++listIt) … … 227 228 } 228 229 else 229 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;230 outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0; 230 231 231 232 if (outOfView) … … 315 316 316 317 // Target marker 317 if(it->second.selected_ )318 if(it->second.selected_ && it->first->getRVOrientedVelocity().squaredLength() != 0) 318 319 { 319 320 Vector3* targetPos = this->toAimPosition(it->first); 320 Vector3 screenPos = camTransform * *targetPos;321 Vector3 screenPos = camTransform * (*targetPos); 321 322 // Check if the target marker is in view too 322 323 if(screenPos.z > 1 || screenPos.x < -1.0 || screenPos.x > 1.0 … … 491 492 // munSpeed*time = lengthBetween(wePosition, targetPosition + targetSpeed*time) 492 493 // from this we extract: 493 float a = pow(targetSpeed.length(),2) - pow(this->currentMunitionSpeed_,2);494 float a = targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_; 494 495 float b = 2*((targetPosition.x - wePosition.x)*targetSpeed.x 495 496 +(targetPosition.y - wePosition.y)*targetSpeed.y 496 497 +(targetPosition.z - wePosition.z)*targetSpeed.z); 497 float c = pow((targetPosition-wePosition).length(),2);498 float c = (wePosition-targetPosition).squaredLength(); 498 499 499 500 // calculate smallest time solution, in case it exists 500 if(pow(b,2) - 4*a*c < 0) 501 float det = b * b - 4 * a * c; 502 if(det < 0) 501 503 return NULL; 502 float time = (-b - sqrt( pow(b,2) - 4*a*c))/(2*a);504 float time = (-b - sqrt(det))/(2*a); 503 505 if(time < 0) 504 time = (-b + sqrt( pow(b,2) - 4*a*c))/(2*a);506 time = (-b + sqrt(det))/(2*a); 505 507 if(time < 0) 506 508 return NULL; 507 Vector3* result = new Vector3(targetPosition + t argetSpeed * time);509 Vector3* result = new Vector3(targetPosition + time * targetSpeed); 508 510 return result; 509 511 } -
code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h
r9434 r9443 87 87 inline void setNavMarkerSize(float size) 88 88 { 89 navMarkerSize_ = size;89 this->navMarkerSize_ = size; 90 90 this->sizeChanged(); 91 91 } … … 94 94 inline void setAimMarkerSize(float size) 95 95 { 96 aimMarkerSize_ = size;96 this->aimMarkerSize_ = size; 97 97 this->sizeChanged(); 98 98 }
Note: See TracChangeset
for help on using the changeset viewer.