@@ -163,17 +163,26 @@ public void CalculateDecalGeometry()
163163 // Re-project the vertices in case the texture axes are not on the face plane
164164 var xShift = face . Texture . UAxis * face . Texture . XScale * Decal . Width / 2 ;
165165 var yShift = face . Texture . VAxis * face . Texture . YScale * Decal . Height / 2 ;
166- decalFace . Vertices . Add ( new Vertex ( face . Plane . Project ( center + xShift - yShift ) , decalFace ) ) ; // Bottom Right
167- decalFace . Vertices . Add ( new Vertex ( face . Plane . Project ( center + xShift + yShift ) , decalFace ) ) ; // Top Right
168- decalFace . Vertices . Add ( new Vertex ( face . Plane . Project ( center - xShift + yShift ) , decalFace ) ) ; // Top Left
169- decalFace . Vertices . Add ( new Vertex ( face . Plane . Project ( center - xShift - yShift ) , decalFace ) ) ; // Bottom Left
166+ var verts = new [ ]
167+ {
168+ new Vertex ( face . Plane . Project ( center + xShift - yShift ) , decalFace ) , // Bottom Right
169+ new Vertex ( face . Plane . Project ( center + xShift + yShift ) , decalFace ) , // Top Right
170+ new Vertex ( face . Plane . Project ( center - xShift + yShift ) , decalFace ) , // Top Left
171+ new Vertex ( face . Plane . Project ( center - xShift - yShift ) , decalFace ) , // Bottom Left
172+ } ;
173+
174+ // TODO normalise these properly - the texture is reversed when it shouldn't be
175+ if ( ! face . Plane . Normal . EquivalentTo ( face . Texture . UAxis . Cross ( face . Texture . VAxis ) ) ) decalFace . Vertices . AddRange ( verts ) ;
176+ else decalFace . Vertices . AddRange ( verts . Reverse ( ) ) ;
177+
170178 decalFace . UpdateBoundingBox ( ) ;
171179 // TODO: verify this covers all situations and I don't have to manually calculate the texture coordinates
172180 decalFace . FitTextureToPointCloud ( new Cloud ( decalFace . Vertices . Select ( x => x . Location ) ) ) ;
173-
181+
174182 // Next, the decal geometry needs to be clipped to the face so it doesn't spill into the void
175183 // Create a fake solid out of the decal geometry and clip it against all the brush planes
176184 var fake = CreateFakeDecalSolid ( decalFace ) ;
185+
177186 foreach ( var f in face . Parent . Faces . Except ( new [ ] { face } ) )
178187 {
179188 Solid back , front ;
0 commit comments