简体   繁体   English

使用XMMatrix和std :: vector的访问冲突

[英]Access Violation using XMMatrix and std::vector

I'm currently having a problem in my project where I'm trying to get a Dx11 running. 我目前在我的项目中遇到问题,试图在其中运行Dx11。

My error is: Unhandled exception at 0x00FC266D in 3DTestProject.exe: 0xC0000005: Access violation reading location 0x00000000. 我的错误是: 3DTestProject.exe中0x00FC266D处未处理的异常:0xC0000005:访问冲突读取位置0x00000000。

The Crash Occurs in my Model.cpp IN Model::Render() at this line: 在我的Model.cpp IN Model :: Render()中的此行发生崩溃:
cb.mWorld = DirectX::XMMatrixTranspose(aOrientation);

Because of the implementation I have to send it as a const reference in Render() 由于实现原因,我必须在Render()中将其作为const引用发送

const DirectX::XMMATRIX& aOrientation

Called from Instance 从实例调用
m_pModel->Update();

My header for Instance looks like this: 我的Instance标头如下所示:

class Instance 
{
public:
  Instance();
  Instance(Model* aModel);
  ~Instance();

  void Update();
  void Render(Camera* aCamera);

private:

  DirectX::XMMATRIX m_Orientation;
};

My guess is it is because I store my instances in Scene.h as a std::vector and I don't know how to solve it. 我的猜测是因为我将实例作为std :: vector存储在Scene.h中,但我不知道如何解决。

std::vector<Instance> m_vecInstances;

Changing these lines and using XMFLOAT4X4 instead seems to work at this point. 此时,更改这些行并使用XMFLOAT4X4似乎可以工作。

const DirectX::XMFLOAT4X4 aOrientation

and

cb.mWorld = DirectX::XMMatrixTranspose(XMLoadFloat4x4(&aOrientation));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM