rednblackgames / HyperLap2D

A powerful, platform-independent, visual editor for complex 2D worlds and scenes.
https://hyperlap2d.rednblack.games/
GNU General Public License v3.0
365 stars 66 forks source link

NullPointerException when Auto Trace #21

Closed kevinbaptist closed 3 years ago

kevinbaptist commented 3 years ago

HyperLap2D Editor crashes when click on Auto Trace (Polygon Component)

To Reproduce

  1. Download my scene.
  2. Click on 'Character' (aka Spineboy) remove Polygon component
  3. Add a new Polygon Component and select Auto Trace and use default values.
  4. Editor crashes. See stack trace below.

Stack Trace

java.lang.NullPointerException
    at games.rednblack.editor.view.ui.dialog.AutoTraceDialogMediator.addAutoTraceMesh(AutoTraceDialogMediator.java:66)
    at games.rednblack.editor.view.ui.dialog.AutoTraceDialogMediator.handleNotification(AutoTraceDialogMediator.java:55)
    at org.puremvc.java.core.View$$Lambda$56/000000002DA4AC20.accept(Unknown Source)
    at org.puremvc.java.patterns.observer.Observer.notifyObserver(Observer.java:72)
    at org.puremvc.java.core.View.lambda$notifyObservers$0(View.java:131)
    at org.puremvc.java.core.View$$Lambda$57/000000002DA9C220.accept(Unknown Source)
    at java.base/java.util.ArrayList.forEach(Unknown Source)
    at org.puremvc.java.core.View.notifyObservers(View.java:131)
    at org.puremvc.java.patterns.facade.Facade.notifyObservers(Facade.java:428)
    at org.puremvc.java.patterns.facade.Facade.sendNotification(Facade.java:386)
    at org.puremvc.java.patterns.facade.Facade.sendNotification(Facade.java:399)
    at games.rednblack.editor.event.ButtonToNotificationListener.touchUp(ButtonToNotificationListener.java:26)
    at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:69)
    at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:352)
    at com.badlogic.gdx.InputMultiplexer.touchUp(InputMultiplexer.java:124)
    at com.badlogic.gdx.InputEventQueue.drain(InputEventQueue.java:86)
    at com.badlogic.gdx.backends.lwjgl3.DefaultLwjgl3Input.update(DefaultLwjgl3Input.java:208)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:394)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:138)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:114)
    at games.rednblack.editor.Main.main(Main.java:57)

Desktop:

fgnm commented 3 years ago

Auto-tracing is possible only for static images (https://github.com/rednblackgames/HyperLap2D/wiki/Basic-Tools#-polygon-tool) and not for animations. There are few reasons why:

You can however add Box2D collision to Spine animations without complicated stuff, EsotericSoftware team provide very good examples including Box2D support.

Anyway, thanks to point out the crash, I'll fix that with an error message instead of NPE.

I think also that you might encounter an issue with your project if you've planned to use forces or velocity. Box2D does not works well with big worlds (it has a limitation on velocity speed), I see that you've used PPWU = 1, the world size should be smaller in order to get Box2D working properly, I suggest something like 64 for Pixels per World Unit. If you aren't interested to box2d gravity and velocity and you need just ray casting to detect collisions, it's fine so :)