remove Vector3 vSet

This commit is contained in:
ikpil 2023-04-12 23:33:15 +09:00
parent 066f6b3f34
commit b1b2bb9e3e
5 changed files with 16 additions and 23 deletions

View File

@ -19,6 +19,7 @@ freely, subject to the following restrictions:
*/ */
using System; using System;
using System.Numerics;
namespace DotRecast.Core namespace DotRecast.Core
{ {
@ -227,13 +228,6 @@ namespace DotRecast.Core
@out.y = @in[1]; @out.y = @in[1];
@out.z = @in[2]; @out.z = @in[2];
} }
public static void vCopy(float[] @out, float[] @in, int i)
{
@out[0] = @in[i];
@out[1] = @in[i + 1];
@out[2] = @in[i + 2];
}
public static void vCopy(ref Vector3f @out, float[] @in, int i) public static void vCopy(ref Vector3f @out, float[] @in, int i)
{ {

View File

@ -28,6 +28,7 @@ namespace DotRecast.Core
public float z { get; set; } public float z { get; set; }
public static Vector3f Zero { get; } = new Vector3f(0, 0, 0); public static Vector3f Zero { get; } = new Vector3f(0, 0, 0);
public static Vector3f Up { get; } = new Vector3f(0, 1, 0);
public static Vector3f Of(float[] f) public static Vector3f Of(float[] f)
{ {

View File

@ -254,9 +254,9 @@ namespace DotRecast.Detour.Crowd
ag.topologyOptTime = 0; ag.topologyOptTime = 0;
ag.targetReplanTime = 0; ag.targetReplanTime = 0;
vSet(ref ag.dvel, 0, 0, 0); ag.dvel = Vector3f.Zero;
vSet(ref ag.nvel, 0, 0, 0); ag.nvel = Vector3f.Zero;
vSet(ref ag.vel, 0, 0, 0); ag.vel = Vector3f.Zero;
vCopy(ref ag.npos, nearest); vCopy(ref ag.npos, nearest);
ag.desiredSpeed = 0; ag.desiredSpeed = 0;
@ -340,8 +340,8 @@ namespace DotRecast.Detour.Crowd
{ {
// Initialize request. // Initialize request.
agent.targetRef = 0; agent.targetRef = 0;
vSet(ref agent.targetPos, 0, 0, 0); agent.targetPos = Vector3f.Zero;
vSet(ref agent.dvel, 0, 0, 0); agent.dvel = Vector3f.Zero;
agent.targetPathQueryResult = null; agent.targetPathQueryResult = null;
agent.targetReplan = false; agent.targetReplan = false;
agent.targetState = CrowdAgent.MoveRequestState.DT_CROWDAGENT_TARGET_NONE; agent.targetState = CrowdAgent.MoveRequestState.DT_CROWDAGENT_TARGET_NONE;
@ -974,8 +974,8 @@ namespace DotRecast.Detour.Crowd
// Copy data for debug purposes. // Copy data for debug purposes.
if (debugAgent == ag) if (debugAgent == ag)
{ {
vSet(ref debug.optStart, 0, 0, 0); debug.optStart = Vector3f.Zero;
vSet(ref debug.optEnd, 0, 0, 0); debug.optEnd = Vector3f.Zero;
} }
} }
} }
@ -1234,7 +1234,7 @@ namespace DotRecast.Detour.Crowd
continue; continue;
} }
vSet(ref ag.disp, 0, 0, 0); ag.disp = Vector3f.Zero;
float w = 0; float w = 0;
@ -1361,8 +1361,8 @@ namespace DotRecast.Detour.Crowd
} }
// Update velocity. // Update velocity.
vSet(ref ag.vel, 0, 0, 0); ag.vel = Vector3f.Zero;
vSet(ref ag.dvel, 0, 0, 0); ag.dvel = Vector3f.Zero;
} }
_telemetry.stop("updateOffMeshConnections"); _telemetry.stop("updateOffMeshConnections");

View File

@ -149,7 +149,7 @@ namespace DotRecast.Detour.Crowd
if (vLen(vel) > 0.0001f) if (vLen(vel) > 0.0001f)
npos = vMad(npos, vel, dt); npos = vMad(npos, vel, dt);
else else
vSet(ref vel, 0, 0, 0); vel = Vector3f.Zero;
} }
public bool overOffmeshConnection(float radius) public bool overOffmeshConnection(float radius)

View File

@ -401,8 +401,7 @@ namespace DotRecast.Detour.Crowd
m_vmax = vmax; m_vmax = vmax;
m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue; m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue;
Vector3f nvel = new Vector3f(); Vector3f nvel = Vector3f.Zero;
vSet(ref nvel, 0f, 0f, 0f);
if (debug != null) if (debug != null)
debug.reset(); debug.reset();
@ -472,8 +471,7 @@ namespace DotRecast.Detour.Crowd
m_vmax = vmax; m_vmax = vmax;
m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue; m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue;
Vector3f nvel = new Vector3f(); Vector3f nvel = Vector3f.Zero;
vSet(ref nvel, 0f, 0f, 0f);
if (debug != null) if (debug != null)
debug.reset(); debug.reset();
@ -546,7 +544,7 @@ namespace DotRecast.Detour.Crowd
{ {
float minPenalty = float.MaxValue; float minPenalty = float.MaxValue;
Vector3f bvel = new Vector3f(); Vector3f bvel = new Vector3f();
vSet(ref bvel, 0, 0, 0); bvel = Vector3f.Zero;
for (int i = 0; i < npat; ++i) for (int i = 0; i < npat; ++i)
{ {