java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.PhysicsScene
- All Implemented Interfaces:
ConstJoltPhysicsObject
,RefTarget
,AutoCloseable
,Comparable<JoltPhysicsObject>
The creation settings of a set of bodies.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the specified body to the scene.void
addConstraint
(TwoBodyConstraintSettings constraint, int body1, int body2) Add the specified constraint to the scene.void
addSoftBody
(ConstSoftBodyCreationSettings softBody) Add the specified soft body to the scene.boolean
createBodies
(PhysicsSystem system) Instantiate the bodies in the scene.boolean
Correct any incorrectly scaled shapes in the scene.void
fromPhysicsSystem
(PhysicsSystem system) Load the current state of the specified physics system.Access the body-creation settings as a Java array.int
Count the active references to the nativePhysicsScene
.Access the soft-body creation settings as a Java array.void
saveBinaryState
(StreamOut stream, boolean saveShapes, boolean saveGroupFilter) Save the scene to the specified binary stream.void
Mark the nativePhysicsScene
as embedded.static PhysicsSceneResult
sRestoreFromBinaryState
(StreamIn stream) Attempt to de-serialize a saved scene from a stream.toRef()
Create a counted reference to the nativePhysicsScene
.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
-
Constructor Details
-
PhysicsScene
public PhysicsScene()Instantiate an empty scene.
-
-
Method Details
-
addBody
Add the specified body to the scene.- Parameters:
body
- the body settings (not null, unaffected)
-
addConstraint
Add the specified constraint to the scene.- Parameters:
constraint
- the constraint settings (not null, unaffected)body1
- the index of the first body in the bodies listbody2
- the index of the 2nd body in the bodies list
-
addSoftBody
Add the specified soft body to the scene.- Parameters:
softBody
- the soft-body settings (not null, unaffected)
-
createBodies
Instantiate the bodies in the scene.- Parameters:
system
- where to add the bodies (not null, modified)- Returns:
true
if successful, otherwisefalse
-
fixInvalidScales
public boolean fixInvalidScales()Correct any incorrectly scaled shapes in the scene.- Returns:
true
if successful, otherwisefalse
-
fromPhysicsSystem
Load the current state of the specified physics system.- Parameters:
system
- the physics system to load from (not null, unaffected)
-
getBodies
Access the body-creation settings as a Java array.- Returns:
- a new array of new JVM objects with the pre-existing native objects assigned
-
getSoftBodies
Access the soft-body creation settings as a Java array.- Returns:
- a new array of new JVM objects with pre-existing native objects assigned
-
saveBinaryState
Save the scene to the specified binary stream. The scene is unaffected.- Parameters:
stream
- the stream to write to (not null)saveShapes
- if true, save the shapessaveGroupFilter
- if true, save the group filter
-
sRestoreFromBinaryState
Attempt to de-serialize a saved scene from a stream.- Parameters:
stream
- (not null)- Returns:
- a new object
-
getRefCount
public int getRefCount()Count the active references to the nativePhysicsScene
. The scene is unaffected.- Specified by:
getRefCount
in interfaceRefTarget
- Returns:
- the count (≥0)
-
setEmbedded
public void setEmbedded()Mark the nativePhysicsScene
as embedded.- Specified by:
setEmbedded
in interfaceRefTarget
-
toRef
Create a counted reference to the nativePhysicsScene
.
-