Skip to content
Snippets Groups Projects
Commit 90365b35 authored by Knuiman, Bart's avatar Knuiman, Bart
Browse files

Fixed bug where pixel was written twice, because geometry from vtile...

Fixed bug where pixel was written twice, because geometry from vtile overlapped twice same pixel, resulting in incorrect mapping.
parent 37968d67
No related branches found
No related tags found
No related merge requests found
......@@ -408,6 +408,8 @@ namespace Wander
UnityEngine.Debug.Assert( resolution > 1, "Must be at least 2." );
byte [] texture = new byte[resolution*resolution/2];
bool [] written = new bool[resolution*resolution];
int d = 4096 / resolution;
int shift = -1;
while (d!=0)
......@@ -430,6 +432,7 @@ namespace Wander
{
var min = poly.mins[t];
var max = poly.maxs[t];
int x1 = Mathf.FloorToInt( min.x );
int y1 = Mathf.FloorToInt( min.y );
int x2 = Mathf.FloorToInt( max.x );
......@@ -462,11 +465,14 @@ namespace Wander
if (PointInTriangle( new Vector2( xk2, yk2 ), poly.vertices[i], poly.vertices[i+1], poly.vertices[i+2] ))
{
var addr2 = (resolution - y -1)*resolution+x;
//var addr2 = (resolution* y)+x;
if (layerIdx > 15)
layerIdx = 15; // max layers 15 (15 is reserved, nothing was hit).
var shift2 = (addr2&1) << 2;
texture[addr2>>1] |= (byte)(layerIdx << shift2);
if (!written[addr2])
{
written[addr2]=true;
if (layerIdx > 15)
layerIdx = 15; // max layers 15 (15 is reserved, nothing was hit).
var shift2 = (addr2&1) << 2;
texture[addr2>>1] |= (byte)(layerIdx << shift2);
}
}
}
}
......@@ -600,8 +606,9 @@ namespace Wander
{
if ((x&1) == 0)
pixel = texture[addr>>1];
UnityEngine.Debug.Assert( (pixel&0xF) < 10 && ((pixel>>4)&0xF) < 10 );
byte shift = (byte)((addr&1));
byte pixel2 = (byte)((pixel >> (shift<<2)) & 15);
byte pixel2 = (byte)((pixel >> (shift<<2)) & 0xF);
if (pixel2 != 15)
{
if (pixel2 != cachedPixel)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment