Skip to content

Commit 692c697

Browse files
committed
remove non-vector overload for distance
1 parent 7cb199f commit 692c697

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

game/world/objects/interactive.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ P* Interactive::findNearest(Inter& in, const Npc& to) {
565565
for(auto& i:in.attPos) {
566566
if(i.user || !i.isAttachPoint())
567567
continue;
568-
float d = in.qDistanceTo(to,i);
568+
float d = in.qDistTo(to,i);
569569
if(d<dist || p==nullptr) {
570570
p = &i;
571571
dist = d;
@@ -853,9 +853,9 @@ void Interactive::setDir(Npc &npc, const Tempest::Matrix4x4 &mat) {
853853
npc.setDirection(Tempest::Vec3(x1-x0, y1-y0, z1-z0));
854854
}
855855

856-
float Interactive::qDistanceTo(const Npc &npc, const Interactive::Pos &to) const {
856+
float Interactive::qDistTo(const Npc &npc, const Interactive::Pos &to) const {
857857
auto p = worldPos(to);
858-
return npc.qDistTo(p.x,p.y-npc.translateY(),p.z);
858+
return npc.qDistTo(p);
859859
}
860860

861861
Tempest::Matrix4x4 Interactive::nodeTranform(const Npc &npc, const Pos& p) const {

game/world/objects/npc.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -686,15 +686,9 @@ std::string_view Npc::formerPortalName() {
686686
return mvAlgo.formerPortalName();
687687
}
688688

689-
float Npc::qDistTo(float x1, float y1, float z1) const {
690-
float dx=x-x1;
691-
float dy=y+translateY()-y1;
692-
float dz=z-z1;
693-
return dx*dx+dy*dy+dz*dz;
694-
}
695-
696-
float Npc::qDistTo(const Tempest::Vec3 pos) const {
697-
return qDistTo(pos.x,pos.y,pos.z);
689+
float Npc::qDistTo(const Vec3 pos) const {
690+
auto dp = pos - Vec3(x,y+translateY(),z);
691+
return dp.quadLength();
698692
}
699693

700694
float Npc::qDistTo(const WayPoint *f) const {
@@ -704,7 +698,7 @@ float Npc::qDistTo(const WayPoint *f) const {
704698
}
705699

706700
float Npc::qDistTo(const Npc &p) const {
707-
return qDistTo(p.x,p.y+p.translateY(),p.z);
701+
return qDistTo(Vec3(p.x,p.y+p.translateY(),p.z));
708702
}
709703

710704
float Npc::qDistTo(const Interactive &p) const {

game/world/objects/npc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ class Npc final {
123123
auto portalName() -> std::string_view;
124124
auto formerPortalName() -> std::string_view;
125125

126-
float qDistTo(float x, float y, float z) const;
127126
float qDistTo(const Tempest::Vec3 pos) const;
128127
float qDistTo(const WayPoint* p) const;
129128
float qDistTo(const Npc& p) const;

0 commit comments

Comments
 (0)