Reputation: 1191
I'm having trouble finding reliable documentation on what happens when you call the default constructor on an XMVECTOR.
MSDN says that the XMMATRIX default constructor does not initialize the variables to 0 (http://msdn.microsoft.com/en-us/library/windows/desktop/ee420023(v=vs.85).aspx). So my gut feeling is that the same is true for XMVECTOR, but unfortunately I cannot find this confirmation on the MSDN site.
Back to the original question:
// Trackball.h
class Trackball
{
...
XMVECTOR m_eye;
XMVECTOR m_position;
XMVECTOR m_up;
XMVECTOR m_rotateStart;
XMVECTOR m_rotateEnd;
...
}
// Trackball.cpp
Trackball::Trackball(void) :
...
m_eye(),
m_rotateStart(),
m_rotateEnd(),
m_zoomStart(),
m_zoomEnd(),
m_panStart(),
m_panEnd(),
...
{
}
But this just uses the default constructor to initialize the variable right? So if the above assumption that the default constructor does not initialize the members of XMVECTOR holds, then should I be doing this instead?:
// Trackball.cpp
Trackball::Trackball(void) :
...
m_eye(XMVectorZero()),
m_rotateStart(XMVectorZero()),
m_rotateEnd(XMVectorZero()),
m_zoomStart(XMVectorZero()),
m_zoomEnd(XMVectorZero()),
m_panStart(XMVectorZero()),
m_panEnd(XMVectorZero()),
...
{
}
That looks ugly but may be right.
Thanks for reading and thanks for any help.
Upvotes: 0
Views: 2390
Reputation: 8747
I think your way is correct, if you think it's ugly, you can put it in the constructor body, though it will lost some performance since initialize list only call copy constructor. if you want to see what the default constructor of XMVECTOR do, you can run your program in debug mode and look that in the watch window.
Upvotes: 2