/// <summary> /// target content will be added or update it's possition if already added /// </summary> public static void Process(IChunkContent processedContent) { Bounds2DInt processedContentBounds = PathFinder.ToChunkPosition(processedContent.chunkContentBounds); ChunkContentMetaData metaData; if (content.TryGetValue(processedContent, out metaData)) { Bounds2DInt currentContentBounds = metaData.lastUpdate; if (currentContentBounds == processedContentBounds) { return; //nothing to change since it occupy same space } GetChunkRemoveContent(currentContentBounds, processedContent); IncludeBounds(processedContentBounds); GetChunkAddContent(processedContentBounds, processedContent); content[processedContent] = new ChunkContentMetaData(processedContentBounds); } else { if (init == false) { beforeInit.Add(processedContent); return; } IncludeBounds(processedContentBounds); GetChunkAddContent(processedContentBounds, processedContent); content[processedContent] = new ChunkContentMetaData(processedContentBounds); } }
void OnSceneGUI(SceneView sceneView) { Event curEvent = Event.current; Color col = Handles.color; Handles.color = Color.red; Handles.DrawLine(pointer, pointer + Vector3.up); Handles.color = col; if ((sellectStart | sellectEnd)) { RaycastHit hit; if (Physics.Raycast(HandleUtility.GUIPointToWorldRay(curEvent.mousePosition), out hit)) { var somePos = PathFinder.ToChunkPosition(hit.point); if (sellectStart) { settings.startX = somePos.x; settings.startZ = somePos.z; } if (sellectEnd) { settings.sizeX = Mathf.Max(1, somePos.x - settings.startX + 1); settings.sizeZ = Mathf.Max(1, somePos.z - settings.startZ + 1); } pointer = hit.point; } if (curEvent.type == EventType.MouseDown && curEvent.button == 0) { sellectStart = false; sellectEnd = false; } Repaint(); } Debuger_K.DrawDebugLabels(); Handles.BeginGUI(); Debuger_K.DrawSceneGUI(); Handles.EndGUI(); }
/// <summary> /// target content will be added or update it's possition if already added /// </summary> public static void Process <T>(List <T> processedContentList) where T : IChunkContent { //Debug.Log(processedContentList.Count); if (processedContentList == null || processedContentList.Count == 0) { return; } Bounds2DInt first = PathFinder.ToChunkPosition(processedContentList[0].chunkContentBounds); int minX = first.minX, minZ = first.minY, maxX = first.maxX, maxZ = first.maxY; Bounds2DInt[] array = new Bounds2DInt[processedContentList.Count]; array[0] = first; for (int i = 1; i < processedContentList.Count; i++) { Bounds2DInt curRange = PathFinder.ToChunkPosition(processedContentList[i].chunkContentBounds); array[i] = curRange; if (minX > curRange.minX) { minX = curRange.minX; } if (minZ > curRange.minY) { minZ = curRange.minY; } if (maxX < curRange.maxX) { maxX = curRange.maxX; } if (maxZ < curRange.maxY) { maxZ = curRange.maxY; } } IncludeBounds(new Bounds2DInt(minX, minZ, maxX, maxZ)); for (int i = 0; i < processedContentList.Count; i++) { Bounds2DInt processedContentBounds = array[i]; IChunkContent processedContent = processedContentList[i]; ChunkContentMetaData metaData; if (content.TryGetValue(processedContent, out metaData)) { Bounds2DInt currentContentBounds = metaData.lastUpdate; if (currentContentBounds == processedContentBounds) { return; //nothing to change since it occupy same space } GetChunkRemoveContent(currentContentBounds, processedContent); GetChunkAddContent(processedContentBounds, processedContent); content[processedContent] = new ChunkContentMetaData(processedContentBounds); } else { if (init == false) { beforeInit.Add(processedContent); return; } GetChunkAddContent(processedContentBounds, processedContent); content[processedContent] = new ChunkContentMetaData(processedContentBounds); } } //SceneDebug(); }
void OnSceneGUI(SceneView sceneView) { Event curEvent = Event.current; Color col = Handles.color; Handles.color = Color.red; //float gs = settings.gridSize; AreaPointer targetData = settings.areaPointer * settings.gridSize; bool isMoved; targetData = MyHandles.DrawData(targetData, 2.5f, settings.gridSize, out isMoved); if (PathFinderSettings.isAreaPointerMoving) { settings.areaPointer = targetData / settings.gridSize; EditorUtility.SetDirty(settings); SceneView.RepaintAll(); } if (curEvent.type == EventType.Used) { PathFinderSettings.isAreaPointerMoving = isMoved; } Handles.color = col; if (sellectorMove) { XZPosInt pointerPos; RaycastHit hit; Ray ray = HandleUtility.GUIPointToWorldRay(curEvent.mousePosition); if (Physics.Raycast(ray, out hit)) { pointerPos = PathFinder.ToChunkPosition(hit.point); } else { Vector3 intersection; if (Math3d.LinePlaneIntersection(out intersection, ray.origin, ray.direction, Vector3.up, new Vector3())) { pointerPos = PathFinder.ToChunkPosition(intersection); } else { pointerPos = new XZPosInt(); } } settingsDrawer.MovePointer(new AreaPointer(pointerPos.x, pointerPos.z, pointerPos.x + 1, pointerPos.z + 1, hit.point.y)); if (curEvent.type == EventType.MouseDown && curEvent.button == 0) { sellectorMove = false; } Repaint(); SceneView.RepaintAll(); } //if (RVOPF.RVOSimulator.instance.debug) { // foreach (var cone in RVOPF.RVOSimulator.instance.collisionCones) { // if (cone.agent == null | cone.other == null) // continue; // Vector3 offset = new Vector3(0, cone.heightOffset, 0); // Vector3 agentPos = cone.agent.positionV3 + offset; // float agentY = agentPos.y; // Vector3 conePos = new Vector3(cone.position.x, agentY, cone.position.y); // Vector3 coneDir = new Vector3(cone.direction.x, agentY, cone.direction.y); // Handles.color = Color.green; // Handles.DrawLine(agentPos, conePos); // Handles.color = Color.red; // Handles.DrawLine(cone.other.positionV3, conePos); // Handles.color = new Color(cone.color.r, cone.color.g, cone.color.b, 0.1f); // Handles.DrawLine(conePos, conePos + coneDir); // float v = Vector2.SignedAngle(Vector2.up, cone.direction); // Quaternion q1 = Quaternion.AngleAxis(v, new Vector3(0, 0, 1)); // Quaternion q2 = Quaternion.AngleAxis(v + cone.angle, new Vector3(0, 0, 1)); // Quaternion q3 = Quaternion.AngleAxis(v - cone.angle, new Vector3(0, 0, 1)); // float targetDistance = Vector2.Distance(cone.agent.positionV2, cone.other.positionV2) + cone.other.radius + cone.agent.radius; // Vector2 P1 = q1 * Vector2.up * targetDistance; // Vector2 P2 = q2 * Vector2.up * targetDistance; // Vector2 P3 = q3 * Vector2.up * targetDistance; // Handles.DrawSolidArc(conePos, Vector3.up, new Vector3(P2.x, 0, P2.y), cone.angle * 2, targetDistance); // Handles.color = cone.color; // Handles.DrawLine(conePos, conePos + new Vector3(P2.x, 0, P2.y)); // Handles.DrawLine(conePos, conePos + new Vector3(P3.x, 0, P3.y)); // Handles.color = Color.black; // Handles.DrawWireDisc(cone.other.positionV3 + offset, Vector3.up, cone.other.radius); // Handles.DrawWireDisc(cone.other.positionV3 + offset, Vector3.up, cone.other.radius + cone.agent.radius); // Handles.DrawLine(cone.other.positionV3, cone.other.positionV3 + offset); // } //} Debuger_K.DrawDebugLabels(); Handles.BeginGUI(); Debuger_K.DrawSceneGUI(); Handles.EndGUI(); }