本文整理汇总了C#中Pathfinding.IntRect.DebugDraw方法的典型用法代码示例。如果您正苦于以下问题:C# IntRect.DebugDraw方法的具体用法?C# IntRect.DebugDraw怎么用?C# IntRect.DebugDraw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pathfinding.IntRect
的用法示例。
在下文中一共展示了IntRect.DebugDraw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateArea
/** Internal function to update an area of the graph.
*/
public void UpdateArea (GraphUpdateObject o) {
if (nodes == null || nodes.Length != width*depth) {
Debug.LogWarning ("The Grid Graph is not scanned, cannot update area ");
//Not scanned
return;
}
//Copy the bounds
Bounds b = o.bounds;
Vector3 min, max;
GetBoundsMinMax (b,inverseMatrix,out min, out max);
int minX = Mathf.RoundToInt (min.x-0.5F);
int maxX = Mathf.RoundToInt (max.x-0.5F);
int minZ = Mathf.RoundToInt (min.z-0.5F);
int maxZ = Mathf.RoundToInt (max.z-0.5F);
//We now have coordinates in local space (i.e 1 unit = 1 node)
IntRect originalRect = new IntRect(minX,minZ,maxX,maxZ);
IntRect affectRect = originalRect;
IntRect gridRect = new IntRect(0,0,width-1,depth-1);
IntRect physicsRect = originalRect;
int erosion = o.updateErosion ? erodeIterations : 0;
#if ASTARDEBUG
Matrix4x4 debugMatrix = matrix;
debugMatrix *= Matrix4x4.TRS (new Vector3(0.5f,0,0.5f),Quaternion.identity,Vector3.one);
originalRect.DebugDraw (debugMatrix,Color.red);
#endif
bool willChangeWalkability = o.updatePhysics || o.modifyWalkability;
//Calculate the largest bounding box which might be affected
if (o.updatePhysics && !o.modifyWalkability) {
//Add the collision.diameter margin for physics calls
if (collision.collisionCheck) {
Vector3 margin = new Vector3 (collision.diameter,0,collision.diameter)*0.5F;
min -= margin*1.02F;//0.02 safety margin, physics is rarely very accurate
max += margin*1.02F;
physicsRect = new IntRect(
Mathf.RoundToInt (min.x-0.5F),
Mathf.RoundToInt (min.z-0.5F),
Mathf.RoundToInt (max.x-0.5F),
Mathf.RoundToInt (max.z-0.5F)
);
affectRect = IntRect.Union (physicsRect, affectRect);
}
}
if (willChangeWalkability || erosion > 0) {
//Add affect radius for erosion. +1 for updating connectivity info at the border
affectRect = affectRect.Expand (erosion + 1);
}
IntRect clampedRect = IntRect.Intersection (affectRect,gridRect);
//Mark nodes that might be changed
for (int x = clampedRect.xmin; x <= clampedRect.xmax;x++) {
for (int z = clampedRect.ymin;z <= clampedRect.ymax;z++) {
o.WillUpdateNode (nodes[z*width+x]);
}
}
//Update Physics
if (o.updatePhysics && !o.modifyWalkability) {
collision.Initialize (matrix,nodeSize);
clampedRect = IntRect.Intersection (physicsRect,gridRect);
for (int x = clampedRect.xmin; x <= clampedRect.xmax;x++) {
for (int z = clampedRect.ymin;z <= clampedRect.ymax;z++) {
int index = z*width+x;
GridNode node = nodes[index];
UpdateNodePositionCollision (node,x,z, o.resetPenaltyOnPhysics);
}
}
}
//Apply GUO
clampedRect = IntRect.Intersection (originalRect, gridRect);
for (int x = clampedRect.xmin; x <= clampedRect.xmax;x++) {
for (int z = clampedRect.ymin;z <= clampedRect.ymax;z++) {
//.........这里部分代码省略.........
示例2: UpdateArea
public new void UpdateArea(GraphUpdateObject o)
{
if (nodes == null || nodes.Length != width*depth*layerCount) {
Debug.LogWarning ("The Grid Graph is not scanned, cannot update area ");
//Not scanned
return;
}
//Copy the bounds
Bounds b = o.bounds;
//Matrix inverse
//node.position = matrix.MultiplyPoint3x4 (new Vector3 (x+0.5F,0,z+0.5F));
Vector3 min, max;
GetBoundsMinMax (b,inverseMatrix,out min, out max);
int minX = Mathf.RoundToInt (min.x-0.5F);
int maxX = Mathf.RoundToInt (max.x-0.5F);
int minZ = Mathf.RoundToInt (min.z-0.5F);
int maxZ = Mathf.RoundToInt (max.z-0.5F);
//We now have coordinates in local space (i.e 1 unit = 1 node)
IntRect originalRect = new IntRect(minX,minZ,maxX,maxZ);
IntRect affectRect = originalRect;
IntRect gridRect = new IntRect(0,0,width-1,depth-1);
IntRect physicsRect = originalRect;
Matrix4x4 debugMatrix = matrix;
debugMatrix *= Matrix4x4.TRS (new Vector3(0.5f,0,0.5f),Quaternion.identity,Vector3.one);
#if ASTARDEBUG
originalRect.DebugDraw (debugMatrix,Color.red);
#endif
bool willChangeWalkability = o.updatePhysics || o.modifyWalkability;
bool willChangeNodeInstances = (o is LayerGridGraphUpdate ? ((LayerGridGraphUpdate)o).recalculateNodes : false);
bool preserveExistingNodes = (o is LayerGridGraphUpdate ? ((LayerGridGraphUpdate)o).preserveExistingNodes : true);
if (o.trackChangedNodes && willChangeNodeInstances) {
Debug.LogError ("Cannot track changed nodes when creating or deleting nodes.\nWill not update LayerGridGraph");
return;
}
//Calculate the largest bounding box which might be affected
if (o.updatePhysics && !o.modifyWalkability) {
//Add the collision.diameter margin for physics calls
if (collision.collisionCheck) {
Vector3 margin = new Vector3 (collision.diameter,0,collision.diameter)*0.5F;
min -= margin*1.02F;//0.02 safety margin, physics is rarely very accurate
max += margin*1.02F;
physicsRect = new IntRect(
Mathf.RoundToInt (min.x-0.5F),
Mathf.RoundToInt (min.z-0.5F),
Mathf.RoundToInt (max.x-0.5F),
Mathf.RoundToInt (max.z-0.5F)
);
affectRect = IntRect.Union (physicsRect, affectRect);
}
}
if (willChangeWalkability && erodeIterations > 0) {
//Add affect radius for erosion. +1 for updating connectivity info at the border
affectRect = affectRect.Expand (erodeIterations+1);
}
IntRect clampedRect = IntRect.Intersection (affectRect,gridRect);
//Mark nodes that might be changed
if (!willChangeNodeInstances) {
for (int x = clampedRect.xmin; x <= clampedRect.xmax;x++) {
for (int z = clampedRect.ymin;z <= clampedRect.ymax;z++) {
for (int y=0;y<layerCount;y++) {
o.WillUpdateNode (nodes[y*width*depth + z*width+x]);
}
}
}
}
//Update Physics
if (o.updatePhysics && !o.modifyWalkability) {
collision.Initialize (matrix,nodeSize);
clampedRect = IntRect.Intersection (physicsRect,gridRect);
bool addedNodes = false;
for (int x = clampedRect.xmin; x <= clampedRect.xmax;x++) {
for (int z = clampedRect.ymin;z <= clampedRect.ymax;z++) {
/** \todo FIX */
addedNodes |= RecalculateCell (x,z,preserveExistingNodes);
//.........这里部分代码省略.........