/// <summary> /// Process the build context. /// </summary> /// <remarks> /// <para> /// The flags will be applied during the <see cref="NMGenState.PolyMeshBuild"/> /// state. /// </para> /// </remarks> /// <param name="state">The current build state.</param> /// <param name="context">The context to process.</param> /// <returns>False on error, otherwise true.</returns> public override bool ProcessBuild(NMGenContext context, NMGenState state) { if (state != NMGenState.PolyMeshBuild) { return(true); } PolyMesh mesh = context.PolyMesh; PolyMeshData data = mesh.GetData(false); if (data.polyCount == 0) { return(true); } bool applied = false; for (int i = 0; i < mAreas.Length; i++) { byte area = mAreas[i]; ushort flags = mFlags[i]; int marked = 0; for (int iPoly = 0; iPoly < data.polyCount; iPoly++) { if (data.areas[iPoly] == area) { data.flags[iPoly] |= flags; marked++; } } if (marked > 0) { string msg = string.Format( "{0} : Added '0x{1:X}' flag(s) to {2} poylgons assigned to area {3}." , Name, flags, marked, area); context.Log(msg, this); applied = true; } } if (applied) { mesh.Load(data); } else { context.Log(Name + ": No flags applied.", this); } return(true); }
public void HandlePolyMesh(NavmeshBuild build, int tx, int tz) { if (!build) { return; } if (mDebugObject == null) { PolyMesh mesh = build.BuildData.GetPolyMesh(tx, tz); if (mesh != null) { mDebugObject = mesh.GetData(false); } } if (mDebugObject != null) { NMGenDebug.Draw(( PolyMeshData )mDebugObject); } }
public bool QueueTask(BuildContext context , int tx, int tz , PolyMesh polyMesh, PolyMeshDetail detailMesh , bool bvTreeEnabled , int priority) { TileBuildTask task = TileBuildTask.Create(tx, tz , polyMesh.GetData(false) , (detailMesh == null ? null : detailMesh.GetData(true)) , Build.Connections , bvTreeEnabled , true , priority); if (!mTaskProcessor.QueueTask(task)) { context.LogError("Task processor rejected task.", this); return(false); } mTileTasks.Add(task); return(true); }