Changeset 10291 for code/trunk/src/modules
- Timestamp:
- Mar 1, 2015, 3:08:45 PM (10 years ago)
- Location:
- code/trunk/src/modules/overlays/hud
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.