Skip to content
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

Performance #38

Open
1j01 opened this issue Sep 1, 2024 · 0 comments
Open

Performance #38

1j01 opened this issue Sep 1, 2024 · 0 comments

Comments

@1j01
Copy link
Owner

1j01 commented Sep 1, 2024

  • I think grass is the main thing, at this point; I did a proof of concept of PIXI.js grass in a project called Skelemon (including hooking into the entities bar to add rendering support for PIXI.js based entities, and integrating canvas 2d API and PIXI.js entities into the scene, albeit on different layers)...
    • Measure the improvement
  • avoid collision checks in SimpleActor by checking if it can move all the way in one step (wouldn't this allow for tunneling?)
  • avoid collision checks in Butterfly, which checks 50 times per step always
  • optimize find_ground_angle using world.collision, move into World
  • terrain_optimized: could probably optimize terrain in edit mode as soon as the world loads, now that it doesn't modify the original entities (this would be more for debug views than perf)
1j01 added a commit that referenced this issue Sep 3, 2024
- Install PIXI.js
- Overlay three canvases (background, PIXI.js, and vanilla 2d canvas)
- Handle PIXI.js for entity previews in entities sidebar
- Add Snake entity based on a PIXI.js SimpleRope example
  (The texture is also from this example.
  The art style kinda fits, in a funny way.)

I originally prototyped this PIXI.js integration in a separate project
called Skelemon (which so far has only been a prototype of this).
I ported it over by copying files atop the equivalent files and then
reverting changes I didn't want, so I've already worked out a lot of
details, like getting the canvases synced to the same frame,
and generalizing code that was much easier to develop in an
ad hoc fashion initially.

PIXI.js should help a lot with performance, see issue:
#38

Caveats:
- There may be overhead in using multiple canvases, until
  everything is moved over to PIXI.js.
- The game now requires WebGL.
  This could be mitigated using the pixi.js-legacy package.
- Entities using PIXI.js are not reflected in the Water yet;
  only the vanilla 2d canvas's content is reflected.
- Entities using PIXI.js cannot be sorted together with other entities
  in this scheme.
  Perhaps entities with vanilla canvas 2d drawing implementations
  integrated as PIXI.Sprite objects, to allow sorting.
1j01 added a commit that referenced this issue Sep 5, 2024
- Overlay three canvases (background, PIXI.js, and vanilla 2d canvas)
- Handle PIXI.js for entity previews in entities sidebar
- Add Snake entity based on a PIXI.js SimpleRope example
  (The texture is also from this example.
  The art style kinda fits, in a funny way.)

I originally prototyped this PIXI.js integration in a separate project
called Skelemon (which so far has only been a prototype of this).
I ported it over by copying files atop the equivalent files and then
reverting changes I didn't want, so I've already worked out a lot of
details, like getting the canvases synced to the same frame,
and generalizing code that was much easier to develop in an
ad hoc fashion initially.

PIXI.js should help a lot with performance, see issue:
#38

Caveats:
- There may be overhead in using multiple canvases, until
  everything is moved over to PIXI.js.
- The game now requires WebGL.
  This could be mitigated using the pixi.js-legacy package.
- Entities using PIXI.js are not reflected in the Water yet;
  only the vanilla 2d canvas's content is reflected.
- Entities using PIXI.js cannot be sorted together with other entities
  in this scheme.
  Perhaps entities with vanilla canvas 2d drawing implementations
  integrated as PIXI.Sprite objects, to allow sorting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant