Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;for循环中的访问冲突写入位置_C++_Directx - Fatal编程技术网

C++ C++;for循环中的访问冲突写入位置

C++ C++;for循环中的访问冲突写入位置,c++,directx,C++,Directx,我试图使一个边界框工作,以便在我的引擎中实现frustrum剔除。但只要我运行解决方案,边界框的transform函数中就会出现访问冲突运行时错误 void BoundingBox::Transform(D3DXVECTOR3 pos, D3DXVECTOR3 rot, D3DXVECTOR3 sca) { D3DXQUATERNION rotationQuaternion; D3DXMatrixTransformation(&mat, NULL, NULL, &sca, N

我试图使一个边界框工作,以便在我的引擎中实现frustrum剔除。但只要我运行解决方案,边界框的transform函数中就会出现访问冲突运行时错误

void BoundingBox::Transform(D3DXVECTOR3 pos, D3DXVECTOR3 rot, D3DXVECTOR3 sca) {

D3DXQUATERNION rotationQuaternion;

D3DXMatrixTransformation(&mat, NULL, NULL, &sca, NULL, 
    D3DXQuaternionRotationYawPitchRoll(&rotationQuaternion, 
    D3DXToRadian(rot.x), D3DXToRadian(rot.y), D3DXToRadian(rot.z)), &pos);

    for (int k = 0; k < 8; k++)
    {
        D3DXVec3Transform(&transVertex[k], &vertexes[k], &mat);

        /*this->*/xMin = min(transVertex->x, /*this->*/xMin);
        /*this->*/yMin = min(transVertex->y, /*this->*/yMin);
        /*this->*/zMin = min(transVertex->z, /*this->*/zMin);

        /*this->*/xMax = max(transVertex->x, /*this->*/xMax);
        /*this->*/yMax = max(transVertex->y, /*this->*/yMax);
        /*this->*/zMax = max(transVertex->z, /*this->*/zMax);
    }}
void BoundingBox::Transform(D3DXVECTOR3 pos、D3DXVECTOR3 rot、D3DXVECTOR3 sca){
D3DX四元数旋转四元数;
D3DXMatrix转换(&mat,NULL,NULL,&sca,NULL,
D3DX四元数旋转YawPitchRoll(&rotationQuaternion,
D3DXToRadian(rot.x)、D3DXToRadian(rot.y)、D3DXToRadian(rot.z))、&pos);
对于(int k=0;k<8;k++)
{
d3dxvec3变换(&transVertex[k]、&vertex[k]、&mat);
/*this->*/xMin=min(transVertex->x,/*this->*/xMin);
/*this->*/yMin=min(跨顶点->y,/*this->*/yMin);
/*this->*/zMin=min(transVertex->z,/*this->*/zMin);
/*this->*/xMax=max(transVertex->x,/*this->*/xMax);
/*this->*/yMax=max(transVertex->y,/*this->*/yMax);
/*this->*/zMax=max(transVertex->z,/*this->*/zMax);
}}
有人知道为什么会这样吗


错误是这样说的:“bushRanger.exe中的0x0F5E20E6(D3DX9_43.dll)抛出异常:0xC0000005:访问冲突写入位置0x00000038。”

我发现了发生的情况,相机生成了平截体,但它没有边界框,并且它仍然使用与其余合成体相同的Move()函数

    void Composite::Move(D3DXVECTOR3 trasl, D3DXVECTOR3 escal, D3DXVECTOR3 rot) 
{
Component::Move(trasl, escal, rot);
/*D3DXMATRIX rotMat = rotXMat * rotYMat * rotZMat;
thyMatrix = scaMat * rotMat * transMat;*/
D3DXQUATERNION rotationQuaternion;
D3DXMatrixTransformation(&thyMatrix, NULL, NULL, &escal, NULL, D3DXQuaternionRotationYawPitchRoll(&rotationQuaternion, D3DXToRadian(rot.x), D3DXToRadian(rot.y), D3DXToRadian(rot.z)), &trasl);
laCajita->Transform(_trasl, _escal, _rot); // and here is a non existant bounding box
UpdateBoundingBox();
}
在这里,当它接触到相机的移动功能时,它调用了一个不存在的边界框


好了,各位,谢谢你们在评论中的帮助,从现在起,在发布问题之前,我会更加关注debbugger。

调试器会怎么说?你怎么知道这是有问题的例行程序?在调试器下运行它,它将向您显示初始化失败的指针。从接近零的地址看,您可能有一个空的
这个
指针。Ken Y-N好吧,我运行了调试器,它在for命令中停止了。您需要在关闭优化的情况下编译。此外,您是否检查了任何局部变量或
是否为
NULL
?Ken Y-N是的,
给出
NULL
,但为什么会发生这种情况?应该初始化该对象。