Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - CodinRonin

Pages: [1]
1
Other Packages / Re: Tasharen Fog Of War fixes.
« on: May 18, 2014, 02:33:47 PM »
Well the issue manifested something like in the attached image. Wrong side of the object was "fogged".

The issue was kinda hard to spot if youre working with small maps where pixel space can be mapped 1:1 to world space since the worldToTex factor is ~1 , but in my case i was working with very small worldToTex factor so it was noticeable.


2
Other Packages / Re: Tasharen Fog Of War fixes.
« on: May 16, 2014, 04:37:31 PM »
For (1) , the Vector2 v , after normalization is applied a magnitude(multiplication) expressed in real world coordinates from the FOWRevealer class.

  1. v *= r.inner;

  1. // From the FOWRevevaler
  2. mRevealer.inner = range.x;
  3. mRevealer.outer = range.y;

So when calculating sx and sy , they have cx/cy part which is in pixel coordinates, and Mathf.RoundToInt(v.x/vy) part of a vector in game world coordinates




3
Other Packages / Tasharen Fog Of War fixes.
« on: May 16, 2014, 04:31:51 AM »
First of all, Great packages , using extensively FoW and HudText.

Just noticed 2 issues with Tasharen Fog Of War.

1. In the FowSystem class in RevealUsingLOS() and RevealUsingCache() methods there is incositency in the dimensioning of the variables,  in the case of (dist < maxRange)

  1. Vector2 v = new Vector2(xd, yd);
  2. v.Normalize();
  3. v *= r.inner;
  4.  
  5. int sx= cx+ Mathf.RoundToInt(v.x);
  6. int sy= cy+ Mathf.RoundToInt(v.y);
  7.  

all the variables are declared in "texture" space (i.e. multiplied with worldtoTex), except the r.inner value which is declared in "real world" value.  So , the fix is to multiply them by worldToTex also

  1. int sx= cx+ Mathf.RoundToInt(v.x * worldToTex);
  2. int sy= cy+ Mathf.RoundToInt(v.y * worldToTex);


2. The second one is more of a special case handling. For instance I'm having a huge world (size), with a relatively small texture size for the fog texture. So in a specific scenario it is possible for the revealer cache calculations to have errors in the approximation. Namely the RevealIntoCache method works with


Test Scenario :

Fow System :
position in real world {{7500,120,7300}}
World size : 178000
Texturesize : 1024
Position of revealer in "FoW" world : {(2615.0, 59.0, 6079.0)} , radius inner: 1200 , outer :1250

worldToTex = 0,05752809

  1. int size = Mathf.RoundToInt(xmax - xmin);
  2. r.cachedBuffer = new bool[size * size];
  3. r.cachedSize = size;

the calculation of xmin , xmax , ymin, ymax suffers a loss in precision and the cache buffer is smaller.
(IE , Mathf.RoundToInt(xmax - xmin) == 143 while Mathf.RoundToInt(ymax - ymin) == 144)
 , so the line
  1. r.cachedBuffer[(x - xmin) + (y - ymin) * size] = true;

fails.

As a safety precaution (temp fix) i formed a buffer from the largest of the min-max range
  1. int size = Mathf.Max(Mathf.RoundToInt(xmax - xmin), Mathf.RoundToInt(ymax - ymin));

Pages: [1]