I'm working on a 3D project in Python using the HARFANG 3D wheel (I got from Pypi).
I have a function where I pass a series of data, including a vector3:
def evaluate_collision_to_sphere(position, velocity, dt, sphere_pos, sphere_rad):
# tries to evaluation if the next iteration
# will drive the position within the sphere radius
position += velocity * dt
if hg.Dist(position, sphere_pos) < sphere_rad:
return True
else:
return False
I don't return position and it is not a global variable. However, when returning from this function, position is modified within the scope of the caller.
How to I prevent this to happen :(