Author Topic: Polyline.setLineLength?  (Read 2494 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Polyline.setLineLength?
« on: September 23, 2017, 01:12:44 am »
I'm writing the following for my son (sorry about the captured frame-rate). The thing about Polyline.update(...) is that it's expensive to always create a new array (I suppose that I could store it, then edit it but that's quirky), and it's inconvenient. Also, the following is the code that increases the length of my laser (deltaTime*10f breaks the numbers by being making them too large):

Code: [Select]
SimpleVector pos = bridge.getTransformedCenter();
pos.y -= 160f;
SimpleVector forward = bridge.getZAxis();
laserLength *= (1f+(deltaTime*6f));
laser.update(new SimpleVector[]{pos, pos.calcAdd(new SimpleVector(forward.x*laserLength, forward.y*laserLength, forward.z*laserLength))});

https://www.youtube.com/watch?v=ui6R1ZDcEqI

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Polyline.setLineLength?
« Reply #1 on: September 23, 2017, 07:50:57 pm »
Polyline represents a set of lines, not just one. I don't see how you could apply to anything but a Polyline with just one line. It's just not compatible with the way in which the are rendered of better: What they are. Creating these arrays in desktop Java is cheap. On Android, I would simply reuse the array and the vectors inside.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: Polyline.setLineLength?
« Reply #2 on: September 23, 2017, 09:12:54 pm »
That's true. What about a getPoints() method so at least we don't have to hold the array ourselves.

And the lwjgl thing? Obviously, 2.9x won't work forever so there has to be a plan forward lest jpct's hardware renderer die. I'm just asking you what your plan is.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Polyline.setLineLength?
« Reply #3 on: September 25, 2017, 08:44:20 am »
Wait until it's inevitable to upgrade. I just don't like way in which LWJGL went...from a simple API to a behemoth that tries to cover everything.

getPoints() doesn't make much sense, because the array is just a container. It gets converted internally anway, I don't store it.