Collision Ray and collision location mismatch

So i have some geometry and I would like to know the surface points given X and Z. I have set the collision ray origin to some given X and Z and ray direction to be in Y direction. However the collision entry surface points are different from the given X and Z. Any ideas?

code:

for x in xrange(0,20,5):
for z in xrange(0,20,5):
self.Ray.setOrigin(x,0,z)
self.Ray.setDirection(0, 1, 0)
base.cTrav.traverse(render)
self.queue.sortEntries()
entry=self.queue.getEntry(0)
pos= entry.getSurfacePoint(entry.getIntoNodePath())
print(‘POSSSSS’,pos, ‘X:’,x,‘Z:’,z)

results: collision points not along given X & Z

('POSSSSS', LPoint3f(-0.130147, 3.83462, -6.19396), 'X:', 0, 'Z:', 0)
('POSSSSS', LPoint3f(-0.143369, 4.99922, -1.30849), 'X:', 0, 'Z:', 5)
('POSSSSS', LPoint3f(-0.136707, 5.45892, 3.67604), 'X:', 0, 'Z:', 10)
('POSSSSS', LPoint3f(-0.106317, 5.07738, 8.7788), 'X:', 0, 'Z:', 15)
('POSSSSS', LPoint3f(4.83067, 5.29287, -6.3989), 'X:', 5, 'Z:', 0)
('POSSSSS', LPoint3f(4.82721, 6.11129, -1.46478), 'X:', 5, 'Z:', 5)
('POSSSSS', LPoint3f(4.8483, 6.05942, 3.59164), 'X:', 5, 'Z:', 10)
('POSSSSS', LPoint3f(4.88533, 5.44265, 8.72746), 'X:', 5, 'Z:', 15)
('POSSSSS', LPoint3f(9.70605, 9.78011, -7.02954), 'X:', 10, 'Z:', 0)
('POSSSSS', LPoint3f(9.7304, 9.61271, -1.95688), 'X:', 10, 'Z:', 5)
('POSSSSS', LPoint3f(9.77999, 8.55052, 3.24154), 'X:', 10, 'Z:', 10)
('POSSSSS', LPoint3f(9.85294, 6.66006, 8.55637), 'X:', 10, 'Z:', 15)
('POSSSSS', LPoint3f(14.6245, 12.7419, -7.44579), 'X:', 15, 'Z:', 0)
('POSSSSS', LPoint3f(14.6466, 12.6536, -2.38424), 'X:', 15, 'Z:', 5)
('POSSSSS', LPoint3f(14.7076, 11.1846, 2.87134), 'X:', 15, 'Z:', 10)
('POSSSSS', LPoint3f(14.7908, 8.93354, 8.23685), 'X:', 15, 'Z:', 15)

I think you want to get the surface point relative render instead, ie. getSurfacePoint(render). Currently, you are getting them relative to the target NodePath, which means the position returned will be relative to that of the NodePath that is being collided with.

1 Like