本文整理汇总了C#中ModifierData类的典型用法代码示例。如果您正苦于以下问题:C# ModifierData类的具体用法?C# ModifierData怎么用?C# ModifierData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModifierData类属于命名空间,在下文中一共展示了ModifierData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public override void Apply(Path p, ModifierData source)
{
Node[] path = p.path;
Vector3[] vectorPath = p.vectorPath;
if (path == null || path.Length == 0 || vectorPath == null || vectorPath.Length != path.Length) {
return;
}
//The graph index for the current nodes
int currentGraphIndex = path[0].graphIndex;
//First node which is in the graph currentGraphIndex
int currentGraphStart = 0;
List<Vector3> funnelPath = new List<Vector3> ();
List<Vector3> left = new List<Vector3> ();
List<Vector3> right = new List<Vector3> ();
for (int i=0;i<path.Length;i++) {
if (path[i].graphIndex != currentGraphIndex) {
IFunnelGraph funnelGraph = AstarData.GetGraph (path[currentGraphStart]) as IFunnelGraph;
if (funnelGraph == null) {
//Debug.Log ("Funnel Graph is null");
for (int j=currentGraphStart;j<=i;j++) {
funnelPath.Add ((Vector3)path[j].position);
}
} else {
ConstructFunnel (funnelGraph, vectorPath,path,currentGraphStart,i-1,funnelPath,left,right);
}
currentGraphIndex = path[i].graphIndex;
currentGraphStart = i;
}
}
IFunnelGraph funnelGraph2 = AstarData.GetGraph (path[currentGraphStart]) as IFunnelGraph;
if (funnelGraph2 == null) {
for (int j=currentGraphStart;j<path.Length-1;j++) {
funnelPath.Add ((Vector3)path[j].position);
}
} else {
ConstructFunnel (funnelGraph2, vectorPath,path,currentGraphStart,path.Length-1,funnelPath,left,right);
}
p.vectorPath = funnelPath.ToArray ();
#if DEBUG
for (int i=0;i<p.vectorPath.Length-1;i++) {
Debug.DrawLine (p.vectorPath[i]+Vector3.up,p.vectorPath[i+1]+Vector3.up,Color.magenta);
}
#endif
}
示例2: Apply
public override void Apply (Path p, ModifierData source) {
lock (lockObject) {
toBeApplied = p.path;
//AstarPath.active.RegisterCanUpdateGraphs (ApplyNow);
if (!waitingForApply) {
waitingForApply = true;
AstarPath.OnPathPreSearch += ApplyNow;
}
}
}
示例3: Apply
public override void Apply (Path p, ModifierData source) {
List<GraphNode> path = p.path;
List<Vector3> vectorPath = p.vectorPath;
if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count) {
return;
}
List<Vector3> funnelPath = ListPool<Vector3>.Claim ();
// Claim temporary lists and try to find lists with a high capacity
List<Vector3> left = ListPool<Vector3>.Claim (path.Count+1);
List<Vector3> right = ListPool<Vector3>.Claim (path.Count+1);
AstarProfiler.StartProfile ("Construct Funnel");
// Enqueue start point
left.Add (vectorPath[0]);
right.Add (vectorPath[0]);
// Loop through all nodes in the path (except the last one)
for (int i=0;i<path.Count-1;i++) {
// Get the portal between path[i] and path[i+1] and add it to the left and right lists
bool portalWasAdded = path[i].GetPortal (path[i+1], left, right, false);
if (!portalWasAdded) {
// Fallback, just use the positions of the nodes
left.Add ((Vector3)path[i].position);
right.Add ((Vector3)path[i].position);
left.Add ((Vector3)path[i+1].position);
right.Add ((Vector3)path[i+1].position);
}
}
// Enqueue end point
left.Add (vectorPath[vectorPath.Count-1]);
right.Add (vectorPath[vectorPath.Count-1]);
if (!RunFunnel (left,right,funnelPath)) {
// If funnel algorithm failed, degrade to simple line
funnelPath.Add (vectorPath[0]);
funnelPath.Add (vectorPath[vectorPath.Count-1]);
}
// Release lists back to the pool
ListPool<Vector3>.Release (p.vectorPath);
p.vectorPath = funnelPath;
ListPool<Vector3>.Release (left);
ListPool<Vector3>.Release (right);
}
示例4: Apply
public override void Apply (Path p, ModifierData source) {
if (this == null) return;
lock (lockObject) {
toBeApplied = p.path.ToArray();
if (!waitingForApply) {
waitingForApply = true;
AstarPath.OnPathPreSearch += ApplyNow;
}
}
}
示例5: Apply
public override void Apply (Path p, ModifierData source) {
var path = p.path;
var vectorPath = p.vectorPath;
if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count) {
return;
}
var funnelPath = ListPool<Vector3>.Claim ();
//Claim temporary lists and try to find lists with a high capacity
var left = ListPool<Vector3>.Claim (path.Count+1);
var right = ListPool<Vector3>.Claim (path.Count+1);
AstarProfiler.StartProfile ("Construct Funnel");
left.Add (vectorPath[0]);
right.Add (vectorPath[0]);
for (var i=0;i<path.Count-1;i++) {
var a = path[i].GetPortal (path[i+1], left, right, false);
var b = false;//path[i+1].GetPortal (path[i], right, left, true);
if (!a && !b) {
left.Add ((Vector3)path[i].position);
right.Add ((Vector3)path[i].position);
left.Add ((Vector3)path[i+1].position);
right.Add ((Vector3)path[i+1].position);
}
}
left.Add (vectorPath[vectorPath.Count-1]);
right.Add (vectorPath[vectorPath.Count-1]);
if (!RunFunnel (left,right,funnelPath)) {
//If funnel algorithm failed, degrade to simple line
funnelPath.Add (vectorPath[0]);
funnelPath.Add (vectorPath[vectorPath.Count-1]);
}
ListPool<Vector3>.Release (p.vectorPath);
p.vectorPath = funnelPath;
ListPool<Vector3>.Release (left);
ListPool<Vector3>.Release (right);
}
示例6: Apply
public override void Apply(Path p, ModifierData source)
{
if (this == null)
{
return;
}
object obj = this.lockObject;
lock (obj)
{
this.toBeApplied = p.path.ToArray();
if (!this.waitingForApply)
{
this.waitingForApply = true;
AstarPath.OnPathPreSearch = (OnPathDelegate)Delegate.Combine(AstarPath.OnPathPreSearch, new OnPathDelegate(this.ApplyNow));
}
}
}
示例7: Apply
public override void Apply (Path p, ModifierData source) {
//This should never trigger unless some other modifier has messed stuff up
if (p.vectorPath == null) {
Debug.LogWarning ("Can't process NULL path (has another modifier logged an error?)");
return;
}
Vector3[] path = p.vectorPath;
switch (smoothType) {
case SmoothType.Simple:
p.vectorPath = SmoothSimple (path); break;
case SmoothType.Bezier:
p.vectorPath = SmoothBezier (path); break;
case SmoothType.OffsetSimple:
p.vectorPath = SmoothOffsetSimple (path); break;
case SmoothType.CurvedNonuniform:
p.vectorPath = CurvedNonuniform (path); break;
}
}
示例8: CanConvertTo
public static ModifierData CanConvertTo(ModifierData a)
{
if (a == ModifierData.All)
{
return ModifierData.All;
}
ModifierData modifierData = a;
if (ModifierConverter.AnyBits(a, ModifierData.Nodes))
{
modifierData |= ModifierData.VectorPath;
}
if (ModifierConverter.AnyBits(a, ModifierData.StrictNodePath))
{
modifierData |= ModifierData.StrictVectorPath;
}
if (ModifierConverter.AnyBits(a, ModifierData.StrictVectorPath))
{
modifierData |= ModifierData.VectorPath;
}
return modifierData;
}
示例9: Convert
public static ModifierData Convert(Path p, ModifierData input, ModifierData output)
{
if (!ModifierConverter.CanConvert(input, output))
{
Debug.LogError(string.Concat(new object[]
{
"Can't convert ",
input,
" to ",
output
}));
return ModifierData.None;
}
if (ModifierConverter.AnyBits(input, output))
{
return input;
}
if (ModifierConverter.AnyBits(input, ModifierData.Nodes) && ModifierConverter.AnyBits(output, ModifierData.Vector))
{
p.vectorPath.Clear();
for (int i = 0; i < p.vectorPath.Count; i++)
{
p.vectorPath.Add((Vector3)p.path[i].position);
}
return ModifierData.VectorPath | ((!ModifierConverter.AnyBits(input, ModifierData.StrictNodePath)) ? ModifierData.None : ModifierData.StrictVectorPath);
}
Debug.LogError(string.Concat(new object[]
{
"This part should not be reached - Error in ModifierConverted\nInput: ",
input,
" (",
(int)input,
")\nOutput: ",
output,
" (",
(int)output,
")"
}));
return ModifierData.None;
}
示例10: Convert
/** Converts a path from \a input to \a output */
public static ModifierData Convert (Path p, ModifierData input, ModifierData output) {
//"Input" can not be converted to "output", log error
if (!CanConvert (input,output)) {
Debug.LogError ("Can't convert "+input+" to "+output);
return ModifierData.None;
}
//"Output" can take "input" with no change, return
if (AnyBits (input,output)) {
return input;
}
//If input is a node path, and output wants a vector array, convert the node array to a vector array
if (AnyBits (input,ModifierData.Nodes) && AnyBits (output, ModifierData.Vector)) {
p.vectorPath.Clear();
for (var i=0;i<p.vectorPath.Count;i++) {
p.vectorPath.Add ((Vector3)p.path[i].position);
}
//Return VectorPath and also StrictVectorPath if input has StrictNodePath set
return ModifierData.VectorPath | (AnyBits (input, ModifierData.StrictNodePath) ? ModifierData.StrictVectorPath : ModifierData.None);
}
Debug.LogError ("This part should not be reached - Error in ModifierConverted\nInput: "+input+" ("+(int)input+")\nOutput: "+output+" ("+(int)output+")");
return ModifierData.None;
}
示例11: AnyBits
/** Returns If \a a and \a b has any bits in common */
public static bool AnyBits (ModifierData a, ModifierData b) {
return (a & b) != 0;
}
示例12: AllBits
/** Returns If \a a has all bits that \a b has set to true, also set to true */
public static bool AllBits (ModifierData a, ModifierData b) {
return (a & b) == b;
}
示例13: Apply
/** Main Post-Processing function */
public abstract void Apply (Path p, ModifierData source);
示例14: GetClampedPoint
/*public override void ApplyOriginal (Path p) {
if (exactStartPoint) {
pStart = GetClampedPoint (p.path[0].position, p.originalStartPoint, p.path[0]);
if (!addPoints) {
p.startPoint = pStart;
}
}
if (exactEndPoint) {
pEnd = GetClampedPoint (p.path[p.path.Length-1].position, p.originalEndPoint, p.path[p.path.Length-1]);
if (!addPoints) {
p.endPoint = pEnd;
}
}
}*/
public override void Apply (Path _p, ModifierData source) {
ABPath p = _p as ABPath;
//Only for ABPaths
if (p == null) return;
if (p.vectorPath.Count == 0) {
return;
} else if (p.vectorPath.Count < 2 && !addPoints) {
//Vector3[] arr = new Vector3[2];
//arr[0] = p.vectorPath[0];
//arr[1] = p.vectorPath[0];
//p.vectorPath = arr;
p.vectorPath.Add (p.vectorPath[0]);
}
//Debug.DrawRay (p.originalEndPoint,Vector3.up,Color.red);
//Debug.DrawRay (p.startPoint,Vector3.up,Color.red);
//Debug.DrawRay (p.endPoint,Vector3.up,Color.green);
Vector3 pStart = Vector3.zero,
pEnd = Vector3.zero;
if (exactStartPoint == Exactness.Original) {
pStart = GetClampedPoint ((Vector3)p.path[0].position, p.originalStartPoint, p.path[0]);
} else if (exactStartPoint == Exactness.ClosestOnNode) {
pStart = GetClampedPoint ((Vector3)p.path[0].position, p.startPoint, p.path[0]);
} else if (exactStartPoint == Exactness.Interpolate) {
pStart = GetClampedPoint ((Vector3)p.path[0].position, p.originalStartPoint, p.path[0]);
pStart = Mathfx.NearestPointStrict ((Vector3)p.path[0].position,(Vector3)p.path[1>=p.path.Count?0:1].position,pStart);
} else {
pStart = (Vector3)p.path[0].position;
}
if (exactEndPoint == Exactness.Original) {
pEnd = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.originalEndPoint, p.path[p.path.Count-1]);
} else if (exactEndPoint == Exactness.ClosestOnNode) {
pEnd = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.endPoint, p.path[p.path.Count-1]);
} else if (exactEndPoint == Exactness.Interpolate) {
pEnd = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.originalEndPoint, p.path[p.path.Count-1]);
pEnd = Mathfx.NearestPointStrict ((Vector3)p.path[p.path.Count-1].position,(Vector3)p.path[p.path.Count-2<0?0:p.path.Count-2].position,pEnd);
} else {
pEnd = (Vector3)p.path[p.path.Count-1].position;
}
if (!addPoints) {
//p.vectorPath[0] = p.startPoint;
//p.vectorPath[p.vectorPath.Length-1] = p.endPoint;
//Debug.DrawLine (p.vectorPath[0],pStart,Color.green);
//Debug.DrawLine (p.vectorPath[p.vectorPath.Length-1],pEnd,Color.green);
p.vectorPath[0] = pStart;
p.vectorPath[p.vectorPath.Count-1] = pEnd;
} else {
//Vector3[] newPath = new Vector3[p.vectorPath.Length+(exactStartPoint != Exactness.SnapToNode ? 1 : 0) + (exactEndPoint != Exactness.SnapToNode ? 1 : 0)];
if (exactStartPoint != Exactness.SnapToNode) {
//newPath[0] = pStart;
p.vectorPath.Insert (0,pStart);
}
if (exactEndPoint != Exactness.SnapToNode) {
//newPath[newPath.Length-1] = pEnd;
p.vectorPath.Add (pEnd);
}
/*int offset = exactStartPoint != Exactness.SnapToNode ? 1 : 0;
for (int i=0;i<p.vectorPath.Length;i++) {
newPath[i+offset] = p.vectorPath[i];
}
p.vectorPath = newPath;*/
}
}
示例15: Apply
public override void Apply (Path p, ModifierData source) {
//This should never trigger unless some other modifier has messed stuff up
if (p.vectorPath == null) {
Debug.LogWarning ("Can't process NULL path (has another modifier logged an error?)");
return;
}
List<Vector3> path = null;
switch (smoothType) {
case SmoothType.Simple:
path = SmoothSimple (p.vectorPath); break;
case SmoothType.Bezier:
path = SmoothBezier (p.vectorPath); break;
case SmoothType.OffsetSimple:
path = SmoothOffsetSimple (p.vectorPath); break;
case SmoothType.CurvedNonuniform:
path = CurvedNonuniform (p.vectorPath); break;
}
if (path != p.vectorPath) {
ListPool<Vector3>.Release (p.vectorPath);
p.vectorPath = path;
}
//.vectorPath.Clear ();
//p.vectorPath.AddRange (path);
}