From 714f6a123ab92e6c88200c67eae143a3ba20373d Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Sun, 28 Jul 2019 12:14:13 +0000 Subject: [PATCH] skip invalid culling nodes --- Src/Graphics/New3D/New3D.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index adf9f46..b8e1491 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -489,6 +489,8 @@ bool CNew3D::DrawModel(UINT32 modelAddr) // Descends into a 10-word culling node void CNew3D::DescendCullingNode(UINT32 addr) { + enum class NodeType { undefined = -1, viewport = 0, rootNode = 1, cullingNode = 2 }; + const UINT32 *node, *lodTable; UINT32 matrixOffset, child1Ptr, sibling2Ptr; BBox bbox; @@ -497,6 +499,7 @@ void CNew3D::DescendCullingNode(UINT32 addr) UINT16 uBlendRadius; float fBlendRadius; UINT8 lodTablePointer; + NodeType nodeType; if (m_nodeAttribs.StackLimit()) { return; @@ -509,11 +512,17 @@ void CNew3D::DescendCullingNode(UINT32 addr) } // Extract known fields + nodeType = (NodeType)(node[0x00] & 3); child1Ptr = node[0x07 - m_offset] & 0x7FFFFFF; // mask colour table bits sibling2Ptr = node[0x08 - m_offset] & 0x1FFFFFF; // mask colour table bits matrixOffset = node[0x03 - m_offset] & 0xFFF; lodTablePointer = (node[0x03 - m_offset] >> 12) & 0x7F; + // check our node type + if (nodeType == NodeType::viewport) { + return; // viewport nodes aren't rendered + } + // parse siblings if ((node[0x00] & 0x07) != 0x06) { // colour table seems to indicate no siblings if (!(sibling2Ptr & 0x1000000) && sibling2Ptr) {