Skip to content

Commit d1e00a2

Browse files
line texcoords
1 parent e6bdc7d commit d1e00a2

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

worldwind/src/commonMain/kotlin/earth/worldwind/shape/TextureQuad.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ open class TextureQuad @JvmOverloads constructor(
101101
protected var vertexIndex = 0
102102

103103
protected var lineVertexIndex = 0
104+
protected val prevPoint = Vec3()
105+
protected var texCoord1d = 0.0
104106

105107
fun getSharedIndexBuffer(rc: RenderContext): BufferObject?
106108
{
@@ -205,7 +207,7 @@ open class TextureQuad @JvmOverloads constructor(
205207
drawableLines.offset = rc.globe.offset
206208
drawableLines.sector.copy(currentBoundindData.boundingSector)
207209
drawableLines.version = computeVersion()
208-
drawableLines.isDynamic = true//isDynamic || rc.currentLayer.isDynamic
210+
drawableLines.isDynamic = isDynamic || rc.currentLayer.isDynamic
209211

210212
cameraDistance = cameraDistanceGeographic(rc, currentBoundindData.boundingSector)
211213
drawStateLines = drawableLines.drawState
@@ -339,15 +341,18 @@ open class TextureQuad @JvmOverloads constructor(
339341
for (idx in 1 until locations.size) {
340342
val end = locations[idx]
341343
val addIndices = idx != locations.size - 1 || end != pos0 // check if there is implicit closing edge
344+
calcPoint(rc, end.latitude, end.longitude, 0.0, isAbsolute = false, isExtrudedSkirt = false)
342345
addLineVertex(rc, end.latitude, end.longitude, isIntermediate = false, addIndices)
343346
begin = end
344347
}
345348

346349
if (begin != pos0) {
347350
// Add additional dummy vertex with the same data after the last vertex.
351+
calcPoint(rc, pos0.latitude, pos0.longitude, 0.0, isAbsolute = false, isExtrudedSkirt = false)
348352
addLineVertex(rc, pos0.latitude, pos0.longitude, isIntermediate = true, addIndices = false)
349353
addLineVertex(rc, pos0.latitude, pos0.longitude, isIntermediate = true, addIndices = false)
350354
} else {
355+
calcPoint(rc, begin.latitude, begin.longitude, 0.0, isAbsolute = false, isExtrudedSkirt = false)
351356
addLineVertex(rc, begin.latitude, begin.longitude, isIntermediate = true, addIndices = false)
352357
}
353358
// Drop last six indices as they are used for connecting segments and there's no next segment for last vertices (check addLineVertex)
@@ -395,8 +400,8 @@ open class TextureQuad @JvmOverloads constructor(
395400
rc: RenderContext, latitude: Angle, longitude: Angle, isIntermediate : Boolean, addIndices : Boolean
396401
) = with(currentData) {
397402
val vertex = lineVertexIndex / VERTEX_LINE_STRIDE
398-
// if (lineVertexIndex == 0) texCoord1d = 0.0 else texCoord1d += point.distanceTo(prevPoint)
399-
// prevPoint.copy(point)
403+
if (lineVertexIndex == 0) texCoord1d = 0.0 else texCoord1d += point.distanceTo(prevPoint)
404+
prevPoint.copy(point)
400405
val upperLeftCorner = encodeOrientationVector(-1f, 1f)
401406
val lowerLeftCorner = encodeOrientationVector(-1f, -1f)
402407
val upperRightCorner = encodeOrientationVector(1f, 1f)
@@ -406,25 +411,25 @@ open class TextureQuad @JvmOverloads constructor(
406411
lineVertexArray[lineVertexIndex++] = (latitude.inDegrees - vertexOrigin.y).toFloat()
407412
lineVertexArray[lineVertexIndex++] = 0.0f
408413
lineVertexArray[lineVertexIndex++] = upperLeftCorner
409-
lineVertexArray[lineVertexIndex++] = 0.0f//texCoord1d.toFloat()
414+
lineVertexArray[lineVertexIndex++] = texCoord1d.toFloat()
410415

411416
lineVertexArray[lineVertexIndex++] = (longitude.inDegrees - vertexOrigin.x).toFloat()
412417
lineVertexArray[lineVertexIndex++] = (latitude.inDegrees - vertexOrigin.y).toFloat()
413418
lineVertexArray[lineVertexIndex++] = 0.0f
414419
lineVertexArray[lineVertexIndex++] = lowerLeftCorner
415-
lineVertexArray[lineVertexIndex++] = 0.0f//texCoord1d.toFloat()
420+
lineVertexArray[lineVertexIndex++] = texCoord1d.toFloat()
416421

417422
lineVertexArray[lineVertexIndex++] = (longitude.inDegrees - vertexOrigin.x).toFloat()
418423
lineVertexArray[lineVertexIndex++] = (latitude.inDegrees - vertexOrigin.y).toFloat()
419424
lineVertexArray[lineVertexIndex++] = 0.0f
420425
lineVertexArray[lineVertexIndex++] = upperRightCorner
421-
lineVertexArray[lineVertexIndex++] = 0.0f//texCoord1d.toFloat()
426+
lineVertexArray[lineVertexIndex++] = texCoord1d.toFloat()
422427

423428
lineVertexArray[lineVertexIndex++] = (longitude.inDegrees - vertexOrigin.x).toFloat()
424429
lineVertexArray[lineVertexIndex++] = (latitude.inDegrees - vertexOrigin.y).toFloat()
425430
lineVertexArray[lineVertexIndex++] = 0.0f
426431
lineVertexArray[lineVertexIndex++] = lowerRightCorner
427-
lineVertexArray[lineVertexIndex++] = 0.0f//texCoord1d.toFloat()
432+
lineVertexArray[lineVertexIndex++] = texCoord1d.toFloat()
428433
if (addIndices) {
429434
// indices for triangles made from this segment vertices
430435
outlineElements.add(vertex)

0 commit comments

Comments
 (0)