Skip to content

Commit

Permalink
PhysxQuery: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
capdevon committed Nov 16, 2023
1 parent b4bb3b7 commit 621ab77
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions game/src/main/java/com/capdevon/physx/PhysxQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.logging.Logger;

import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.objects.PhysicsRigidBody;
Expand All @@ -14,9 +13,7 @@
* @author capdevon
*/
public class PhysxQuery {

private static final Logger logger = Logger.getLogger(PhysxQuery.class.getName());


/**
* DefaultRaycastLayers
*/
Expand All @@ -29,19 +26,21 @@ public class PhysxQuery {
/**
* A private constructor to inhibit instantiation of this class.
*/
private PhysxQuery() {}

private PhysxQuery() {
}

/**
* Computes and stores colliders inside the sphere.
*
* @param position - Center of the sphere.
* @param radius - Radius of the sphere.
* @param layerMask - A Layer mask defines which layers of colliders to include in the query.
* @param func - Specifies a function to filter colliders.
* @param position Center of the sphere.
* @param radius Radius of the sphere.
* @param layerMask A Layer mask defines which layers of colliders to include in the query.
* @param func Specifies a function to filter colliders.
* @return Returns an array with all PhysicsRigidBody touching or inside the
* sphere.
* sphere.
*/
public static List<PhysicsRigidBody> checkSphere(Vector3f position, float radius, int layerMask, Predicate<PhysicsRigidBody> func) {
public static List<PhysicsRigidBody> checkSphere(Vector3f position, float radius, int layerMask,
Predicate<PhysicsRigidBody> func) {

List<PhysicsRigidBody> results = new ArrayList<>(10);
for (PhysicsRigidBody pco : PhysicsSpace.getPhysicsSpace().getRigidBodyList()) {
Expand All @@ -56,27 +55,28 @@ public static List<PhysicsRigidBody> checkSphere(Vector3f position, float radius
}
return results;
}

public static List<PhysicsRigidBody> checkSphere(Vector3f position, float radius, int layerMask) {
return checkSphere(position, radius, layerMask, IdentityFunction);
}

public static List<PhysicsRigidBody> checkSphere(Vector3f position, float radius) {
return checkSphere(position, radius, ALL_LAYERS, IdentityFunction);
}

/**
* Computes and stores colliders inside the sphere into the provided buffer.
* Does not attempt to grow the buffer if it runs out of space.
*
* @param position - Center of the sphere.
* @param radius - Radius of the sphere.
* @param results - The buffer to store the results into.
* @param layerMask - A Layer mask defines which layers of colliders to include in the query.
* @param func - Specifies a function to filter colliders.
* @param position Center of the sphere.
* @param radius Radius of the sphere.
* @param results The buffer to store the results into.
* @param layerMask A Layer mask defines which layers of colliders to include in the query.
* @param func Specifies a function to filter colliders.
* @return Returns the amount of colliders stored into the results buffer.
*/
public static int checkSphereNonAlloc(Vector3f position, float radius, PhysicsRigidBody[] results, int layerMask, Predicate<PhysicsRigidBody> func) {
public static int checkSphereNonAlloc(Vector3f position, float radius, PhysicsRigidBody[] results, int layerMask,
Predicate<PhysicsRigidBody> func) {

int numColliders = 0;
for (PhysicsRigidBody pco : PhysicsSpace.getPhysicsSpace().getRigidBodyList()) {
Expand Down

0 comments on commit 621ab77

Please sign in to comment.