public bool FindRandomPoint(ref Vector3 resultPoint) { NavimeshStatus status = (NavimeshStatus)RecastDll.FindRandomPoint(this.recastPtr, this.resultPos); if (this.IsSuccessStatus(status)) { resultPoint.Set(this.resultPos[0], this.resultPos[1], this.resultPos[2]); return(true); } return(false); }
public bool FindRandomPointAroundCircle(ref Vector3 center, float radius, ref Vector3 resultPoint) { this.Vector3ToArray(ref center, this.startPos); NavimeshStatus status = (NavimeshStatus)RecastDll.FindRandomPointAroundCircle(this.recastPtr, this.startPos, radius, this.resultPos); if (this.IsSuccessStatus(status)) { resultPoint.Set(this.resultPos[0], this.resultPos[1], this.resultPos[2]); return(true); } return(false); }
public bool Raycast(ref Vector3 startPoint, ref Vector3 endPoint, ref Vector3 hitPoint) { this.Vector3ToArray(ref startPoint, this.startPos); this.Vector3ToArray(ref endPoint, this.endPos); NavimeshStatus status = (NavimeshStatus)RecastDll.Raycast(this.recastPtr, this.startPos, this.endPos, this.resultPos); if (this.IsSuccessStatus(status)) { hitPoint.Set(this.resultPos[0], this.resultPos[1], this.resultPos[2]); return(true); } return(false); }
/// <summary> /// 路径点少,无平滑 /// </summary> public bool FindStraightPath(Vector3 startPos, Vector3 endPos, List <Vector3> path) { this.Vector3ToArray(ref startPos, this.startPos); this.Vector3ToArray(ref endPos, this.endPos); NavimeshStatus status = (NavimeshStatus)RecastDll.FindStraightPath(this.recastPtr, this.startPos, this.endPos, this.straightPath, ref this.straigntCount); if (this.IsSuccessStatus(status)) { path.Clear(); int count = this.straigntCount * 3; Debug.Assert(this.straightPath.Length >= count); for (int i = 0; i < count; i += 3) { Vector3 point = new Vector3(this.straightPath[i], this.straightPath[i + 1], this.straightPath[i + 2]); path.Add(point); } return(true); } return(false); }
private bool IsSuccessStatus(NavimeshStatus status) { return((status & NavimeshStatus.DT_SUCCESS) != 0); }