Class PhysicsWorldBuilder
Utilities for building a physics world.
Inherited Members
Namespace: Unity.Physics.Systems
Assembly: Unity.Physics.dll
Syntax
[BurstCompile]
public static class PhysicsWorldBuilder
Methods
BuildBroadphaseBVHImmediate(ref PhysicsWorld, bool, float, float3)
Build broadphase BoundingVolumeHierarchy of the specified PhysicsWorld (run immediately on the current thread)
Declaration
public static void BuildBroadphaseBVHImmediate(ref PhysicsWorld world, bool haveStaticBodiesChanged, float timeStep, float3 gravity)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |
bool | haveStaticBodiesChanged | True if have static bodies changed. |
float | timeStep | The time step. |
float3 | gravity | The gravity. |
BuildPhysicsWorldImmediate(ref SystemState, ref PhysicsWorldData, float, float3, uint)
Fill specified PhysicsWorld with bodies and joints (using entities from specified queries) and build broadphase BoundingVolumeHierarchy (run immediately on the current thread). Needs a system to to update type handles of physics-related components.
Declaration
public static void BuildPhysicsWorldImmediate(ref SystemState systemState, ref PhysicsWorldData physicsData, float timeStep, float3 gravity, uint lastSystemVersion)
Parameters
Type | Name | Description |
---|---|---|
SystemState | systemState | [in,out] State of the system. |
PhysicsWorldData | physicsData | [in,out] Information describing the physics. |
float | timeStep | The time step. |
float3 | gravity | The gravity. |
uint | lastSystemVersion | The last system version. |
BuildPhysicsWorldImmediate(ref PhysicsWorld, NativeReference<int>, in PhysicsWorldComponentHandles, float, float3, uint, EntityQuery, EntityQuery, EntityQuery)
Fill specified PhysicsWorld with bodies and joints (using entities from specified queries) and build broadphase BoundingVolumeHierarchy (run immediately on the current thread).
Declaration
public static void BuildPhysicsWorldImmediate(ref PhysicsWorld world, NativeReference<int> haveStaticBodiesChanged, in PhysicsWorldData.PhysicsWorldComponentHandles componentHandles, float timeStep, float3 gravity, uint lastSystemVersion, EntityQuery dynamicEntityGroup, EntityQuery staticEntityGroup, EntityQuery jointEntityGroup)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |
NativeReference<int> | haveStaticBodiesChanged | [in,out] The have static bodies changed. |
PhysicsWorldData.PhysicsWorldComponentHandles | componentHandles | The component handles. |
float | timeStep | The time step. |
float3 | gravity | The gravity. |
uint | lastSystemVersion | The last system version. |
EntityQuery | dynamicEntityGroup | Group the dynamic entity belongs to. |
EntityQuery | staticEntityGroup | Group the static entity belongs to. |
EntityQuery | jointEntityGroup | Group the joint entity belongs to. |
ScheduleBroadphaseBVHBuild(ref PhysicsWorld, ReadOnly, in JobHandle, float, bool, float3)
Schedule jobs to build the broadphase of the specified PhysicsWorld.
Declaration
public static JobHandle ScheduleBroadphaseBVHBuild(ref PhysicsWorld world, NativeReference<int>.ReadOnly haveStaticBodiesChanged, in JobHandle inputDep, float timeStep, bool isBroadphaseUpdateMultiThreaded, float3 gravity)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorld | world | [in,out] The world. |
NativeReference<int>.ReadOnly | haveStaticBodiesChanged | The have static bodies changed. |
JobHandle | inputDep | The input dependency. |
float | timeStep | The time step. |
bool | isBroadphaseUpdateMultiThreaded | True if the broadphase update is multi threaded, false if not. |
float3 | gravity | The gravity. |
Returns
Type | Description |
---|---|
JobHandle | A JobHandle. |
SchedulePhysicsWorldBuild(ref SystemState, ref PhysicsWorld, ref NativeReference<int>, in PhysicsWorldComponentHandles, in JobHandle, float, bool, float3, uint, EntityQuery, EntityQuery, EntityQuery)
Schedule jobs to fill specified PhysicsWorld with bodies and joints (using entities from specified queries) and build broadphase BoundingVolumeHierarchy.
Declaration
public static JobHandle SchedulePhysicsWorldBuild(ref SystemState systemState, ref PhysicsWorld world, ref NativeReference<int> haveStaticBodiesChanged, in PhysicsWorldData.PhysicsWorldComponentHandles componentHandles, in JobHandle inputDep, float timeStep, bool isBroadphaseBuildMultiThreaded, float3 gravity, uint lastSystemVersion, EntityQuery dynamicEntityGroup, EntityQuery staticEntityQuery, EntityQuery jointEntityGroup)
Parameters
Type | Name | Description |
---|---|---|
SystemState | systemState | [in,out] State of the system. |
PhysicsWorld | world | [in,out] The world. |
NativeReference<int> | haveStaticBodiesChanged | [in,out] The have static bodies changed. |
PhysicsWorldData.PhysicsWorldComponentHandles | componentHandles | The component handles. |
JobHandle | inputDep | The input dependency. |
float | timeStep | The time step. |
bool | isBroadphaseBuildMultiThreaded | True if the broadphase build is multi threaded, false if not. |
float3 | gravity | The gravity. |
uint | lastSystemVersion | The last system version. |
EntityQuery | dynamicEntityGroup | Group the dynamic entity belongs to. |
EntityQuery | staticEntityQuery | The static entity query. |
EntityQuery | jointEntityGroup | Group the joint entity belongs to. |
Returns
Type | Description |
---|---|
JobHandle | A JobHandle. |
SchedulePhysicsWorldBuild(ref SystemState, ref PhysicsWorldData, in JobHandle, float, bool, float3, uint)
Schedule jobs to fill the PhysicsWorld in specified physicsData with bodies and joints (using entities from physicsData's queries) and build broadphase BoundingVolumeHierarchy. Needs a SystemState to update component handles.
Declaration
public static JobHandle SchedulePhysicsWorldBuild(ref SystemState systemState, ref PhysicsWorldData physicsData, in JobHandle inputDep, float timeStep, bool isBroadphaseBuildMultiThreaded, float3 gravity, uint lastSystemVersion)
Parameters
Type | Name | Description |
---|---|---|
SystemState | systemState | [in,out] State of the system. |
PhysicsWorldData | physicsData | [in,out] Information describing the physics. |
JobHandle | inputDep | The input dependency. |
float | timeStep | The time step. |
bool | isBroadphaseBuildMultiThreaded | True if the broadphase build is multi threaded, false if not. |
float3 | gravity | The gravity. |
uint | lastSystemVersion | The last system version. |
Returns
Type | Description |
---|---|
JobHandle | A JobHandle. |
ScheduleUpdateBroadphase(ref PhysicsWorldData, float, float3, uint, in JobHandle, bool)
Schedule jobs to update the broadphase of the specified PhysicsWorld.
Declaration
public static JobHandle ScheduleUpdateBroadphase(ref PhysicsWorldData physicsWorldData, float timeStep, float3 gravity, uint lastSystemVersion, in JobHandle inputDep, bool isBroadphaseUpdatedMultiThreaded)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorldData | physicsWorldData | [in,out] Information describing the physics world. |
float | timeStep | The time step. |
float3 | gravity | The gravity. |
uint | lastSystemVersion | The last system version. |
JobHandle | inputDep | The input dependency. |
bool | isBroadphaseUpdatedMultiThreaded | True if is broadphase update is multi threaded, false if not. |
Returns
Type | Description |
---|---|
JobHandle | A JobHandle. |
ScheduleUpdateMotionData(ref SystemState, ref PhysicsWorldData, JobHandle)
Update the pre-existing MotionData and MotionVelocity using the current state of the physic object (transform and physics velocities). This method can be used to update the state of the physic simulation when running physic multiple time in the same frame. Assumes that the number of physics objects (static and dynamic) and joints remain the same after the physics world as been built.
Declaration
public static JobHandle ScheduleUpdateMotionData(ref SystemState systemState, ref PhysicsWorldData physicsData, JobHandle inputDeps)
Parameters
Type | Name | Description |
---|---|---|
SystemState | systemState | [in,out] State of the system. |
PhysicsWorldData | physicsData | [in,out] Information describing the physics. |
JobHandle | inputDeps | the input dependencies |
Returns
Type | Description |
---|---|
JobHandle |
UpdateBroadphaseImmediate(ref PhysicsWorldData, float, float3, uint)
Update the broadphase BoundingVolumeHierarchy of the of the specified PhysicsWorld (run immediately on the current thread).
Declaration
public static void UpdateBroadphaseImmediate(ref PhysicsWorldData physicsWorldData, float timeStep, float3 gravity, uint lastSystemVersion)
Parameters
Type | Name | Description |
---|---|---|
PhysicsWorldData | physicsWorldData | |
float | timeStep | |
float3 | gravity | |
uint | lastSystemVersion |
UpdateMotionDataImmediate(ref SystemState, ref PhysicsWorldData)
Update the pre-existing MotionData and MotionVelocity using the current state of the physic object (transform and physics velocities). This method can be used to update the state of the physic simulation when running physic multiple time in the same frame. Assumes that the number of physics objects (static and dynamic) and joints remain the same after the physics world as been built.
Declaration
public static void UpdateMotionDataImmediate(ref SystemState systemState, ref PhysicsWorldData physicsData)
Parameters
Type | Name | Description |
---|---|---|
SystemState | systemState | [in,out] State of the system. |
PhysicsWorldData | physicsData | [in,out] Information describing the physics. |