forked from bit/DotRecastNetSim
vector3f -> xyz
This commit is contained in:
parent
0620cdcd85
commit
cf7a44afdb
|
@ -83,9 +83,9 @@ namespace DotRecast.Core
|
||||||
float EPS = 1e-6f;
|
float EPS = 1e-6f;
|
||||||
|
|
||||||
Vector3f d = new Vector3f();
|
Vector3f d = new Vector3f();
|
||||||
d[0] = sq[0] - sp[0];
|
d.x = sq[0] - sp[0];
|
||||||
d[1] = sq[1] - sp[1];
|
d.y = sq[1] - sp[1];
|
||||||
d[2] = sq[2] - sp[2];
|
d.z = sq[2] - sp[2];
|
||||||
float tmin = 0.0f;
|
float tmin = 0.0f;
|
||||||
float tmax = 1.0f;
|
float tmax = 1.0f;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ freely, subject to the following restrictions:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Numerics;
|
|
||||||
|
|
||||||
namespace DotRecast.Core
|
namespace DotRecast.Core
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,9 +256,9 @@ namespace DotRecast.Detour
|
||||||
float t = isec.Item2;
|
float t = isec.Item2;
|
||||||
if (s >= 0.0f && s <= 1.0f && t >= 0.0f && t <= 1.0f)
|
if (s >= 0.0f && s <= 1.0f && t >= 0.0f && t <= 1.0f)
|
||||||
{
|
{
|
||||||
p[0] = a[0] + (b[0] - a[0]) * s;
|
p.x = a[0] + (b[0] - a[0]) * s;
|
||||||
p[1] = a[1] + (b[1] - a[1]) * s;
|
p.y = a[1] + (b[1] - a[1]) * s;
|
||||||
p[2] = a[2] + (b[2] - a[2]) * s;
|
p.z = a[2] + (b[2] - a[2]) * s;
|
||||||
return Intersection.Single;
|
return Intersection.Single;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -844,9 +844,9 @@ namespace DotRecast.Detour
|
||||||
if (bestvi != null && bestvj != null)
|
if (bestvi != null && bestvj != null)
|
||||||
{
|
{
|
||||||
var tangent = vSub(bestvi, bestvj);
|
var tangent = vSub(bestvi, bestvj);
|
||||||
hitNormal[0] = tangent[2];
|
hitNormal.x = tangent[2];
|
||||||
hitNormal[1] = 0;
|
hitNormal.y = 0;
|
||||||
hitNormal[2] = -tangent[0];
|
hitNormal.z = -tangent[0];
|
||||||
vNormalize(ref hitNormal);
|
vNormalize(ref hitNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,12 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
for (int i = 0; i < tile.data.verts.Length; i += 3)
|
for (int i = 0; i < tile.data.verts.Length; i += 3)
|
||||||
{
|
{
|
||||||
bmin[0] = Math.Min(bmin[0], tile.data.verts[i]);
|
bmin.x = Math.Min(bmin[0], tile.data.verts[i]);
|
||||||
bmin[1] = Math.Min(bmin[1], tile.data.verts[i + 1]);
|
bmin.y = Math.Min(bmin[1], tile.data.verts[i + 1]);
|
||||||
bmin[2] = Math.Min(bmin[2], tile.data.verts[i + 2]);
|
bmin.z = Math.Min(bmin[2], tile.data.verts[i + 2]);
|
||||||
bmax[0] = Math.Max(bmax[0], tile.data.verts[i]);
|
bmax.x = Math.Max(bmax[0], tile.data.verts[i]);
|
||||||
bmax[1] = Math.Max(bmax[1], tile.data.verts[i + 1]);
|
bmax.y = Math.Max(bmax[1], tile.data.verts[i + 1]);
|
||||||
bmax[2] = Math.Max(bmax[2], tile.data.verts[i + 2]);
|
bmax.z = Math.Max(bmax[2], tile.data.verts[i + 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,12 +118,16 @@ namespace DotRecast.Recast.Geom
|
||||||
int v0 = faces[i] * 3;
|
int v0 = faces[i] * 3;
|
||||||
int v1 = faces[i + 1] * 3;
|
int v1 = faces[i + 1] * 3;
|
||||||
int v2 = faces[i + 2] * 3;
|
int v2 = faces[i + 2] * 3;
|
||||||
Vector3f e0 = new Vector3f(), e1 = new Vector3f();
|
|
||||||
for (int j = 0; j < 3; ++j)
|
var e0 = new Vector3f();
|
||||||
{
|
var e1 = new Vector3f();
|
||||||
e0[j] = vertices[v1 + j] - vertices[v0 + j];
|
e0.x = vertices[v1 + 0] - vertices[v0 + 0];
|
||||||
e1[j] = vertices[v2 + j] - vertices[v0 + j];
|
e0.y = vertices[v1 + 1] - vertices[v0 + 1];
|
||||||
}
|
e0.z = vertices[v1 + 2] - vertices[v0 + 2];
|
||||||
|
|
||||||
|
e1.x = vertices[v2 + 0] - vertices[v0 + 0];
|
||||||
|
e1.y = vertices[v2 + 1] - vertices[v0 + 1];
|
||||||
|
e1.z = vertices[v2 + 2] - vertices[v0 + 2];
|
||||||
|
|
||||||
normals[i] = e0[1] * e1[2] - e0[2] * e1[1];
|
normals[i] = e0[1] * e1[2] - e0[2] * e1[1];
|
||||||
normals[i + 1] = e0[2] * e1[0] - e0[0] * e1[2];
|
normals[i + 1] = e0[2] * e1[0] - e0[0] * e1[2];
|
||||||
|
|
|
@ -58,9 +58,9 @@ namespace DotRecast.Recast
|
||||||
Vector3f[] vs = new Vector3f[3];
|
Vector3f[] vs = new Vector3f[3];
|
||||||
for (int k = 0; k < 3; ++k)
|
for (int k = 0; k < 3; ++k)
|
||||||
{
|
{
|
||||||
vs[k][0] = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3];
|
vs[k].x = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3];
|
||||||
vs[k][1] = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 1];
|
vs[k].y = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 1];
|
||||||
vs[k][2] = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 2];
|
vs[k].z = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
float? intersection = Intersections.intersectSegmentTriangle(sp, sq, vs[0], vs[1], vs[2]);
|
float? intersection = Intersections.intersectSegmentTriangle(sp, sq, vs[0], vs[1], vs[2]);
|
||||||
|
|
|
@ -58,10 +58,10 @@ namespace DotRecast.Recast
|
||||||
{
|
{
|
||||||
float tsx = cfg.tileSizeX * cfg.cs;
|
float tsx = cfg.tileSizeX * cfg.cs;
|
||||||
float tsz = cfg.tileSizeZ * cfg.cs;
|
float tsz = cfg.tileSizeZ * cfg.cs;
|
||||||
this.bmin[0] += tileX * tsx;
|
this.bmin.x += tileX * tsx;
|
||||||
this.bmin[2] += tileZ * tsz;
|
this.bmin.z += tileZ * tsz;
|
||||||
this.bmax[0] = this.bmin[0] + tsx;
|
this.bmax.x = this.bmin[0] + tsx;
|
||||||
this.bmax[2] = this.bmin[2] + tsz;
|
this.bmax.z = this.bmin[2] + tsz;
|
||||||
// Expand the heighfield bounding box by border size to find the extents of geometry we need to build this
|
// Expand the heighfield bounding box by border size to find the extents of geometry we need to build this
|
||||||
// tile.
|
// tile.
|
||||||
//
|
//
|
||||||
|
@ -85,10 +85,10 @@ namespace DotRecast.Recast
|
||||||
// you will need to pass in data from neighbour terrain tiles too! In a simple case, just pass in all the 8
|
// you will need to pass in data from neighbour terrain tiles too! In a simple case, just pass in all the 8
|
||||||
// neighbours,
|
// neighbours,
|
||||||
// or use the bounding box below to only pass in a sliver of each of the 8 neighbours.
|
// or use the bounding box below to only pass in a sliver of each of the 8 neighbours.
|
||||||
this.bmin[0] -= cfg.borderSize * cfg.cs;
|
this.bmin.x -= cfg.borderSize * cfg.cs;
|
||||||
this.bmin[2] -= cfg.borderSize * cfg.cs;
|
this.bmin.z -= cfg.borderSize * cfg.cs;
|
||||||
this.bmax[0] += cfg.borderSize * cfg.cs;
|
this.bmax.x += cfg.borderSize * cfg.cs;
|
||||||
this.bmax[2] += cfg.borderSize * cfg.cs;
|
this.bmax.z += cfg.borderSize * cfg.cs;
|
||||||
width = cfg.tileSizeX + cfg.borderSize * 2;
|
width = cfg.tileSizeX + cfg.borderSize * 2;
|
||||||
height = cfg.tileSizeZ + cfg.borderSize * 2;
|
height = cfg.tileSizeZ + cfg.borderSize * 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,30 +27,30 @@ namespace DotRecast.Recast
|
||||||
{
|
{
|
||||||
public static void min(ref Vector3f a, float[] b, int i)
|
public static void min(ref Vector3f a, float[] b, int i)
|
||||||
{
|
{
|
||||||
a[0] = Math.Min(a[0], b[i + 0]);
|
a.x = Math.Min(a[0], b[i + 0]);
|
||||||
a[1] = Math.Min(a[1], b[i + 1]);
|
a.y = Math.Min(a[1], b[i + 1]);
|
||||||
a[2] = Math.Min(a[2], b[i + 2]);
|
a.z = Math.Min(a[2], b[i + 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void min(ref Vector3f a, Vector3f b, int i)
|
public static void min(ref Vector3f a, Vector3f b, int i)
|
||||||
{
|
{
|
||||||
a[0] = Math.Min(a[0], b[i + 0]);
|
a.x = Math.Min(a[0], b[i + 0]);
|
||||||
a[1] = Math.Min(a[1], b[i + 1]);
|
a.y = Math.Min(a[1], b[i + 1]);
|
||||||
a[2] = Math.Min(a[2], b[i + 2]);
|
a.z = Math.Min(a[2], b[i + 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void max(ref Vector3f a, float[] b, int i)
|
public static void max(ref Vector3f a, float[] b, int i)
|
||||||
{
|
{
|
||||||
a[0] = Math.Max(a[0], b[i + 0]);
|
a.x = Math.Max(a[0], b[i + 0]);
|
||||||
a[1] = Math.Max(a[1], b[i + 1]);
|
a.y = Math.Max(a[1], b[i + 1]);
|
||||||
a[2] = Math.Max(a[2], b[i + 2]);
|
a.z = Math.Max(a[2], b[i + 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void max(ref Vector3f a, Vector3f b, int i)
|
public static void max(ref Vector3f a, Vector3f b, int i)
|
||||||
{
|
{
|
||||||
a[0] = Math.Max(a[0], b[i + 0]);
|
a.x = Math.Max(a[0], b[i + 0]);
|
||||||
a[1] = Math.Max(a[1], b[i + 1]);
|
a.y = Math.Max(a[1], b[i + 1]);
|
||||||
a[2] = Math.Max(a[2], b[i + 2]);
|
a.z = Math.Max(a[2], b[i + 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void copy(ref Vector3f @out, float[] @in, int i)
|
public static void copy(ref Vector3f @out, float[] @in, int i)
|
||||||
|
@ -103,25 +103,25 @@ namespace DotRecast.Recast
|
||||||
|
|
||||||
public static void add(ref Vector3f e0, Vector3f a, float[] verts, int i)
|
public static void add(ref Vector3f e0, Vector3f a, float[] verts, int i)
|
||||||
{
|
{
|
||||||
e0[0] = a[0] + verts[i];
|
e0.x = a[0] + verts[i];
|
||||||
e0[1] = a[1] + verts[i + 1];
|
e0.y = a[1] + verts[i + 1];
|
||||||
e0[2] = a[2] + verts[i + 2];
|
e0.z = a[2] + verts[i + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sub(ref Vector3f e0, float[] verts, int i, int j)
|
public static void sub(ref Vector3f e0, float[] verts, int i, int j)
|
||||||
{
|
{
|
||||||
e0[0] = verts[i] - verts[j];
|
e0.x = verts[i] - verts[j];
|
||||||
e0[1] = verts[i + 1] - verts[j + 1];
|
e0.y = verts[i + 1] - verts[j + 1];
|
||||||
e0[2] = verts[i + 2] - verts[j + 2];
|
e0.z = verts[i + 2] - verts[j + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sub(ref Vector3f e0, Vector3f i, float[] verts, int j)
|
public static void sub(ref Vector3f e0, Vector3f i, float[] verts, int j)
|
||||||
{
|
{
|
||||||
e0[0] = i[0] - verts[j];
|
e0.x = i[0] - verts[j];
|
||||||
e0[1] = i[1] - verts[j + 1];
|
e0.y = i[1] - verts[j + 1];
|
||||||
e0[2] = i[2] - verts[j + 2];
|
e0.z = i[2] - verts[j + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,9 +141,9 @@ namespace DotRecast.Recast
|
||||||
|
|
||||||
public static void cross(ref Vector3f dest, Vector3f v1, Vector3f v2)
|
public static void cross(ref Vector3f dest, Vector3f v1, Vector3f v2)
|
||||||
{
|
{
|
||||||
dest[0] = v1[1] * v2[2] - v1[2] * v2[1];
|
dest.x = v1[1] * v2[2] - v1[2] * v2[1];
|
||||||
dest[1] = v1[2] * v2[0] - v1[0] * v2[2];
|
dest.y = v1[2] * v2[0] - v1[0] * v2[2];
|
||||||
dest[2] = v1[0] * v2[1] - v1[1] * v2[0];
|
dest.z = v1[0] * v2[1] - v1[1] * v2[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,9 +158,9 @@ namespace DotRecast.Recast
|
||||||
public static void normalize(ref Vector3f v)
|
public static void normalize(ref Vector3f v)
|
||||||
{
|
{
|
||||||
float d = (float)(1.0f / Math.Sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]));
|
float d = (float)(1.0f / Math.Sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]));
|
||||||
v[0] *= d;
|
v.x *= d;
|
||||||
v[1] *= d;
|
v.y *= d;
|
||||||
v[2] *= d;
|
v.z *= d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float dot(float[] v1, float[] v2)
|
public static float dot(float[] v1, float[] v2)
|
||||||
|
|
Loading…
Reference in New Issue