dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
84 stars 20 forks source link

Fix writePLY uchar color export. #427

Closed aidanmorales closed 2 weeks ago

aidanmorales commented 2 weeks ago

Issue #425

Reverted all formatting changes. Code change shown below:

endian <- if (format == "little_endian") "little" else "big"
if (nrow(Vertices)) {
  for (i in seq_len(nrow(Vertices))) {
    writeBin(as.numeric(Vertices[i,]), con, size=4, endian=endian)
    if (withColors)
      writeBin(as.integer(Colors[i,]), con, size=1, endian=endian)
  }
}

Original code threw: Error in Colors[i, ] : subscript out of bounds when setting withColors = FALSE with endian formats.

endian <- if (format == "little_endian") "little" else "big"
if (nrow(Vertices)) {
  if (!nrow(Colors))
    writeBin(as.numeric(t(Vertices)), con, size=4, endian=endian)
  else {
    for (i in seq_len(nrow(Vertices))) {
      writeBin(Vertices[i,], con, size=4, endian=endian)
      writeBin(Colors[i,], con, size=1)
    }
  }
}
dmurdoch commented 2 weeks ago

That is still mainly irrelevant changes. What are the important ones? I can't see any.