|
|
|
|
|
|
|
|
|
|
List<uiPathPath> _paths = new List<uiPathPath>(); |
|
|
|
List<uiPathPoint> _points = new List<uiPathPoint>(); |
|
|
|
|
|
|
|
//mesh cache
|
|
|
|
uiMeshMesh _fillMesh; |
|
|
|
bool _fillConvex; |
|
|
|
|
|
|
|
uiMeshMesh _strokeMesh; |
|
|
|
float _strokeWidth; |
|
|
|
StrokeCap _lineCap; |
|
|
|
StrokeJoin _lineJoin; |
|
|
|
float _miterLimit; |
|
|
|
|
|
|
|
public static uiPathCache create(float scale) { |
|
|
|
uiPathCache newPathCache = ItemPoolManager.alloc<uiPathCache>(); |
|
|
|
|
|
|
public override void clear() { |
|
|
|
this._paths.Clear(); |
|
|
|
this._points.Clear(); |
|
|
|
this._fillMesh?.dispose(); |
|
|
|
this._fillMesh = null; |
|
|
|
|
|
|
|
this._strokeMesh?.dispose(); |
|
|
|
this._strokeMesh = null; |
|
|
|
} |
|
|
|
|
|
|
|
public uiPathCache() { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public uiMeshMesh getFillMesh(out bool convex) { |
|
|
|
if (this._fillMesh != null) { |
|
|
|
convex = this._fillConvex; |
|
|
|
return this._fillMesh; |
|
|
|
} |
|
|
|
|
|
|
|
var vertices = this._expandFill(); |
|
|
|
|
|
|
|
var paths = this._paths; |
|
|
|
|
|
|
D.assert(indices.Count == cindices); |
|
|
|
|
|
|
|
var mesh = uiMeshMesh.create(null, vertices, indices); |
|
|
|
|
|
|
|
var _fillMesh = mesh; |
|
|
|
|
|
|
|
var _fillConvex = false; |
|
|
|
this._fillMesh = mesh; |
|
|
|
|
|
|
|
this._fillConvex = false; |
|
|
|
for (var i = 0; i < paths.Count; i++) { |
|
|
|
var path = paths[i]; |
|
|
|
if (path.count <= 2) { |
|
|
|
|
|
|
if (_fillConvex) { |
|
|
|
if (this._fillConvex) { |
|
|
|
_fillConvex = false; |
|
|
|
this._fillConvex = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_fillConvex = true; |
|
|
|
this._fillConvex = true; |
|
|
|
convex = _fillConvex; |
|
|
|
return _fillMesh; |
|
|
|
convex = this._fillConvex; |
|
|
|
return this._fillMesh; |
|
|
|
} |
|
|
|
|
|
|
|
void _calculateJoins(float w, StrokeJoin lineJoin, float miterLimit) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public uiMeshMesh getStrokeMesh(float strokeWidth, StrokeCap lineCap, StrokeJoin lineJoin, float miterLimit) { |
|
|
|
if (this._strokeMesh != null && |
|
|
|
this._strokeWidth == strokeWidth && |
|
|
|
this._lineCap == lineCap && |
|
|
|
this._lineJoin == lineJoin && |
|
|
|
this._miterLimit == miterLimit) { |
|
|
|
return this._strokeMesh; |
|
|
|
} |
|
|
|
|
|
|
|
var vertices = this._expandStroke(strokeWidth, lineCap, lineJoin, miterLimit); |
|
|
|
|
|
|
|
var paths = this._paths; |
|
|
|
|
|
|
|
|
|
|
D.assert(indices.Count == cindices); |
|
|
|
|
|
|
|
var _strokeMesh = uiMeshMesh.create(null, vertices, indices); |
|
|
|
return _strokeMesh; |
|
|
|
this._strokeMesh?.dispose(); |
|
|
|
this._strokeMesh = uiMeshMesh.create(null, vertices, indices); |
|
|
|
this._strokeWidth = strokeWidth; |
|
|
|
this._lineCap = lineCap; |
|
|
|
this._lineJoin = lineJoin; |
|
|
|
this._miterLimit = miterLimit; |
|
|
|
return this._strokeMesh; |
|
|
|
} |
|
|
|
} |
|
|
|
} |