[orx-shapes] Improve contour adjuster framework
This commit is contained in:
@@ -58,6 +58,7 @@ fun Segment.withTunniPoint(tunniPoint: Vector2): Segment {
|
||||
* @since orx 0.4.5
|
||||
*/
|
||||
fun Segment.withTunniLine(pointOnLine: Vector2): Segment {
|
||||
println("hoi! $pointOnLine")
|
||||
val ls = LineSegment(pointOnLine, pointOnLine + this.cubic.control[0] - this.cubic.control[1])
|
||||
val ac0 = LineSegment(start, this.cubic.control[0])
|
||||
val bc1 = LineSegment(end, this.cubic.control[1])
|
||||
@@ -66,6 +67,10 @@ fun Segment.withTunniLine(pointOnLine: Vector2): Segment {
|
||||
val cp1 = intersection(ls, bc1, Double.POSITIVE_INFINITY)
|
||||
|
||||
return if (cp0 != Vector2.INFINITY && cp1 != Vector2.INFINITY) {
|
||||
println("$cp0 $cp1")
|
||||
copy(start, listOf(cp0, cp1), end)
|
||||
} else this
|
||||
} else {
|
||||
println("${cp0} ${cp1}")
|
||||
this
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ fun ContourEdge.withTunniLine(pointOnLine: Vector2): ContourEdge {
|
||||
if (contour.empty) {
|
||||
return withoutAdjustments()
|
||||
} else {
|
||||
val segment = contour.segments[segmentIndex].withTunniPoint(pointOnLine)
|
||||
val segment = contour.segments[segmentIndex].withTunniLine(pointOnLine)
|
||||
val newSegments = contour.segments.map { it }.toMutableList()
|
||||
newSegments[segmentIndex] = segment
|
||||
return ContourEdge(ShapeContour.fromSegments(newSegments, contour.closed), segmentIndex)
|
||||
|
||||
Reference in New Issue
Block a user