Original Post
I suppose this is more of a .Net/C# question than a SlimDX one, but I want to make sure the SlimDX guys see it to get their input. The "problem" I'm having is that 90% of the time I use Vector3.Transform() and the other Vector3 methods, I want a Vector3 as the output (much like you get in XNA), however, since SlimDX wraps DirectX it outputs a Vector4, just like the D3DX functions. So my first thought was to write a quick ToVector3() extension method for Vector4, but then I couldn't figure out which was the best way to write it. Originally I had the following: Thinking about it this morning though, I don't want to be allocating new Vector3s each frame (or does it not really matter?) Ideally the Vector3 methods would return Vector3s, or I could downcast between Vector types but I know both of those are not going to happen. Is there another way of doing this? Or a more efficient way? Is it worth writting an extension overload for transform that returns a Vector3 instead? (although I'm guessing I'd lose out on all the optomisation the wrapped SlimDX methods have?)
public static Vector3 ToVector3(this Vector4 in)
{
return new Vector3(in.X, in.Y, in.Z);
}