/// <summary> /// 获取三边中点距离 /// </summary> /// <param name="index"></param> /// <returns></returns> public double GetWallDis(int index) { if (index >= 3) { DEBUG.ERROR("GetWallDis:The index is large than 3."); return(-1); } return(this.m_vecWallDistance[index]); }
/// <summary> /// 获取邻居节点ID /// </summary> /// <param name="index"></param> /// <returns></returns> public int GetNeighbor(int index) { if (index >= 3) { DEBUG.ERROR("GetNeighbor:The index is large than 3."); return(-1); } return(this.m_vecNeighbors[index]); }
/// <summary> /// 设置邻居三角形ID /// </summary> /// <param name="index"></param> /// <param name="id"></param> public void SetNeighbor(int index, int id) { if (index >= 3) { DEBUG.ERROR("SetNeighbor:The index is large than 3."); return; } this.m_vecNeighbors[index] = id; }
/// <summary> /// 获取指定点 /// </summary> /// <param name="index"></param> /// <returns></returns> public Vector2 GetPoint(int index) { if (index >= 3) { DEBUG.ERROR("GetPoint:The index is large than 3."); return(Vector2.zero); } return(this.m_vecPoints[index]); }
/// <summary> /// 计算包围盒 /// </summary> private void CalcCollider() { //计算包围盒 if (this.m_vecPoints[0] == this.m_vecPoints[1] || this.m_vecPoints[1] == this.m_vecPoints[2] || this.m_vecPoints[0] == this.m_vecPoints[2]) { DEBUG.ERROR("Triangle:This is not a triangle."); return; } Rect collider = new Rect(); collider.xMin = collider.xMax = this.m_vecPoints[0].x; collider.yMin = collider.yMax = this.m_vecPoints[0].y; for (int i = 1; i < 3; i++) { if (this.m_vecPoints[i].x < collider.xMin) { collider.xMin = this.m_vecPoints[i].x; } else if (this.m_vecPoints[i].x > collider.xMax) { collider.xMax = this.m_vecPoints[i].x; } if (this.m_vecPoints[i].y < collider.yMin) { collider.yMin = this.m_vecPoints[i].y; } else if (this.m_vecPoints[i].y > collider.yMax) { collider.yMax = this.m_vecPoints[i].y; } } this.m_cBoxCollider = collider; }