Hi,
I'm still a bit confused about structs being copied when they are modified. I have a ray class, with two vectors ...
public class Ray
{
public Vector3 Origin { get; set; }
public Vector3 Direction { get; set; }
public Ray(Vector3 origin, Vector3 direction)
{
Origin = origin;
direction.Normalize();
Direction = direction;
/* this doesn't work*/
//Direction = direction;
//Direction.Normalize();
}
What I don't get is why direction.Normalize() modifies direction, but Direction.Normalize() doesn't modify Direction.
Edit : My running theory, is that after Normalize is called, both direction and Direction are copies local to the constructor, and in the first case, it is actually assigned to the global, but in the second, it is left unused.