Fix for ATOM-15923 : Editor Spends Several Minutes Entering/Ending Play Game Mode (#1846)
* Cut off kd-tree generation if more than 10 percent of triangles straddle split axis Signed-off-by: amzn-tommy <waltont@amazon.com> * Switched to aznumeric_cast and added a comment with a JIRA to follow up on Signed-off-by: amzn-tommy <waltont@amazon.com>
This commit is contained in:
@@ -67,7 +67,8 @@ namespace AZ
|
||||
void ConstructMeshList(const ModelAsset* model, const AZ::Transform& matParent);
|
||||
|
||||
static const int s_MinimumVertexSizeInLeafNode = 3 * 10;
|
||||
|
||||
// Stop splitting the tree if more than 10% of the triangles are straddling the split axis
|
||||
static constexpr float s_MaximumSplitAxisStraddlingTriangles = 1.1;
|
||||
AZStd::unique_ptr<ModelKdTreeNode> m_pRootNode;
|
||||
|
||||
struct MeshData
|
||||
|
||||
@@ -84,7 +84,11 @@ namespace AZ
|
||||
|
||||
// If either the top or bottom contain all the input indices, the triangles are too close to cut any
|
||||
// further and the split failed
|
||||
return indices.size() != outInfo.m_aboveIndices.size() && indices.size() != outInfo.m_belowIndices.size();
|
||||
// Additionally, if too many triangles straddle the split-axis,
|
||||
// the triangles are too close and the split failed
|
||||
// [ATOM-15944] - Use a more sophisticated method to terminate KdTree generation
|
||||
return indices.size() != outInfo.m_aboveIndices.size() && indices.size() != outInfo.m_belowIndices.size()
|
||||
&& aznumeric_cast<float>(outInfo.m_aboveIndices.size() + outInfo.m_belowIndices.size()) / aznumeric_cast<float>(indices.size()) < s_MaximumSplitAxisStraddlingTriangles;
|
||||
}
|
||||
|
||||
bool ModelKdTree::Build(const ModelAsset* model)
|
||||
|
||||
Reference in New Issue
Block a user