Skip to content

Commit

Permalink
Introduced local variable to trick native and jvm into accepting an o…
Browse files Browse the repository at this point in the history
…therwise unused import.
  • Loading branch information
c committed Oct 23, 2023
1 parent b5c8cbd commit 6937b82
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions mesh/shared/src/main/scala/ai/dragonfly/mesh/io/PLY.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package ai.dragonfly.mesh.io

import slash.vector.*
import Vec.*
import ai.dragonfly.mesh.sRGB.*
import ai.dragonfly.mesh.Mesh

Expand All @@ -42,11 +41,13 @@ object PLY {
}

def fromMesh(mesh: Mesh, vertexColorMapper: Vec[3] => ARGB32):String = {
val meshPoints: NArray[Vec[3]] = mesh.points

val sb: StringBuilder = new StringBuilder()

sb.append(
s"""$defaultHeader
element vertex ${mesh.points.length}
element vertex ${meshPoints.length}
property float x
property float y
property float z
Expand All @@ -60,8 +61,8 @@ end_header
"""
)

var i:Int = 0; while (i < mesh.points.length) {
val v:Vec[3] = mesh.points(i)
var i:Int = 0; while (i < meshPoints.length) {
val v:Vec[3] = meshPoints(i)
val c: ARGB32 = vertexColorMapper(v)
sb.append(s"${v.x} ${v.y} ${v.z} ${c.red} ${c.green} ${c.blue} ${c.alpha}\n")
i += 1
Expand All @@ -78,11 +79,13 @@ end_header


def fromMesh(mesh: Mesh): String = {
val meshPoints: NArray[Vec[3]] = mesh.points

val sb: StringBuilder = new StringBuilder()

sb.append(
s"""$defaultHeader
element vertex ${mesh.points.length}
element vertex ${meshPoints.length}
property float x
property float y
property float z
Expand All @@ -92,16 +95,15 @@ end_header
"""
)

var i:Int = 0; while (i < mesh.points.length) {
val v: Vec[3] = mesh.points(i)
var i:Int = 0; while (i < meshPoints.length) {
val v: Vec[3] = meshPoints(i)
// if (v == null) println(s"$i -> null")
// else
sb.append(s"${v.x} ${v.y} ${v.z}\n")
i += 1
}

var t: Int = 0;
while (t < mesh.triangles.length) {
var t: Int = 0; while (t < mesh.triangles.length) {
val triangle = mesh.triangles(t)
sb.append(s"3 ${triangle.v1} ${triangle.v2} ${triangle.v3}\n")
t += 1
Expand Down

0 comments on commit 6937b82

Please sign in to comment.