Skip to content

Commit

Permalink
Sync from next
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Dec 26, 2020
1 parent 47ecc6a commit 773cc83
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import kotlinx.coroutines.*
import kotlin.coroutines.*
import kotlin.jvm.*

open class ViewsForTesting @JvmOverloads constructor(
open class ViewsForTesting(
val frameTime: TimeSpan = 10.milliseconds,
val windowSize: SizeInt = SizeInt(DefaultViewport.WIDTH, DefaultViewport.HEIGHT),
val virtualSize: SizeInt = SizeInt(windowSize.size.clone()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.soywiz.korge3d

import com.soywiz.kds.floatArrayListOf
import com.soywiz.kds.intArrayListOf
import com.soywiz.kds.*
import com.soywiz.korag.AG
import com.soywiz.korag.shader.VertexLayout
import com.soywiz.korge3d.internal.toFBuffer
Expand Down Expand Up @@ -32,7 +31,7 @@ class MeshBuilder3D(

val vertexData = floatArrayListOf()
var nextVertexIndex = 0
val indexData = intArrayListOf()
val indexData = ShortArrayList()

private var _material: Material3D? = null

Expand Down Expand Up @@ -80,7 +79,7 @@ class MeshBuilder3D(
}

fun addIndex(index: Int) {
indexData.add(index)
indexData.add(index.toShort())
}

fun addIndices(vararg indices: Int) = indices.forEach { addIndex(it) }
Expand Down Expand Up @@ -237,7 +236,7 @@ class MeshBuilder3D(
fun build(): Mesh3D = Mesh3D(
vertexData.toFBuffer(),
indexData.toFBuffer(),
AG.IndexType.UINT,
AG.IndexType.USHORT,
indexData.size,
layout,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class ColladaParser {

// @TODO: We should use separate components
val combinedVertexData = floatArrayListOf()
val combinedIndexData = intArrayListOf()
val combinedIndexData = ShortArrayList()

val hasNormals = (nx.size >= px.size)
val hasTexture = TEXCOORD != null
Expand All @@ -254,7 +254,7 @@ class ColladaParser {
combinedVertexData.add(weightWeights[m][VERTEX_indices[n]])
}
}
combinedIndexData.add(n)
combinedIndexData.add(n.toShort())
}

//println(combinedData.toString())
Expand All @@ -266,7 +266,7 @@ class ColladaParser {
//combinedData.toFloatArray().toFBuffer(),
combinedVertexData.toFBuffer(),
combinedIndexData.toFBuffer(),
AG.IndexType.UINT,
AG.IndexType.USHORT,
combinedIndexData.size,
VertexLayout(buildList {
add(Shaders3D.a_pos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ internal fun FloatArray.toFBuffer(): FBuffer =
internal fun IntArrayList.toFBuffer(): FBuffer = toIntArray().toFBuffer()
internal fun IntArray.toFBuffer():FBuffer =
FBuffer.alloc(this.size * 4).also { it.setAlignedArrayInt32(0, this, 0, this.size) }

internal fun ShortArrayList.toFBuffer(): FBuffer = toShortArray().toFBuffer()
internal fun ShortArray.toFBuffer():FBuffer =
FBuffer.alloc(this.size * 2).also { it.setAlignedArrayInt16(0, this, 0, this.size) }

0 comments on commit 773cc83

Please sign in to comment.