本文整理汇总了C#中FastList.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# FastList.Clear方法的具体用法?C# FastList.Clear怎么用?C# FastList.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FastList
的用法示例。
在下文中一共展示了FastList.Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportAnimation
//.........这里部分代码省略.........
{
foreach (CompressedTimeSpan time in curve.Keys)
{
animationKeysSet.Add(time);
}
}
}
// Sort key times
var animationKeys = animationKeysSet.ToList();
animationKeys.Sort();
var animationOperations = new FastList<AnimationOperation>();
var combinedAnimationClip = new AnimationClip();
var translationCurve = new AnimationCurve<Vector3>();
var rotationCurve = new AnimationCurve<Quaternion>();
var scaleCurve = new AnimationCurve<Vector3>();
// Evaluate at every key frame
foreach (var animationKey in animationKeys)
{
var matrix = Matrix.Identity;
// Evaluate node
foreach (var node in nodesToMerge)
{
// Get default position
var modelNodeDefinition = node.Item1;
// Compute
AnimationClipResult animationClipResult = null;
animationOperations.Clear();
animationOperations.Add(AnimationOperation.NewPush(node.Item3, animationKey));
node.Item2.Compute(animationOperations, ref animationClipResult);
var updateMemberInfos = new List<UpdateMemberInfo>();
foreach (var channel in animationClipResult.Channels)
updateMemberInfos.Add(new UpdateMemberInfo { Name = channel.PropertyName, DataOffset = channel.Offset });
// TODO: Cache this
var compiledUpdate = UpdateEngine.Compile(typeof(ModelNodeDefinition), updateMemberInfos);
unsafe
{
fixed (byte* data = animationClipResult.Data)
UpdateEngine.Run(modelNodeDefinition, compiledUpdate, (IntPtr)data, null);
}
Matrix localMatrix;
TransformComponent.CreateMatrixTRS(ref modelNodeDefinition.Transform.Position, ref modelNodeDefinition.Transform.Rotation, ref modelNodeDefinition.Transform.Scale,
out localMatrix);
matrix = Matrix.Multiply(localMatrix, matrix);
}
// Done evaluating, let's decompose matrix
TransformTRS transform;
matrix.Decompose(out transform.Scale, out transform.Rotation, out transform.Position);
// Create a key
translationCurve.KeyFrames.Add(new KeyFrameData<Vector3>(animationKey, transform.Position));
rotationCurve.KeyFrames.Add(new KeyFrameData<Quaternion>(animationKey, transform.Rotation));
scaleCurve.KeyFrames.Add(new KeyFrameData<Vector3>(animationKey, transform.Scale));
}
示例2: FindPath
//.........这里部分代码省略.........
{
AStarNodeBall curPos = queue.Dequeue();
int curHash = curPos.GetHashCode();
inQueueTable.Remove(curHash);
passedTable.Add(curHash, curPos);
City cc = curPos.City;
// BFS展开新节点
// expand sub nodes in the searching
for (int i = 0; i < cc.LinkableCityCount; i++)
{
City nc = cc.GetLinkableCity(i);
AStarNodeBall np = nodeTable[nc];
if (np.City == target)
{
// found the way to the destination
found = true; //找到路径了
finalNode = np;
np.depth = curPos.depth + 1;
np.parent = curPos; //当前格坐标为终点的父方格坐标
break;
}
else if (np.City.Owner == start.Owner)
{
int npHash = np.GetHashCode();
float cost = Vector3.Distance(cc.Position, nc.Position) / 1000.0f;
bool isNPInQueue = false;
AStarNodeBall temp;
if (inQueueTable.TryGetValue(npHash, out temp) && temp == np)
{
if (np.g > curPos.g + cost)
{
np.g = curPos.g + cost;
np.f = np.g + np.h;
}
isNPInQueue = true;
}
// check if the expanded node is allowable
// Is the grid node is node in passedTable and inQueueTable?
if (!isNPInQueue &&
(!passedTable.TryGetValue(npHash, out temp) && temp != np))
//如果此方格不在即将展开的节点表 和 已遍历过的节点表
{
np.parent = curPos; //当前格为此格的父方格
np.g = curPos.g + cost;
np.h = Vector3.Distance(target.Position, nc.Position);
np.f = np.g + np.h;
np.depth = curPos.depth + 1;
enQueueBuffer.Add(np);
inQueueTable.Add(npHash, np);
}
}
}
// A*
//enQueueBuffer.Sort(Comparision);
if (enQueueBuffer.Count > 0)
{
QuickSort(enQueueBuffer, 0, enQueueBuffer.Count - 1);
for (int i = 0; i < enQueueBuffer.Count; i++)
{
queue.Enqueue(enQueueBuffer[i]);
}
enQueueBuffer.Clear();
}
}
if (found)
{
AStarNodeBall curNode = finalNode;
for (int i = 0; i < curNode.depth; i++)
{
result.Add((City)null);
}
do
{
//result.Add(curNode);
result[curNode.depth - 1] = curNode.City;
curNode = curNode.parent;
}
while (curNode.parent != null);
return new BallPathFinderResult(result);
}
return null;
}
示例3: Load
public override void Load()
{
base.Load();
if (OfflineCompilation)
return;
var renderTargets = new RenderTarget[2];
DepthStencilBuffer depthStencilBuffer = null;
Texture2D depthStencilTexture = null;
Parameters.AddSources(MainPlugin.ViewParameters);
Parameters.RegisterParameter(EffectPlugin.BlendStateKey);
var filteredPasses = new FastList<RenderPass>();
RenderPass.UpdatePasses += updatePassesAction = (RenderPass currentRenderPass, ref FastList<RenderPass> currentPasses) =>
{
var originalPasses = currentPasses;
filteredPasses.Clear();
currentPasses = filteredPasses;
Parameters.Set(PickingFrameIndex, ++currentPickingFrameIndex);
Request[] requests;
lock (pendingRequests)
{
// No picking request or no mesh to pick?
if (pendingRequests.Count == 0)
return;
requests = pendingRequests.ToArray();
pendingRequests.Clear();
}
foreach (var request in requests)
{
requestResults.Add(request);
}
if (originalPasses == null)
return;
// Count mesh passes
int meshIndex = 0;
foreach (var pass in originalPasses)
{
meshIndex += pass.Passes.Count;
}
// No mesh to pick?
if (meshIndex == 0)
return;
// Copy mesh passes and assign indices
var meshPasses = new EffectMesh[meshIndex];
meshIndex = 0;
foreach (var pass in RenderPass.Passes)
{
throw new NotImplementedException();
//foreach (var effectMeshPass in pass.Meshes)
//{
// meshPasses[meshIndex] = (EffectMesh)effectMeshPass;
// // Prefix increment so that 0 means no rendering.
// effectMeshPass.Parameters.Set(PickingMeshIndex, ++meshIndex);
//}
}
// For now, it generates one rendering per picking.
// It would be quite easy to optimize it by make Picking shader works on multiple picking points at a time.
foreach (var request in requests)
{
var pickingRenderPass = new RenderPass("Picking");
pickingRenderPass.StartPass.AddFirst = (threadContext) =>
{
threadContext.GraphicsDevice.Clear(renderTargets[0], Color.Black);
threadContext.GraphicsDevice.Clear(renderTargets[1], Color.Black);
threadContext.Parameters.Set(PickingScreenPosition, request.Location);
threadContext.GraphicsDevice.SetViewport(new Viewport(0, 0, renderTargets[0].Description.Width, renderTargets[0].Description.Height));
threadContext.GraphicsDevice.Clear(depthStencilBuffer, DepthStencilClearOptions.DepthBuffer);
threadContext.GraphicsDevice.SetRenderTargets(depthStencilBuffer, renderTargets);
};
pickingRenderPass.EndPass.AddLast = (threadContext) =>
{
threadContext.Parameters.Reset(PickingScreenPosition);
threadContext.GraphicsDevice.Copy(renderTargets[0].Texture, request.ResultTextures[0]);
threadContext.GraphicsDevice.Copy(renderTargets[1].Texture, request.ResultTextures[1]);
};
//pickingRenderPass.PassesInternal = originalPasses;
throw new NotImplementedException();
request.MeshPasses = meshPasses;
currentPasses.Add(pickingRenderPass);
request.HasResults = true;
//.........这里部分代码省略.........
示例4: FindPath
//.........这里部分代码省略.........
AStarNode np = units[nx][ny];
int npHash = np.GetHashCode();
if (nx == tx && ny == ty) //如此方格为终点
{
found = true; //找到路径了
finalNode = np;
np.depth = curPos.depth + 1;
np.parent = curPos; //当前格坐标为终点的父方格坐标
break;
}
else
{
if (!terrain.GetBit(ny * width + nx)) //地块能通过
{
bool isNPInQueue = false;
AStarNode temp;
if (inQueueTable.TryGetValue(npHash, out temp) && temp == np)
{
if (np.g > curPos.g + stateEnumCost[i])
{
np.g = curPos.g + stateEnumCost[i];
np.f = np.g + np.h;
}
isNPInQueue = true;
}
if (!isNPInQueue &&
(!passedTable.TryGetValue(npHash, out temp) && temp != np))
//如果此方格不在即将展开的节点表 和 已遍历过的节点表
{
np.parent = curPos; //当前格为此格的父方格
np.g = curPos.g + stateEnumCost[i];
np.h = Math.Abs(tx - nx) + Math.Abs(ty - ny);
np.f = np.g + np.h;
np.depth = curPos.depth + 1;
enQueueBuffer.Add(np);
inQueueTable.Add(npHash, np);
}
}
}
}
}
// A*
//enQueueBuffer.Sort(Comparision);
if (enQueueBuffer.Count > 0)
{
QuickSort(enQueueBuffer, 0, enQueueBuffer.Count - 1);
for (int i = 0; i < enQueueBuffer.Count; i++)
{
queue.Enqueue(enQueueBuffer[i]);
}
enQueueBuffer.Clear();
}
}
if (rcpf)
{
AStarNode curNode = finalNode;
int baseOffset = result.Count;
for (int i = 0; i < curNode.depth; i++)
{
result.Add(Point.Zero);
}
do
{
//result.Add(curNode);
result[baseOffset + curNode.depth - 1] = new Point(curNode.X, curNode.Y);
curNode = curNode.parent;
}
while (curNode.parent != null);
return new PathFinderResult(result, true);
}
if (found)
{
AStarNode curNode = finalNode;
for (int i = 0; i < curNode.depth + 1; i++)
{
result.Add(Point.Zero);
}
do
{
//result.Add(curNode);
result[curNode.depth] = new Point(curNode.X, curNode.Y);
curNode = curNode.parent;
}
while (curNode.parent != null);
result[0] = new Point(sx, sy);
return new PathFinderResult(result, false);
}
return null;
}