Skip to content

Commit

Permalink
Removed RcVecUtils.Scale()
Browse files Browse the repository at this point in the history
  • Loading branch information
ikpil committed Jun 7, 2024
1 parent 0f20db4 commit b18845a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Removed
- Removed RcVecUtils.Dot()
- Removed RcVecUtils.Scale()

### Special Thanks
- [@Doprez](https://github.com/Doprez)
Expand Down
6 changes: 0 additions & 6 deletions src/DotRecast.Core/Numerics/RcVecUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ public static float Get(this RcVec3f v, int i)
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Scale(this RcVec3f v, float scale)
{
return v * scale;
}

/// Derives the dot product of two vectors on the xz-plane. (@p u . @p v)
/// @param[in] u A vector [(x, y, z)]
/// @param[in] v A vector [(x, y, z)]
Expand Down
6 changes: 3 additions & 3 deletions src/DotRecast.Detour.Crowd/DtCrowd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ private void CalculateSteering(IList<DtCrowdAgent> agents)
float speedScale = ag.GetDistanceToGoal(slowDownRadius) / slowDownRadius;

ag.desiredSpeed = ag.option.maxSpeed;
dvel = dvel.Scale(ag.desiredSpeed * speedScale);
dvel = dvel * (ag.desiredSpeed * speedScale);
}

// Separation
Expand Down Expand Up @@ -1110,7 +1110,7 @@ private void CalculateSteering(IList<DtCrowdAgent> agents)
float desiredSqr = RcMath.Sqr(ag.desiredSpeed);
if (speedSqr > desiredSqr)
{
dvel = dvel.Scale(desiredSqr / speedSqr);
dvel = dvel * (desiredSqr / speedSqr);
}
}
}
Expand Down Expand Up @@ -1268,7 +1268,7 @@ private void HandleCollisions(IList<DtCrowdAgent> agents)
if (w > 0.0001f)
{
float iw = 1.0f / w;
ag.disp = ag.disp.Scale(iw);
ag.disp = ag.disp * iw;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/DotRecast.Detour.Crowd/DtCrowdAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public class DtCrowdAgent

/// The local path corridor corners for the agent.
public DtStraightPath[] corners = new DtStraightPath[DtCrowdConst.DT_CROWDAGENT_MAX_CORNERS];

/// The number of corners.
public int ncorners;

public DtMoveRequestState targetState; // < State of the movement request.
public long targetRef; // < Target polyref of the movement request.
public RcVec3f targetPos = new RcVec3f(); // < Target position of the movement request (or velocity in case of DT_CROWDAGENT_TARGET_VELOCITY).
Expand All @@ -91,7 +91,7 @@ public void Integrate(float dt)
RcVec3f dv = RcVec3f.Subtract(nvel, vel);
float ds = dv.Length();
if (ds > maxDelta)
dv = dv.Scale(maxDelta / ds);
dv = dv * (maxDelta / ds);
vel = RcVec3f.Add(vel, dv);

// Integrate
Expand Down Expand Up @@ -150,7 +150,7 @@ public RcVec3f CalcSmoothSteerDirection()
float len0 = dir0.Length();
float len1 = dir1.Length();
if (len1 > 0.001f)
dir1 = dir1.Scale(1.0f / len1);
dir1 = dir1 * (1.0f / len1);

dir.X = dir0.X - dir1.X * len0 * 0.5f;
dir.Y = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/DotRecast.Detour.Crowd/DtObstacleAvoidanceQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private float ProcessSample(RcVec3f vcand, float cs, RcVec3f pos, float rad, RcV
DtObstacleCircle cir = m_circles[i];

// RVO
RcVec3f vab = vcand.Scale(2);
RcVec3f vab = vcand * 2;
vab = RcVec3f.Subtract(vab, vel);
vab = RcVec3f.Subtract(vab, cir.vel);

Expand Down
2 changes: 1 addition & 1 deletion src/DotRecast.Recast.Toolset/Tools/RcCrowdTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private RcVec3f CalcVel(RcVec3f pos, RcVec3f tgt, float speed)
RcVec3f vel = RcVec3f.Subtract(tgt, pos);
vel.Y = 0.0f;
vel = RcVec3f.Normalize(vel);
return vel.Scale(speed);
return vel * speed;
}

public long GetCrowdUpdateTime()
Expand Down
2 changes: 1 addition & 1 deletion test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected RcVec3f CalcVel(RcVec3f pos, RcVec3f tgt, float speed)
RcVec3f vel = RcVec3f.Subtract(tgt, pos);
vel.Y = 0.0f;
vel = RcVec3f.Normalize(vel);
vel = vel.Scale(speed);
vel = vel * speed;
return vel;
}

Expand Down

0 comments on commit b18845a

Please sign in to comment.