我有以下课程
class Viewport
{
public:
Viewport();
~Viewport();
void setSize(float x, float y);
private:
float _X;
float _Y;
};
void Viewport::setSize(float x, float y)
{
//Conditionals used to make sure that the viewport stays inside the [0.0f, 1.0f] range
if(x < 0.0f)
_X = 0.0f;
else if(x > 1.0f)
_X = 1.0f;
else
_X = x;
if(y < 0.0f)
_Y = 0.0f;
else if(y > 1.0f)
_Y = 1.0f;
else
_Y = y;
}
我创建了视口矢量
Viewport vps[3];
uint _NumCascades = 3;
for(uint i = 0; i < _NumCascades; i++)
vps[i].setSize(i * (1.0f/_NumCascades), 0.0f);
奇怪的错误发生在何时i == 1
和i==2
在线_X = x;
,因为_X
被分配了值1051372203
而不是0.33333334f