New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte buffer triangle size is wrong #38

Closed
io7m opened this Issue Jan 25, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@io7m
Owner

io7m commented Jan 25, 2017

  /**
   * @return The size in bits of a single triangle index
   */

  @Value.Parameter
  int triangleIndexSizeBits();

  /**
   * @return The size in bits of a single triangle
   */

  @Value.Lazy
  default int triangleSizeBits()
  {
    return Math.multiplyExact(this.triangleIndexSizeBits(), 3);
  }

  /**
   * @return The size in octets of a single triangle
   */

  @Value.Lazy
  default int triangleSizeOctets()
  {
    return this.triangleSizeBits() / 8;
  }

  /**
   * @return The size in octets of a single triangle index
   */

  @Value.Lazy
  default int triangleIndexSizeOctets()
  {
    return this.triangleIndexSizeBits() / 8;
  }

  /**
   * @return A cursor that can access individual triangles
   */

  @Value.Lazy
  default JPRACursor1DType<SMFByteBufferIntegerUnsigned3Type> cursor()
  {
    Preconditions.checkPreconditionL(
      this.triangleCount(),
      Long.compareUnsigned(this.triangleCount(), 0L) > 0,
      x -> "Triangle count must be non-zero");

    return SMFByteBufferCursors.createUnsigned3Raw(
      this.byteBuffer(),
      this.triangleIndexSizeBits(),
      0,
      Math.multiplyExact(this.triangleSizeOctets(), 3));
  }

The last line is incorrect: It multiplies the total triangle size by three, rather than multiplying the size of a single triangle index by three.

@io7m io7m added the bug label Jan 25, 2017

@io7m io7m added this to the 0.8.0 milestone Jan 25, 2017

@io7m io7m self-assigned this Jan 25, 2017

@io7m io7m closed this in 9aaf72b Jan 25, 2017

io7m added a commit that referenced this issue Jan 27, 2017

Merge branch 'release/0.8.0'
Release: io7m-smfj 0.8.0
Code change: Change bytebuffer API to allow failures; introduce a codebase-wide general error type. (tickets: #37)
Code fix: Correct triangle size calculation for ByteBuffer cursors. (tickets: #38)
Code change: Abstract header triangle information into its own SMFTriangles type.
Code change: The byte buffer event method onAllocateTriangleBuffer() now takes an SMFTriangles value.

io7m added a commit that referenced this issue Jan 27, 2017

Merge tag 'io7m-smf-0.8.0' into develop
Release: io7m-smfj 0.8.0

Code change: Change bytebuffer API to allow failures; introduce a codebase-wide general error type. (tickets: #37)
Code fix: Correct triangle size calculation for ByteBuffer cursors. (tickets: #38)
Code change: Abstract header triangle information into its own SMFTriangles type.
Code change: The byte buffer event method onAllocateTriangleBuffer() now takes an SMFTriangles value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment