Skip to content

Commit

Permalink
sensors: v_dist_point_to_rect is not valid for get distance of the po…
Browse files Browse the repository at this point in the history
…inter to the target in pointer_over_no_phy.
  • Loading branch information
Julio Manuel López Tercero committed Feb 14, 2017
1 parent 498bdee commit 9075de5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions engine/sensors.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,12 @@ pointer_over_no_phy = (pointer_event, cam, objects={})->

for ob in objects
pos = ob.get_world_position()
vdist = r3.v_dist_point_to_rect v3, pos, cam_pos, dir
dist = vec3.len vdist

vec3.normalize dir, dir
target_dir = vec3.scale v3, dir, vec3.dist(cam_pos, pos)
vec3.add target_dir, cam_pos, target_dir
dist = vec3.dist(target_dir, pos)

if dist <= ob.radius
hits.push
object: ob
Expand Down

0 comments on commit 9075de5

Please sign in to comment.