FBX access violation on Manager->destory() because of normals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all, I have a similar issue to this posting here on the forum . Link here
However, instead of it being on the material, the access violation occurs when I am computing/adding in the normal. When the code is removed, I am able to compute everything and the destroy function works. I am thinking that there is issue where an index goes out of bounds. Anyways, here is the code snippet with the bug present. Could someone take a look at what I have an see if there is any issue with what I wrote?
if (!normal_indexes.empty() && !p_Context.batch_mode)
{
// get normals
auto normal_element = shape->CreateElementNormal();
normal_element->SetMappingMode(FbxGeometryElement::eByPolygonVertex);
normal_element->SetReferenceMode(FbxGeometryElement::eIndexToDirect);
auto& direct_array = normal_element->GetDirectArray();
// set a base normals
std::for_each(modelIterator.getNormals().begin(), modelIterator.getNormals().end(),
[&direct_array](const Geometry::Vector3& elem)
{
direct_array.Add(FbxVector4(elem.x, elem.y, elem.z));
});
for (auto& morph_normal : morph.get_normals())
{
uint32_t idx = morph_normal.first;
auto& offset = morph_normal.second;
auto& base = modelIterator.getNormals().at(idx);
direct_array[idx].Set(base.x + offset.x, base.y + offset.y, base.z + offset.z);
}
auto& index_array = normal_element->GetIndexArray();
std::for_each(normal_indexes.begin(), normal_indexes.end(),
[&index_array](const uint32_t& idx) { index_array.Add(idx); });
std::cout << "Finished" << std::endl;
}
Link copied