Is Sin and Cos calculated in c2 via look up tables?

0 favourites
  • 5 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hey,

    Does anyone know if sin and cos have look up tables in c2 to speed it up or is it calculated every time it is called?

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't know, but based on performance results I'm leaning towards calculated every time.

  • It uses javascript's Math.sin , Math.cos function call.

  • Ruskul

    lookup tables don't innately speed things up, and would only really be used on weaker hardware, or places where you need the same sin/cos value over and over, which is rarely true when they're being fed continuously changing floats like they are in construct.

    C2 afaik uses the JS Math.sin() / Math.cos() functions, which likely work using the fastest possible implementation of trig functions using your hardware. You're not going to get a performance improvement by using a lookup table, and you'll likely get way worse performance if you try. If you have to recalculate the same sin/cos multiple times, do it once in a variable. this is the "fast" way to do things. Even if you do this you might not get any performance gains since most new js engines will dynamically find these little things and optimize them with their JIT compiler, unless its a really significant overuse in your code.

  • QuaziGNRLnose

    That's good to know, It's crazy how smart compilers are at this point. My problem is, is that I am never sure if I am slowing things down or doing good. I have been setting a system that sorts the objects and tries to ensure I can compute sin(a) and then use it on all objects with the same angle calculation. after those are taken care of I then calculate the rest. I try to save as much cpu time as possible due to a heavy physics system.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)