Triangle Intersection: Unterschied zwischen den Versionen

Aus Das Sopra Wiki
Florian (Diskussion | Beiträge)
Die Seite wurde neu angelegt: „{{Stub}} Gerade für Picking kann es sehr interessant sein beim Raytracing direkt die Triangles eines Modells für den Schnittpunkttest zu verwenden um dsa P…“
 
Florian (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Zeile 64: Zeile 64:
         IntersectionHelper.RayTriangleIntersect(ref objectRay, ref this.vertices[this.indicesInt[i]], ref this.vertices[this.indicesInt[i + 1]], ref this.vertices[this.indicesInt[i + 2]], out result);
         IntersectionHelper.RayTriangleIntersect(ref objectRay, ref this.vertices[this.indicesInt[i]], ref this.vertices[this.indicesInt[i + 1]], ref this.vertices[this.indicesInt[i + 2]], out result);


      if ((result.HasValue) && (result.Value < nearestResult))
        if ((result.HasValue) && (result.Value < nearestResult))
        {
          nearestResult = result.Value;
        }
      }
    }
    else
    {
      for (int i = 0; i < this.indicesShort.Length; i += 3)
       {
       {
         nearestResult = result.Value;
         IntersectionHelper.RayTriangleIntersect(ref objectRay, ref this.vertices[this.indicesShort[i]], ref this.vertices[this.indicesShort[i + 1]], ref this.vertices[this.indicesShort[i + 2]], out result);
 
        if ((result.HasValue) && (result.Value < nearestResult))
        {
          nearestResult = result.Value;
        }
       }
       }
     }
     }
  }
  else
  {
    for (int i = 0; i < this.indicesShort.Length; i += 3)
    {
      IntersectionHelper.RayTriangleIntersect(ref objectRay, ref this.vertices[this.indicesShort[i]], ref this.vertices[this.indicesShort[i + 1]], ref this.vertices[this.indicesShort[i + 2]], out result);


     if ((result.HasValue) && (result.Value < nearestResult))
     if (!float.IsPositiveInfinity(nearestResult))
     {
     {
       nearestResult = result.Value;
       result = nearestResult;
}
    }
}
  }
}
}
</source>


if (!float.IsPositiveInfinity(nearestResult))
[[Kategorie:Code-Beispiele]]
{
result = nearestResult;
}
}
}
</source> [[Kategorie:Code-Beispiele]]