Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 1, 2015, 3:08:45 PM (9 years ago)
Author:
landauf
Message:

simplified Math: temp is always positive, thus only solution1 is necessary
simplified HUDNavigation: use existing function to calculation aim-position

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/overlays/hud/HUDNavigation.cc

    r10258 r10291  
    487487                    {
    488488                        // get the aim position
    489                         Vector3* targetPos = this->toAimPosition(it->first);
     489                        const Vector3& targetPos = this->toAimPosition(it->first);
    490490                        // Transform to screen coordinates
    491                         Vector3 screenPos = camTransform * (*targetPos);
     491                        Vector3 screenPos = camTransform * targetPos;
    492492                        // Check if the target marker is in view too
    493493                        if(screenPos.z > 1 || screenPos.x < -1.0 || screenPos.x > 1.0
     
    502502                            it->second.target_->show();
    503503                        }
    504                         delete targetPos;
    505504                    }
    506505
     
    679678    }
    680679
    681     Vector3* HUDNavigation::toAimPosition(RadarViewable* target) const
     680    Vector3 HUDNavigation::toAimPosition(RadarViewable* target) const
    682681    {
    683682        Vector3 wePosition = HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition();
    684683        Vector3 targetPosition = target->getRVWorldPosition();
    685684        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);
    693687    }
    694688
Note: See TracChangeset for help on using the changeset viewer.