Skip to content

Commit

Permalink
fix(meshoptimizer) issues with auto-sized params
Browse files Browse the repository at this point in the history
Close LWJGL#981
  • Loading branch information
Spasi committed May 24, 2024
1 parent 9a8113b commit b3f60b7
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 74 deletions.
3 changes: 3 additions & 0 deletions doc/notes/3.3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ This build includes the following changes:

#### Breaking Changes

- meshoptimizer: Fixed autosizing issues. (#981)
* For consistency across the API, auto-sizing of some parameters was removed and the corresponding count parameters were made explicit.
* Auto-sizing is now always based on input parameters, the destination buffers are only checked for enough capacity.
- stb: `stb_image_resize2.h` replaced `stb_image_resize.h` with a new API.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ private class AutoSizeBytesTransform(
} catch(e: NumberFormatException) {
// non-numeric expressions
expression = if (type.mapping.let { it === PrimitiveMapping.POINTER || it === PrimitiveMapping.LONG })
"($expression << $byteShift) ${factor.operator} ${factor.expression}"
"($expression << $byteShift) ${factor.operator} ${if (factor.expression.contains(' ')) "(${factor.expression})" else factor.expression}"
else
"(${type.javaMethodType})(((long)$expression << $byteShift) ${factor.operator} ${factor.expression})"
"(${type.javaMethodType})(((long)$expression << $byteShift) ${factor.operator} ${if (factor.expression.contains(' ')) "(${factor.expression})" else factor.expression})"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ class AutoSizeFactor(
fun scale(operand: String) = if (expression === OPERAND)
operator.replace(OPERAND, operand)
else
"$operand $operator $expression"
"$operand $operator ${if (expression.contains(' ')) "($expression)" else expression}"

fun scaleInv(operand: String) = if (expression === OPERAND)
operatorInv.replace(OPERAND, operand)
else
"$operand $operatorInv $expression"
"$operand $operatorInv ${if (expression.contains(' ')) "($expression)" else expression}"
}

class AutoSize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ RGBA16S
)..void.p("_output", "welded vertices remapping table. The size of buffer must be the same as number of vertices."),
bgfx_vertex_layout_t.const.p("_layout", "vertex stream layout"),
Unsafe..void.const.p("_data", "vertex stream"),
AutoSizeShr("(_index32 ? 2 : 1)", "_output")..uint32_t("_num", "number of vertices in vertex stream"),
AutoSizeShr("_index32 ? 2 : 1", "_output")..uint32_t("_num", "number of vertices in vertex stream"),
bool("_index32", "set to {@code true} if input indices are 32-bit"),
float("_epsilon", "error tolerance for vertex position comparison"),

Expand All @@ -997,7 +997,7 @@ RGBA16S
PointerMapping.DATA_SHORT,
PointerMapping.DATA_INT
)..void.const.p("_indices", "source indices"),
AutoSizeShr("(_index32 ? 2 : 1)", "_indices")..uint32_t("_numIndices", "number of input indices"),
AutoSizeShr("_index32 ? 2 : 1", "_indices")..uint32_t("_numIndices", "number of input indices"),
bool("_index32", "set to {@code true} if input indices are 32-bit"),

returnDoc = "number of output indices after conversion"
Expand Down Expand Up @@ -1030,7 +1030,7 @@ RGBA16S
PointerMapping.DATA_SHORT,
PointerMapping.DATA_INT
)..void.const.p("_indices", "source indices"),
AutoSizeShr("(_index32 ? 2 : 1)", "_indices")..uint32_t("_numIndices", "number of input indices"),
AutoSizeShr("_index32 ? 2 : 1", "_indices")..uint32_t("_numIndices", "number of input indices"),
bool("_index32", "set to {@code true} if input indices are 32-bit")
)

Expand Down
Loading

0 comments on commit b3f60b7

Please sign in to comment.