Would it be possible for you to derive your Vector3D
class from D3DXVECTOR3
? Just like ATL::CRect
class derives from Win32 RECT
structure (adding convenient methods).
If this is not possible or just doesn't fit well in your particular design context, consider offering explicit methods for conversions, just like std::string
offers a .c_str()
method to get a const char*
pointer, instead of using an implicit conversion. You may find this blog post interesting as well:
Reader Q&A: Why don’t modern smart pointers implicitly convert to *?
Moreover, I noted that D3DXVec3Add()
just uses pointers to instances of D3DXVECTOR3
. So, in case you can't derive your own class from D3DXVECTOR3
(as you stated in a comment), it would make sense to provide a couple of getters (both const
and non-const
versions), like this:
class Vector3D
{
public:
....
// Get read-only access to wrapped D3DX vector
const D3DXVECTOR3* Get() const
{
return &m_vec;
}
// Get read-write access to wrapped D3DX vector
D3DXVECTOR3* Get()
{
return &m_vec;
}
private:
D3DXVECTOR3 m_vec;
};
and then use them like this:
Vector3D v1;
Vector3D v2;
Vector3D vSum;
D3DXVec3Add(vSum.Get(), v1.Get(), v2.Get());