@@ -62,7 +62,11 @@ inline static LegoU32 BuildModelClipFlags(const GolD3DRenderDevice::VertexCacheE
6262 return lowFlags | (highFlags & ~(lowFlags << 1 ));
6363}
6464
65- inline static LegoFloat GetClipDistance (const GolD3DRenderDevice::VertexCacheEntry& p_vertex, LegoU32 p_plane)
65+ inline static LegoFloat GetClipDistance (
66+ const GolD3DRenderDevice::VertexCacheEntry& p_vertex,
67+ LegoU32 p_plane,
68+ LegoFloat p_farClip
69+ )
6670{
6771 if (p_plane == 0x01 ) {
6872 return p_vertex.m_x ;
@@ -80,7 +84,7 @@ inline static LegoFloat GetClipDistance(const GolD3DRenderDevice::VertexCacheEnt
8084 return p_vertex.m_z ;
8185 }
8286
83- return p_vertex.m_w - p_vertex. m_z ;
87+ return p_vertex.m_z - p_farClip ;
8488}
8589
8690inline static LegoU32 InterpolateColor (LegoU32 p_from, LegoU32 p_to, LegoFloat p_amount)
@@ -3675,7 +3679,6 @@ void GolD3DRenderDevice::FUN_1000d760(LegoU32 p_outputFirst, LegoU32 p_firstVert
36753679 vertex->sz = cache->m_z * vertex->rhw ;
36763680 const LegoU8* sourceColor = reinterpret_cast <const LegoU8*>(&source->m_color );
36773681 vertex->color = (sourceColor[3 ] << 24 ) | (sourceColor[0 ] << 16 ) | (sourceColor[1 ] << 8 ) | sourceColor[2 ];
3678- vertex->specular = m_unk0xc83fc;
36793682 vertex->tu = source->m_u + m_unk0xc83a0;
36803683 vertex->tv = source->m_v + m_unk0xc83a4;
36813684 }
@@ -3756,7 +3759,6 @@ void GolD3DRenderDevice::FUN_1000dbb0(LegoU32 p_outputFirst, LegoU32 p_firstVert
37563759 vertex->sz = cache->m_z * vertex->rhw ;
37573760 const LegoU8* sourceColor = reinterpret_cast <const LegoU8*>(&source->m_color );
37583761 vertex->color = alpha | (sourceColor[0 ] << 16 ) | (sourceColor[1 ] << 8 ) | sourceColor[2 ];
3759- vertex->specular = m_unk0xc83fc;
37603762 vertex->tu = source->m_u + m_unk0xc83a0;
37613763 vertex->tv = source->m_v + m_unk0xc83a4;
37623764 }
@@ -4219,12 +4221,12 @@ void GolD3DRenderDevice::FUN_1000edf0(undefined4 p_firstTriangle, undefined4 p_t
42194221 LegoU32 outputCount = 0 ;
42204222 LegoU32 previousIndex = vertexCount - 1 ;
42214223 LegoBool32 previousInside = (inputCache[previousIndex]->m_clipFlags & plane) == 0 ;
4222- LegoFloat previousDistance = GetClipDistance (*inputCache[previousIndex], plane);
4224+ LegoFloat previousDistance = GetClipDistance (*inputCache[previousIndex], plane, farClip );
42234225 unionFlags = 0 ;
42244226
42254227 for (LegoU32 i = 0 ; i < vertexCount; i++) {
42264228 LegoBool32 currentInside = (inputCache[i]->m_clipFlags & plane) == 0 ;
4227- LegoFloat currentDistance = GetClipDistance (*inputCache[i], plane);
4229+ LegoFloat currentDistance = GetClipDistance (*inputCache[i], plane, farClip );
42284230
42294231 if (previousInside != currentInside) {
42304232 LegoFloat delta = previousDistance - currentDistance;
@@ -4561,13 +4563,13 @@ void GolD3DRenderDevice::FUN_100106d0(undefined4 p_firstTriangle, undefined4 p_t
45614563 LegoU32 outputCount = 0 ;
45624564 LegoU32 previousIndex = inputIndices[vertexCount - 1 ];
45634565 LegoBool32 previousInside = (m_unk0xc38ec[previousIndex].m_clipFlags & plane) == 0 ;
4564- LegoFloat previousDistance = GetClipDistance (m_unk0xc38ec[previousIndex], plane);
4566+ LegoFloat previousDistance = GetClipDistance (m_unk0xc38ec[previousIndex], plane, farClip );
45654567 unionFlags = 0 ;
45664568
45674569 for (LegoU32 i = 0 ; i < vertexCount; i++) {
45684570 LegoU32 currentIndex = inputIndices[i];
45694571 LegoBool32 currentInside = (m_unk0xc38ec[currentIndex].m_clipFlags & plane) == 0 ;
4570- LegoFloat currentDistance = GetClipDistance (m_unk0xc38ec[currentIndex], plane);
4572+ LegoFloat currentDistance = GetClipDistance (m_unk0xc38ec[currentIndex], plane, farClip );
45714573
45724574 if (previousInside != currentInside) {
45734575 LegoFloat delta = previousDistance - currentDistance;
0 commit comments