jMonkeyEngine / jMonkeyEngine/jmonkeyengine

Possible floating point precision issue in corner case using BoundingBox.clip()

Open
#2,556 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

defect Needs investigation
Dominant language
Java
Stars
4.3k
Forks
1.2k
Avg merge
4d 7h
Merged PRs (30d)
14

Description

While working on getting jme compiled to javascript I've encountered an issue: clicks went through some ui elements (lemur).
After a very long debugging session i've isolated the problem to a floating point precision issue in BoundingBox.clip that happens when bounding boxes have zExtent=0.

https://github.com/jMonkeyEngine/jmonkeyengine/blob/8cc308616271604f13f9311207cc1e5ebd7a8169/jme3-core/src/main/java/com/jme3/bounding/BoundingBox.java#L1015-L1073

As you can see, in this code there is a note by @pspeed42 regarding a similar issue that he fixed in the past.

My assumption is that, the way floating point numbers are represented in javascript (doubles?) caused this issue to reappear when the engine was compiled with teavm. I've ended up fixing it in this way.

I’m opening this issue to make it searchable in the future, in case this corner case ever arises during normal use of jME.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with jme3-core/src/main/java/com/jme3/bounding/BoundingBox.java at the referenced BoundingBox.clip() code around lines 1015-1073, including the nearby note about a similar precision issue. Reproduce the zExtent=0 corner case and compare the behavior with the linked workaround; done means the precision problem is confirmed and a project-level resolution is documented or implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.