- d = vlen(NearestPointOnBox(self, other.origin) - other.origin);
- if(d < self.loddistance1)
- self.modelindex = self.lodmodelindex0;
- else if(!self.lodmodelindex2 || d < self.loddistance2)
- self.modelindex = self.lodmodelindex1;
+ vector near_point = NearestPointOnBox(this, other.origin);
+ if(vdist(near_point - other.origin, <, this.loddistance1))
+ this.modelindex = this.lodmodelindex0;
+ else if(!this.lodmodelindex2 || vdist(near_point - other.origin, <, this.loddistance2))
+ this.modelindex = this.lodmodelindex1;