Add this method to

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

Add this method to

Postby zgintasz » Sat Mar 12, 2016 6:52 pm

You can see there is:
Code: Select all
public void rayCast (RayCastCallback callback, Vector2 point1, Vector2 point2) {
    rayCastCallback = callback;
    jniRayCast(addr, point1.x, point1.y, point2.x, point2.y);

I suggest to additionally add this one, so we won't have to create new useless Vector2's, when wanting to raycast:

Code: Select all
public void rayCast (RayCastCallback callback, float point1X, float point1Y, float point2X, float point2Y) {
    rayCastCallback = callback;
    jniRayCast(addr, point1X, point1Y, point2X, point2Y);
Posts: 52
Joined: Tue Jan 12, 2016 4:01 pm

Re: Add this method to

Postby dualjack » Tue Mar 22, 2016 8:35 pm

Using vectors isn't useless. It saves time and is more clear, for example you can obtain player position by calling playerOne.position(), not playerOne.x, playerOne.y
Posts: 25
Joined: Sun Mar 30, 2014 6:08 pm

Re: Add this method to

Postby Magnesus » Wed Mar 23, 2016 8:42 am

In this situation it might often be useless. For example when you do some additional operations on the values - you would have to create a new Vector2 (or two) object just for this one task. From garbage collection viewpoint it is bad.
Posts: 1680
Joined: Sun Sep 25, 2011 3:50 pm

Re: Add this method to

Postby captainflyaway » Sun Oct 29, 2017 8:32 pm

I wanted to to ask for the same thing but no spam.

I am heavily using the raycast function in various ways.

While sometimes a vector2 is fine (e.g. center of bodies) many times I would love to just pass in an x and y value for raycasting..

Adding this to libgdx will propably not take that long and I think it is definetly worth it.
Posts: 221
Joined: Mon Feb 20, 2017 7:52 am

Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest