-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BodyManager: add the 2 public methods
- Loading branch information
1 parent
4016e6c
commit 4dbbac7
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,21 @@ of this software and associated documentation files (the "Software"), to deal | |
|
||
import com.github.stephengold.joltjni.readonly.ConstBodyCreationSettings; | ||
import com.github.stephengold.joltjni.readonly.ConstBodyId; | ||
import com.github.stephengold.joltjni.readonly.ConstBroadPhaseLayerInterface; | ||
|
||
/** | ||
* A container for bodies. | ||
* | ||
* @author Stephen Gold [email protected] | ||
*/ | ||
public class BodyManager extends NonCopyable { | ||
// ************************************************************************* | ||
// fields | ||
|
||
/** | ||
* protect the BroadPhaseLayerInterface from garbage collection | ||
*/ | ||
private ConstBroadPhaseLayerInterface layerMap; | ||
// ************************************************************************* | ||
// constructors | ||
|
||
|
@@ -173,6 +181,16 @@ public BodyVector getBodies() { | |
return result; | ||
} | ||
|
||
/** | ||
* Access the (application-provided) interface for mapping object layers to | ||
* broadphase layers. | ||
* | ||
* @return the pre-existing instance, or {@code null} if none | ||
*/ | ||
public ConstBroadPhaseLayerInterface getBroadPhaseLayerInterface() { | ||
return layerMap; | ||
} | ||
|
||
/** | ||
* Return the maximum number of bodies the manager can support. | ||
* | ||
|
@@ -184,6 +202,24 @@ public int getMaxBodies() { | |
|
||
return result; | ||
} | ||
|
||
/** | ||
* Initialize the manager. | ||
* | ||
* @param maxBodies the desired maximum number of rigid bodies that can be | ||
* added | ||
* @param numBodyMutexes the desired number of mutexes to allocate, or 0 for | ||
* the default number | ||
* @param map the desired map from object layers to broad-phase layers (not | ||
* null, alias created) | ||
*/ | ||
public void init(int maxBodies, int numBodyMutexes, | ||
ConstBroadPhaseLayerInterface map) { | ||
this.layerMap = map; | ||
long managerVa = va(); | ||
long mapVa = map.va(); | ||
init(managerVa, maxBodies, numBodyMutexes, mapVa); | ||
} | ||
// ************************************************************************* | ||
// native private methods | ||
|
||
|
@@ -205,4 +241,7 @@ native private static void draw(long managerVa, long drawSettingsVa, | |
native private static long getBodies(long managerVa); | ||
|
||
native private static int getMaxBodies(long managerVa); | ||
|
||
native private static void init( | ||
long managerVa, int maxBodies, int numBodyMutexes, long mapVa); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters