D3DXMATRIX ColladaFileLoader::processMatrix(daeElement* node)
{
D3DXMATRIX matWorld;
daeTArray<daeElementRef> nodeChildren = node->getChildren();
for (int i = 0; i < nodeChildren.getCount(); i++)
{
string type = nodeChildren[i]->getAttribute("sid");
if (type == "rotationX")
{
string data = nodeChildren[i]->getCharData();
stringstream stm(data);
stm >> matWorld.m[0][0];
stm >> matWorld.m[0][1];
stm >> matWorld.m[0][2];
stm >> matWorld.m[0][3];
}
if (type == "rotationY")
{
string data = nodeChildren[i]->getCharData();
stringstream stm(data);
stm >> matWorld.m[1][0];
stm >> matWorld.m[1][1];
stm >> matWorld.m[1][2];
stm >> matWorld.m[1][3];
}
if (type == "rotationZ")
{
string data = nodeChildren[i]->getCharData();
stringstream stm(data);
stm >> matWorld.m[2][0];
stm >> matWorld.m[2][1];
stm >> matWorld.m[2][2];
stm >> matWorld.m[2][3];
}
if (type == "location")
{
string data = nodeChildren[i]->getCharData();
stringstream stm(data);
stm >> matWorld.m[3][0];
stm >> matWorld.m[3][1];
stm >> matWorld.m[3][2];
matWorld.m[3][3] = 1;
}
}
return matWorld;
}此函数将在第一次循环结束后运行run debug assertion failed。循环将正确运行,它将进入最后一条if语句并正确设置所有值。然而,当传递完成后,在它开始下一次传递之前,它将调试断言失败。我认为它试图销毁string类型的变量,但当它试图删除它时,有些东西正在破坏它。我不知道问题出在哪里。它似乎在我的程序的其他部分也是这样做的,这些部分从文件中获取字符串并放在std::string中。我通过完全移除它们来修复它们,但是这个不能被移除,它需要存在。
不知道这是否与此有关,但我使用的是visual studio 11开发预览版,并使用编译器vs100 (vs10的编译器)设置。
dbgheap.c行:1322
表达式:_CrtISValidHeapPointer(pUserData)
另外,当我使用调试器时,这个函数中的变量都不会在错误之后出现。
发布于 2011-10-25 03:14:19
Ok在近一周的时间里发现了这个问题,对于将来可能遇到这个问题的其他人,我会把解决方案张贴出来。
我使用的colladaDOM版本是使用/mDd库(多线程调试dll)编译的,而我的项目使用的是/mtd (多线程调试静态)设置。在将我的项目改为/MDd之后,我所有的问题都消失了。
另一种可能的解决方案是使用/mtd重新构建DOM以匹配项目设置。
https://stackoverflow.com/questions/7802301
复制相似问题