Code Monkey home page Code Monkey logo

Comments (7)

kripken avatar kripken commented on August 14, 2024

How does it render? If it's using GL emulation, could be a limitation of that. Otherwise, it should work, please make as reduced a testcase as you can.

from box2d.js.

jarbot avatar jarbot commented on August 14, 2024

I'm testing with the canvas testbed https://github.com/kripken/box2d.js/blob/master/html5canvas_demo/tests/fallingShapes.js

b2CircleShape(); <- doesn't seem to render the fill or stroke but is still affected by physics simulation

from box2d.js.

kripken avatar kripken commented on August 14, 2024

I think @iforce2d wrote that, iforce2d?

from box2d.js.

iforce2d avatar iforce2d commented on August 14, 2024

Yes. I just did a git clone and it looks ok when running with the box2d.js as in the repo...
@jarbot when you say 'axes' you mean the red and green marker for the body position right? Is the drawCircle function in embox2d-html5canvas-debugDraw.js being entered at all?

from box2d.js.

jarbot avatar jarbot commented on August 14, 2024

The box2d.js from the repo works fine for me too. It's when I do my own build that the circle doesn't render.

when you say 'axes' you mean the red and green marker for the body position right?
Correct.

I set a break point on line 50 of embox2d-html5canvas-debugDraw.js and it never gets hit.

from box2d.js.

iforce2d avatar iforce2d commented on August 14, 2024

@jarbot After building with the latest source I was able to reproduce the problem you describe.

It looks like customizeVTable is not matching the correct function when replacing the virtual functions of b2Draw. Instead of matching DrawCircle, it is matching DrawTransform, so you see an axis marker instead of a circle. As the comments for customizeVTable indicate, the method used to replace virtual functions may not be 100% reliable:

  // Prepare replacement lookup table and add replacements.
  // There is actually no good way to do this! So we do the following hack:
  // We create a fake vtable with canary functions, to detect which actual
  // function is being called

Unfortunately I have no idea why the problem occurs or how to fix it, but I found two ways to avoid it. The first is to remove the -O2 flag from the final step in the makefile, if you can live with a slightly larger/slower build.

The other way is to move the call to customizeVTable for the two circle drawing functions (DrawCircle and DrawSolidCircle) so that they appear after that of DrawTransform (these calls are in embox2d-html5canvas-debugDraw.js). Obviously this is not ideal, because then the transform marker axes do not get drawn... just thought I would mention it anyway.

from box2d.js.

jarbot avatar jarbot commented on August 14, 2024

@iforce2d thank you for spending the time to look into this. I will give the -O2 approach a shot and hope it doesn't get too slow.

from box2d.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.