Changeset 10291 for code/trunk/src
- Timestamp:
- Mar 1, 2015, 3:08:45 PM (10 years ago)
- Location:
- code/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/util/Math.cc
r10289 r10291 360 360 return orxonox::Vector3::ZERO; 361 361 362 float temp = sqrt(discriminant); 363 float solution1 = (-b + temp) / (2 * a); 364 float solution2 = (-b - temp) / (2 * a); 365 float time = 1.0f / std::max(solution1, solution2); 362 float solution = (-b + sqrt(discriminant)) / (2 * a); 363 float time = 1.0f / solution; 366 364 367 365 return (targetposition + targetvelocity * time); -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r10258 r10291 487 487 { 488 488 // get the aim position 489 Vector3*targetPos = this->toAimPosition(it->first);489 const Vector3& targetPos = this->toAimPosition(it->first); 490 490 // Transform to screen coordinates 491 Vector3 screenPos = camTransform * (*targetPos);491 Vector3 screenPos = camTransform * targetPos; 492 492 // Check if the target marker is in view too 493 493 if(screenPos.z > 1 || screenPos.x < -1.0 || screenPos.x > 1.0 … … 502 502 it->second.target_->show(); 503 503 } 504 delete targetPos;505 504 } 506 505 … … 679 678 } 680 679 681 Vector3 *HUDNavigation::toAimPosition(RadarViewable* target) const680 Vector3 HUDNavigation::toAimPosition(RadarViewable* target) const 682 681 { 683 682 Vector3 wePosition = HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition(); 684 683 Vector3 targetPosition = target->getRVWorldPosition(); 685 684 Vector3 targetSpeed = target->getRVVelocity(); 686 Vector3 relativePosition = targetPosition - wePosition; //Vector from attacker to target 687 688 float p_half = relativePosition.dotProduct(targetSpeed)/(targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_); 689 float time1 = -p_half + sqrt(p_half * p_half - relativePosition.squaredLength()/(targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_)); 690 691 Vector3* result = new Vector3(targetPosition + targetSpeed * time1); 692 return result; 685 686 return getPredictedPosition(wePosition, this->currentMunitionSpeed_, targetPosition, targetSpeed); 693 687 } 694 688 -
code/trunk/src/modules/overlays/hud/HUDNavigation.h
r10258 r10291 138 138 float getArrowSizeY(int dist) const; 139 139 140 Vector3 *toAimPosition(RadarViewable* target) const;140 Vector3 toAimPosition(RadarViewable* target) const; 141 141 142 142 std::map<RadarViewable*, ObjectInfo> activeObjectList_;
Note: See TracChangeset
for help on using the changeset viewer.