KotlinNullPointerException when calling set of PolygonShape
- Dominant language
- Kotlin
- Stars
- 4
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
example:
```
val vecs: Array = Array(8) { Vec2(1F, 1F) }
PolygonShape().set(vecs, vecs.size)
```
issue in org.jbox2d.collision.shapes.PolygonShape:
```
// Perform welding and copy vertices into local buffer.
val ps = if (vecPool != null)
vecPool[Settings.maxPolygonVertices]
else
arrayOfNulls(Settings.maxPolygonVertices)
var tempCount = 0
for (i in 0 until n) {
val v = verts[i]
var unique = true
for (j in 0 until tempCount) {
if (MathUtils.distanceSquared(v, ps[j]!!) < 0.5f * Settings.linearSlop) {
unique = false
break
}
}
if (unique) {
ps[tempCount++]!!.set(v)
}
```
ps will be an array of nulls. Unique is true in the first run, since tempCount is 0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in org.jbox2d.collision.shapes.PolygonShape, at the set implementation and the temporary ps buffer shown in the report. Reproduce the supplied Vec2 example and inspect the first unique-vertex path. Done means calling set no longer raises KotlinNullPointerException for that input; check nearby shape behavior for a regression test if the repository provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100