Changelog
[0.50.0] - 2021-09-17
Changed
- Upgraded com.unity.burst to 1.5.5
- Adjusted code to remove obsolete APIs across all jobs inheriting IJobEntityBatch
- Resources/ (used by Debug Draw) has been renamed DebugDisplayResources/ and now loads assets differently
Removed
- All usages of PhysicsExclude from Demo and Runtime code.
Fixed
- An issue with the rendering pipeline used for the package samples, which caused none of the samples to render post conversion
- An issue with the materials present in the samples as their colors were no longer correct
[0.10.0-preview.1] - 2021-06-25
Upgrade guide
- Added
PhysicsWorldIndex
shared component, which is required on every Entity that should be involved in physics simulation (body or joint). ItsValue
denotes the index of physics world that the Entity belongs to (0 for defaultPhysicsWorld
processed byBuildPhysicsWorld
,StepPhysicsWorld
andExportPhysicsWorld
systems). Note that Entities for different physics worlds will be stored in separate chunks, due to different values of shared component. PhysicsExclude
component is obsolete, but will still work at least until 2021-10-01. Instead of addingPhysicsExclude
when you want to exclude an Entity from physics simulation, you can achieve the same thing by removing the requiredPhysicsWorldIndex
shared component.HaveStaticBodiesChanged
was added toSimulationStepInput
. It's a NativeArray of size 1, used for optimization of static body synchronization. ### Changes- Dependencies
- Run-Time API
- Added
BlobAssetReferenceColliderExtension
functions for ease of use and to help avoid unsafe code- Added reinterpret_cast-like logic via
BlobAssetReference<Collider>.As<To>
whereTo
is the destination collider struct type. The extension will return a reference to the desired type. - Added reinterpret_cast-like logic via
BlobAssetReference<Collider>.AsPtr<To>
whereTo
is the destination collider struct type. The extension will return a pointer to the desired type. - Added an easy conversion helper to
PhysicsCollider
viaBlobAssetReference<Collider>.AsComponent()
- Added
ColliderCastInput
andColliderDistanceInput
constructors that do not require unsafe code, along withSetCollider
function to change a collider after creation of the input struct.
- Added reinterpret_cast-like logic via
PhysicsWorldData
is a new structure encapsulatingPhysicsWorld
and other data and queries that are necessary for simulating a physics world.PhysicsWorldBuilder
andPhysicsWorldExporter
are new utility classes providing methods for building aPhysicsWorld
and exporting its data to ECS components, with options to tweak queries that fetch Entities for the physics world.PhysicsWorldStepper
is a new helper class for scheduling physics simulation jobs. ItsSimulationCreator
delegate and methods that need to instantiate anISimulation
require physics world index to be passed in.BuildPhysicsWorld
was refactored to keep the data inPhysicsWorldData
and usePhysicsWorldBuilder
.WorldFilter
field holds its physics world index (0).StepPhysicsWorld
was refactored to usePhysicsWorldStepper
.ExportPhysicsWorld
was refactored to usePhysicsWorldExporter
, which knows how to copyCollisionWorld
and export data to Entities fetched by its queries.- Optimized
Collider.Clone()
to no longer create an extra copy of theCollider
memory during the clone process.
- Added
- Authoring/Conversion API
- Physics Body authoring component has a new field
WorldIndex
in Advanced section, with default value of 0 (meaning that it belongs to the defaultPhysicsWorld
). Objects that don't have Physics Body authoring component on them or on any parent in the hierarchy will also get the default value.CustomTags
field was moved to the Advanced section. PhysicsRuntimeExtensions
has new template methodsRegisterPhysicsRuntimeSystem*
which can be used in system'sOnStartRunning()
method for automatic dependency management for non-default physics runtime data. They are analoguous to the existing non-templated counterparts, just require a separateComponentData
type for each non-default physics world.
- Physics Body authoring component has a new field
- Run-Time Behavior
- Added support for multiple
PhysicsWorlds
, where each body in each world is represented by a separate Entity. Each entity must have all components that are needed for physics simulation in its world. - Non-default physics worlds require custom systems that will processs (build, simulate and export) them, from Entities that are marked with appropriate
PhysicsWorldIndex
shared component. Storage ofPhysicsWorld
is also controlled by the user. A number of utilities was added to make this easier.
- Added support for multiple
- Authoring/Conversion Behavior ### Fixes
- Fixed a bug in Graphical Interpolation where
LocalToWorld
was not updated if rendering and physics were exactly in sync. - Fixed the spring constant calculation during joint conversion
- Fixed the configurable joint linear limit during joint conversion
- Physics Debug Display: Draw Collider Edges performance improved
- Physics Debug Display: Draw Collider Edges for sphere colliders improved
[0.9.0-preview.4] - 2021-05-19
Upgrade guide
- An extra check was added to verify that the data provided to the 'Start/End' properties of 'RayCastInput/ColliderCastInput' does not generate a cast length that is not too long. The maximum length allowed is half of 'float.MaxValue'
- Integrity checks can be now be enabled and disabled by toggling the new "DOTS/Physics/Enable Integrity Checks" menu item. Integrity checks should be enabled when checking simulation quality and behaviour. Integrity checks should be disabled when measuring performance. When enabled, Integrity checks will be included in a in Development build of a standalone executable, but are always excluded in release builds.
- An extra check was added to verify that the data provided to the
Start
&End
properties ofRayCastInput
&ColliderCastInput
does not generate a cast length that is too long. The maximum length allowed is half offloat.MaxValue
### Changes - Dependencies
- Updated Burst to
1.5.3
- Updated Collections to
0.17.0-preview.18
- Updated Entities to
0.19.0-preview.30
- Updated Jobs to
0.10.0-preview.18
- Updated Test Framework to
1.1.24
- Updated Burst to
- Added
partial
keyword to allSystemBase
-derived classes ### Fixes - Fixed the condition for empty physics world, to return from
BuildPhysicsWorld.OnUpdate()
before callingPhysicsWorld.Reset()
. - Fixed a bug in
DebugDisplay.Managed.Instance.Render()
where only half of Debug Display lines were rendered for a MeshTopology.Lines type - Fixed a bug in
CalculateAabb
method for cylinder collider that was increasing the AABB height axis by radius - Integrity checks can now be toggled via an Editor menu item, and can be run in Development builds.
- Fixed a bug where PhysicsDebugDisplay lines would disappear if editor was paused in PlayMode
Known Issues
[0.8.0-preview.1] - 2021-03-26
Upgrade guide
Changes
Dependencies
- Updated Collections from
0.16.0-preview.22
to0.17.0-preview.10
- Updated Entities from
0.18.0-preview.42
to0.19.0-preview.17
- Updated Jobs from
0.9.0-preview.24
to0.10.0-preview.10
- Updated Collections from
Run-Time API
- Made
CollisionEvent
andTriggerEvent
implement a commonISimulationEvent
interface allowing them to be equatable and comparable. - Made
ColliderKey
comparable. - Exposed a
MotionVelocity.IsKinematic
property. - Exposed a
PhysicsMass.IsKinematic
property. - Added a
PhysicsMassOverride.SetVelocityToZero
field. IfPhysicsMassOverride.IsKinematic
, is a non-zero value, then a body's mass and inertia are made infinite, though it's motion will still be integrated. IfPhysicsMassOverride.SetVelocityToZero
is also a non-zero value, the kinematic body will ignore the values in the associatedPhysicsVelocity
component and no longer move.
- Made
Run-Time Behavior
- If a body has infinite mass and/or inertia, then linear and/or angular damping will no longer be applied respectively.
Fixes
- Fixed a bug in
ExportPhysicsWorld.CheckColliderFilterIntegrity()
method that was giving false integrity errors due to the fact that it had incorrectly handled compound colliders, if they (or their children) had aGroupIndex
on theFilter
that is not 0. - Added an extra change check on the
Parent
component type toCheckStaticBodyChangesJob
in theBuildPhysicsWorld
system. ### Known Issues
[0.7.0-preview.3] - 2021-02-24
Upgrade guide
RegisterPhysicsRuntimeSystemReadOnly()
andRegisterPhysicsRuntimeSystemReadWrite()
(both registered as extensions ofSystemBase
) should be used to manage physics data dependencies instead of the oldAddInputDependency()
andGetOutputDependency()
approach. Users should declare theirUpdateBefore
andUpdateAfter
systems as before and additionally only call one of the two new functions in their system'sOnStartRunning()
, which will be enough to get an automatic update of theDependency
property without the need for manually combining the dependencies as before. Note that things have not changed if you want to read or write physics runtime data directly in your system'sOnUpdate()
- in that case, you still need to ensure that jobs from previous systems touching physics runtime data are complete, by completing theDependency
. Also note thatBuildPhysicsWorld.AddInputDependencyToComplete()
still remains needed for jobs that need to finish before any changes are made to the PhysicsWorld, if your system is not scheduled in between other 2 physics systems that will do that for you.The
Constraint.DefaultSpringFrequency
andConstraint.DefaultSpringDamping
values have been changed. The original defaults were setup to match the defaultfixedDeltaTime
and therefore assumed a 50hz simulation timestep. The current default simulation step is now 60hz and so the default spring parameters have been changed to match this assumption. This change may affect more complex Joint setups that are close to being overconstrained, but generally it should not break the original intent of the setup.
Changes
Dependencies
- Updated minimum Unity Editor version from
2020.1.0f1
to2020.2.4f1
- Updated Collections from
0.15.0-preview.21
to0.16.0-preview.22
- Updated Entities from
0.17.0-preview.41
to0.18.0-preview.42
- Updated Jobs from
0.8.0-preview.23
to0.9.0-preview.24
- Updated minimum Unity Editor version from
Run-Time API
- Added a
CompoundCollider.Child.Entity
& associatedChildCollider.Entity
field. This field is useful in creating a link back to the original Entity from which the Child was built. - Added
Integrator.Integrate()
which takes aRigidTransform
,MotionVelocity
and time step and integrates the transform in time. This can be used to integrate forward in time, but also to undo integration if necessary (by providing the negative time). - Removed
ModifiableJacobianHeader.HasColliderKeys
,ModifiableJacobianHeader.ColliderKeyA
andModifiableJacobianHeader.ColliderKeyB
as they are not meant to be read by users, but to fill the data for collision events. - Removed
SimulationCallbacks.Phase.PostSolveJacobians
as it doesn't have real use cases and it's causing inconsistencies between the two engines. Instead, users should schedule their jobs afterStepPhysicsWorld
and beforeExportPhysicsWorld
to achieve a similar effect. - Added
ClampToMaxLength()
toUnity.Physics.Math
, which reduces the length of specifiedfloat3
vector to specified maxLength if it was bigger. ColliderCastHit
andDistanceHit
now haveQueryColliderKey
field. If the input ofColliderCast
orColliderDistance
queries contains a non-convex collider, this field will contain the collider key of the input collider. Otherwise, its value will beColliderKey.Empty
.- Removed
AddInputDependency()
andGetOutputDependency()
from all physics systems as dependencies are now handled in a different way (see below). - Added
RegisterPhysicsRuntimeSystemReadOnly()
andRegisterPhysicsRuntimeSystemReadWrite()
that are both extension methods forSystemBase
and are used to declare interaction with the runtime physics data (stored in PhysicsWorld). One should call one of these in their system'sOnStartRunning()
(usingthis.RegisterPhysicsRuntimeSystemReadOnly()
orthis.RegisterPhysicsRuntimeSystemReadWrite()
) to declare interaction with the physics data, which will translate to automatic data dependencies being included in theSystemBase.Dependency
property of any system. - Previously internal functions in
ColliderKey
,ColliderKeyPath
andChildCollider
are now public to aid the traversal of aCollider
hierarchy.
- Added a
Authoring/Conversion API
- A new
CompoundCollider.Child.Entity
field is automatically populated through the conversion system, to point at the converted Entity associated with the GameObject that contacted thePhysicsShapeAuthoring
component.- This default setting can be overriden by adding a
PhysicsRenderEntity
component data. The common use case for this is where noMeshRenderer
component is on the converted child Entity, and it is desirable to redirect to another Entity with a graphical representation in a different branch of the hierarchy.
- This default setting can be overriden by adding a
- Added a
PhysicsRenderEntity
component data. This is primarily used for populating aCompoundCollider.Child.Entity
field where there was no graphical representation on the same GameObject that has aPhysicsShapeAuthoring
component.
- A new
Run-Time Behavior
ColliderDistance
andColliderCast
queries now support non-convex input colliders (Compounds, Meshes and Terrains).
Authoring/Conversion Behavior
Fixes
- Fixed a bug in
ExportPhysicsWorld.OnCreate()
method that relied on the fact thatBuildPhysicsWorld.OnCreate()
was executed before it. - Fixed
CompoundCollider.RefreshCollisionFilter()
when compound contains compound children.
Known Issues
[0.6.0-preview.3] - 2021-01-18
Upgrade guide
PhysicsStep.ThreadCountHint
has now been removed, so if you had it set to a value less or equal to 0 (meaning you wanted single threaded simulation with small number of jobs), you now need to set the new fieldPhysicsStep.MultiThreaded
to false. Otherwise, it will be set to true, meaning you'll get a default multi threaded simulation as ifPhysicsStep.ThreadCountHint
is a positive number.
Changes
Dependencies
- Updated minimum Unity Editor version from
2020.1.0f1
to2020.1.9f1
- Updated Burst from
1.3.7
to1.4.1
- Updated Collections from
0.14.0-preview.16
to0.15.0-preview.21
- Updated Entities from
0.16.0-preview.21
to0.17.0-preview.41
- Updated Jobs from
0.7.0-preview.17
to0.8.0-preview.23
- Updated minimum Unity Editor version from
Run-Time API
- Added a
Collider.Clone()
function. - Added
Material
toIQueryResult
interface and its implementations (RaycastHit
,ColliderCastHit
,DistanceHit
). All hits now have material information of the primitive that was hit. - Added the following interfaces to
ICollidable
and all its implementations:- These API's represent the equivalent of the familiar GameObjects' query interface, with the addition of Custom version, which takes a collector and enables one to use custom filtering logic when accepting query hits.
bool CheckSphere(float3 position, float radius, CollisionFilter filter, QueryInteraction interaction)
bool OverlapSphere(float3 position, float radius, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction interaction)
bool OverlapSphereCustom<T>(float3 position, float radius, ref T collector, CollisionFilter filter, QueryInteraction interaction) where T : struct, ICollector<DistanceHit>
bool CheckCapsule(float3 point1, float3 point2, float radius, CollisionFilter filter, QueryInteraction queryInteraction)
bool OverlapCapsule(float3 point1, float3 point2, float radius, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction)
bool OverlapCapsuleCustom<T>(float3 point1, float3 point2, float radius, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction) where T : struct, ICollector<DistanceHit>
bool CheckBox(float3 center, quaternion orientation, float3 halfExtents, CollisionFilter filter, QueryInteraction queryInteraction)
bool OverlapBox(float3 center, quaternion orientation, float3 halfExtents, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction)
bool OverlapBoxCustom<T>(float3 center, quaternion orientation, float3 halfExtents, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction where T : struct, ICollector<DistanceHit>
bool SphereCast(float3 origin, float radius, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction)
bool SphereCast(float3 origin, float radius, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction)
bool SphereCastAll(float3 origin, float radius, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction)
bool SphereCastCustom<T>(float3 origin, float radius, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction) where T : struct, ICollector<ColliderCastHit>
bool BoxCast(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction)
bool BoxCast(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction)
bool BoxCastAll(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction)
bool BoxCastCustom<T>(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction) where T : struct, ICollector<ColliderCastHit>
bool CapsuleCast(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction)
bool CapsuleCast(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction)
bool CapsuleCastAll(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction)
bool CapsuleCastCustom<T>(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction) where T : struct, ICollector<ColliderCastHit>
- Exposed the following collider initialization functions:
SphereCollider.Initialize(SphereGeometry geometry, CollisionFilter filter, Material material)
CapsuleCollider.Initialize(CapsuleGeometry geometry, CollisionFilter filter, Material material)
BoxCollider.Initialize(BoxGeometry geometry, CollisionFilter filter, Material material)
CylinderCollider.Initialize(CylinderGeometry geometry, CollisionFilter filter, Material material)
- These functions enable the creation of colliders on stack, as opposed to only creating them using
BlobAssetReference<Collider>.Create()
methods.
- Replaced all instances of
IJobChunk
withIJobEntityBatch
orIJobEntityBatchWithIndex
for better performance. CollisionWorld
andDynamicsWorld
now store index maps linking Entity with RigidBody and Joint indices.- Use
PhysicsWorld.GetRigidBodyIndex(Entity)
to get a RigidBody index for the Bodies array. This replaces the variant fromPhysicsWorldExtensions
. - Use
PhysicsWorld.GetJointIndex(Entity)
to get a Joint index for the Joints array - If map is invalid or Entity is not in map then an index of -1 is returned.
BuildPhysicsWorld
system updates the maps on update. If updating the world manually then callPhysicsWorld.UpdateIndexMaps()
to refresh.
- Use
- Removed
PhysicsStep.ThreadCountHint
since the value is now retrieved fromJobsUtility.JobWorkerCount
. - Added
PhysicsStep.SingleThreaded
to request the simulation with a very small number of single threaded jobs (previouslyPhysicsStep.ThreadCountHint
<= 0). - Added
MeshCollider.Filter
andCompoundCollider.Filter
setters that set the collision filter on all triangles of the mesh and children of the compound. Furthermore, added theCompoundCollider.RefreshCollisionFilter()
to be called when a child filter changes, so that the root level of the compound collider can be updated. Collider
now has aFilter
setter regardless of the type of the collider.Collider
now has aRespondsToCollision
getter that shows if it will participate in collision, or only move and intercept queries.
- Added a
Authoring/Conversion API
Run-Time Behavior
ExportPhysicsWorld
system should now only get updated when there is at least one entity satisfyingBuildPhysicsWorld.DynamicEntityGroup
entity query.
Authoring/Conversion Behavior
Fixes
- Fixed the issue of
BuildPhysicsWorld
system not being run when there are not entities in the scene, leading toStepPhysicsWorld
system operating on stale data. - Fixed write-back in
ContactJacobian.SolveContact()
to only affect linear and angular velocity. This preventsJacobianHeader
's mass factors from affectingMotionVelocity
's mass factors, which used to have multiplicative effect on those mass factors over time. - Fixed the issue where
ExportPhysicsWorld
system would not get run if there wasn't at least one entity that hasPhysicsCollider
component. - Fixed a crash on Android 32 with Bursted calls to create a
Hash128
. - Fixed a bug that was causing AABB of the compound collider to be incorrectly calculated if one of the child colliders were a TerrainCollider.
Known Issues
[0.5.1-preview.2] - 2020-10-14
Upgrade guide
Changes
Dependencies
- Updated Burst from
1.3.2
to1.3.7
- Updated Mathematics from
1.1.0
to1.2.1
- Updated Collections from
0.11.0-preview.17
to0.14.0-preview.16
- Updated Entities from
0.13.0-preview.24
to0.16.0-preview.21
- Updated Jobs from
0.4.0-preview.18
to0.7.0-preview.17
- Updated Burst from
Run-Time API
- Added the
TerrainCollider.Filter
setter - Removed the
CompoundCollider.Filter
setter as it was doing the wrong thing (composite collider filters should be the union of their children) - Added
BuildPhysicsWorld.AddDependencyToComplete()
which takes a job dependency that theBuildPhysicsWorld
system should complete immediately in itsOnUpdate()
call (before scheduling new jobs). The reason is that this system does reallocations in theOnUpdate()
immediately (not in jobs), and any previous jobs that are being run before this system could rely on that data being reallocated. This way, these jobs can provide their dependency toBuildPhysicsWorld
and make sure it will wait until they are finished before doing the reallocations. - Added the option to provide a custom explosion filter in 'PhysicsVelocity.ApplyExplosionForce'.
- Added the
Authoring/Conversion API
Run-Time Behavior
- Changed Graphical Interpolation default to simpler implementation that doesn't try and consider velocities
BuildPhysicsWorld.CreateMotions
now gives Kinematic bodies a zero Gravity Factor (i.e. they will not be affected by gravity)- Setting the
Collider.Filter
is now allowed for Terrain colliders as well, as opposed to previously only working for Convex colliders
Authoring/Conversion Behavior
Fixes
- Fixed the potential issues if more than one job implements IBodyPairsJob.
- DebugStream.DrawComponent now cleans up its associated GameObject
- Fixed a bug in
PhysicsVelocity.ApplyExplosionForce
where the provided collider's collision filter could prevent the explosion from happening. - Fixed a memory leak in the Collider debug display gizmo
Known Issues
[0.5.0-preview.1] - 2020-09-15
Upgrade guide
- Physics systems now update in the
FixedStepSimulationSystemGroup
, using a fixed timestep provided by the group. This ensures that the results of the physics simulation do not depend on the application's display frame rate. Important consequences for applications:- Application systems that need to run at the same rate as the physics systems should also be moved into
FixedStepSimulationSystemGroup
(e.g., systems that handle collision or trigger events). - Application systems that should continue to run once per display frame should remove any
[UpdateAfter]
attributes targeting the physics systems. Any update order constraints for such systems should instead be expressed with respected toFixedStepSimulationSystemGroup
. - The DOTS fixed timestep is get/set using the
Timestep
property on theFixedStepSimulationSystemGroup
. The group's default timestep value is 1/60 second. The group's timestep is not affected by changes to the fixed timestep specified in the Project Settings. If this behavior is desired, applications can setFixedStepSimulationSystemGroup.Timestep
toUnityEngine.Time.fixedDeltaTime
every frame. - Care must be taken when processing input events during the FixedStepSimulationSystemGroup's update. The group may update zero, or one, or many times per display frame. If input events are polled once per display frame, naive input processing may lead to input events being skipped or processed multiple times.
- If your application's frame rate is faster than the fixed timestep, rigid bodies may appear to move in stop motion by default (as with classic GameObject-base physics). You can enable smoothing options for their graphics representations as needed.
- Application systems that must update once per display frame, yet which query the
Translation
orRotation
of dynamic rigid bodies, should instead queryLocalToWorld
when smoothed graphical transformations are required.
- Application systems that must update once per display frame, yet which query the
- Application systems that need to run at the same rate as the physics systems should also be moved into
- It is possible to see integrity failures when updating to this release.
BuildPhysicsWorld
andExportPhysicsWorld
expect the chunk layouts for rigid bodies to be the same at both ends of the physics pipeline in order to write the simulation results to component data. These messages indicate that you are making some structural change or modifying rigid bodies' component data (e.g.,Translation
,Rotation
,PhysicsCollider
) between these systems. - Old, unused serialized data have been removed from
PhysicsShapeAuthoring
andPhysicsMaterialTemplate
. Ensure you have run the upgrade utility in your project before updating to this version of the package (Window -> DOTS -> Physics -> Upgrade Data).
Changes
Dependencies
- Updated minimum Unity Editor version from
2019.4.0f1
to2020.1.0f1
- Updated Burst from
1.3.0
to1.3.2
- Updated Collections from
0.9.0-preview.6
to0.11.0-preview.17
- Updated Entities from
0.11.1-preview.4
to0.13.0-preview.24
- Updated Jobs from
0.2.10-preview.12
to0.4.0-preview.18
- Updated Performance Testing API from
2.0.8-preview
to2.2.0-preview
- Updated minimum Unity Editor version from
Run-Time API
- Added the following new types:
PhysicsGraphicsIntegration
namespacePhysicsGraphicalSmoothing
andPhysicsGraphicalInterpolationBuffer
components, which can be used to smooth a rigid body's graphical motion when rendering and physics are out of syncRecordMostRecentFixedTime
, which stores time values from the most recent tick ofFixedStepSimulationSystemGroup
BufferInterpolatedRigidBodiesMotion
, which stores dynamic rigid bodies' motion properties at the start of the frame when when smoothed bodies use interpolationCopyPhysicsVelocityToSmoothing
, which stores dynamic rigid bodies' velocities after physics has finished in the current frameSmoothRigidBodiesGraphicalMotion
, which writes dynamic rigid bodies'LocalToWorld
when smoothing is enabledGraphicalSmoothingUtility
class, which contains various methods for smoothing the motion of rigid bodies
- Renamed
ComponentExtensions
toPhysicsComponentExtensions
- Changed the following members/types:
PhysicsComponentExtensions.GetCenterOfMassWorldSpace()
now passesPhysicsMass
asin
rather thanref
.PhysicsComponentExtensions.GetLinearVelocity()
now passesPhysicsVelocity
asin
.PhysicsWorldExtensions.CalculateVelocityToTarget()
is now implemented and passes aRigidTransform
for the target rather than a separatefloat3
andquaternion
.
- Removed the following expired members/types:
BodyIndexPair.BodyAIndex
BodyIndexPair.BodyBIndex
- Body pair interfaces on events and modifiers (
CollisionEvent
,TriggerEvent
,ModifiableContactHeader
,ModifiableBodyPair
andModifiableJacobianHeader
)BodyCustomTags
BodyIndices
ColliderKeys
Entities
ComponentExtensions.GetCenterOfMass()
ComponentExtensions.SetCenterOfMass()
ComponentExtensions.GetAngularVelocity()
ComponentExtensions.SetAngularVelocity()
EndFramePhysicsSystem.HandlesToWaitFor
FinalJobHandle
on all core physics systems (BuildPhysicsWorld
,StepPhysicsWorld
,ExportPhysicsWorld
andEndFramePhysicsSystem
)Joint.JointData
JointData
JointFrame
Material.IsTrigger
Material.EnableCollisionEvents
MotionData.GravityFactor
PhysicsJoint.JointData
PhysicsJoint.EntityA
PhysicsJoint.EntityB
PhysicsJoint.EnableCollision
SimulationContext.Reset()
passingPhysicsWorld
Solver.ApplyGravityAndCopyInputVelocities()
passingNativeArray<MotionData>
Solver.SolveJacobians()
not passing explicitStabilizationData
- Added
JointType.LimitedDegreeOfFreedom
and associated creation and control functions - Added
Aabb.Intersect()
function - Added
PhysicsComponentExtensions.GetEffectiveMass()
- Added the following new types:
Authoring/Conversion API
- Removed the following expired members/types:
LegacyJointConversionSystem
(now internal)PhysicsMaterialTemplate.IsTrigger
PhysicsMaterialTemplate.RaisesCollisionEvents
PhysicsShapeAuthoring.IsTrigger
andOverrideIsTrigger
PhysicsShapeAuthoring.RaisesCollisionEvents
andOverrideRaisesCollisionEvents
- Added the following new types:
BodySmoothing
enum
- Added the following new members:
PhysicsBodyAuthoring.Smoothing
, to enable motion smoothing
PhysicsBodyAuthoring.LinearDamping
andAngularDamping
setters now clamp incoming values to be at least 0.
- Removed the following expired members/types:
Run-Time Behavior
- Debug rendering is now significantly faster, in the case of 3D lines.
- Physics systems now update in the
FixedStepSimulationSystemGroup
.
Authoring/Conversion Behavior
- Classic
Rigidbody
interpolation mode is now supported during conversion. - Inspector help button for built-in authoring components and assets now opens the corresponding page in the API reference.
- Classic
Fixes
- Fixed issue where orientation in Physics Shape component would get dirtied when nothing changed
- Fixed issue with
PhysicsJoint.CreateHinge()
only working on a single axes. - Fixed
Constraint.Dimension
not returning 0 when it should. - Reduced size of compound collider/mesh collider AABB in cases where their bodies are rotated by some angle.
- Added optional integrity checks for physics ECS data consistency between BuildPhysicsWorld and ExportPhysicsWorld. Checks can be run in editor only.
- Fixed regression that caused additional sub-meshes to be ignored when converting mesh colliders.
Known Issues
- Physics debug display may not work properly while stepping frame by frame in Editor.
[0.4.1-preview] - 2020-07-28
Changes
- Run-Time API
- Added the following members:
FloatRange.Mid
AABB.ClosestPoint
- Changed the following members/types:
- All systems now inherit
SystemBase
instead ofComponentSystem
.
- All systems now inherit
- Added the following members:
Fixes
- When using Unity 2020.1.0b13 or newer, it is now possible to convert mesh colliders inside of sub-scenes when their input meshes do not have read/write enabled. Meshes converted at run-time must still have read/write enabled.
- Stopped emitting warning messages about physics material properties being upgraded when creating new objects from editor scripts.
- Fixed warnings from exceptions thrown in Bursted code paths when using Burst 1.4.0.
- Fixed issue with static layer not being rebuilt when order of entities in chunk changes.
- Fixed issue with invalid colliders with empty AABB breaking bounding volume hierarchy and making objects "disappear" from the world.
- Fixed an editor crash when maximum level of composite collider nesting is breached.
[0.4.0-preview.5] - 2020-06-18
Upgrade guide
RigidBody
queries may no longer work, since they required inputs to be transformed to body space. As of this release, body queries require input in world space.- Core physics systems now expose
AddInputDependency()
andGetOutputDependency()
methods for user code to be able to plug in user systems between any of the core physics systems (BuildPhysicsWorld
,StepPhysicsWorld
,ExportPhysicsWorld
andEndFramePhysicsSystem
). - The serialization layout has changed for
PhysicsShapeAuthoring
andPhysicsMaterialTemplate
. Because data are upgraded before Prefab overrides are applied, you must manually re-apply any Prefab overrides that existed on scene objects, nested Prefabs, or Prefab variants for the migrated properties. It is recommended you use the data upgrade utility under the menu item Window -> DOTS -> Physics -> Upgrade Data.m_IsTrigger
andm_RaisesCollisionEvents
have been replaced withm_CollisionResponse
.m_BelongsTo
has been replaced withm_BelongsToCategories
m_CollidesWith
has been replaced withm_CollidesWithCategories
m_CustomTags
has been replaced withm_CustomMaterialTags
Changes
Dependencies
- Updated minimum Unity Editor version from
2019.3.0f1
to2019.4.0f1
- Updated Burst from
1.3.0-preview.7
to1.3.0
- Updated Collections from
0.7.1-preview.3
to0.9.0-preview.6
- Updated Entities from
0.9.0-preview.6
to0.11.1-preview.4
- Updated Jobs from
0.2.8-preview.3
to0.2.10-preview.12
- Updated Performance Testing API from
1.3.3-preview
to2.0.8-preview
- Updated minimum Unity Editor version from
Run-Time API
- Added the following new types:
BuildPhysicsWorld.CollisionWorldProxyGroup
CollisionResponsePolicy
(introduces a new value,None
, which allows a shape to move and participate in queries, without generating a collision response or overlap events)CollisionWorldProxy
to synchronizeCollisionWorld
with data flow graph node setsColliderCastNode
to perform queries in a data flow graph nodeForceMode
to use with extension methods analogous to those used with classicRigidbody
JointComponentExtensions
for use withPhysicsJoint
JointType
to serve as a hint to code modifying joint limitsPhysicsExclude
to easily exclude bodies from physics temporarilyPhysicsMassOverride
to easily make dynamic bodies enter and exit a kinematic statePhysicsConstrainedBodyPair
PhysicsJointCompanion
to keep track of sets of joints used to stabilize complex joint configurationsRaycastNode
to perform queries in a data flow graph nodeSolver.StabilizationData
Solver.StabilizationHeuristicSettings
- Added the following members:
ComponentExtensions.ApplyExplosionForce()
equivalent to classicRigidbody.ApplyExplosionForce()
method.ComponentExtensions.GetImpulseFromForce()
to mapForceMode
variants to impulses.FloatRange.Sorted()
to ensureMin
is not larger thanMax
.PhysicsStep.SolverStabilizationHeuristicSettings
to enable and configure solver stabilization heuristic. This can improve behavior in stacking scenarios, as well as overall stability of bodies and piles, but may result in behavior artifacts. It is off by default to avoid breaking existing behavior. Setting it to true enables the heuristic and its default parameters.PhysicsStep.SynchronizeCollisionWorld
to enable rebuild of the dynamic bodies bounding volume hierarchy after the step. This enables precise query results before the nextBuildPhysicsWorld
update call. Note thatBuildPhysicsWorld
will do this work on the following frame anyway, so only use this option when another system must know about the results of the simulation before the end of the frame (e.g., to destroy or create some other body that must be present in the following frame). In most cases, tolerating a frame of latency is easier to work with and is better for performance.PhysicsVelocity.CalculateVelocityToTarget()
to move kinematic bodies to desired target locations without teleporting them.SurfaceConstraintInfo.IsMaxSlope
- Implemented
ToString()
on some typesColliderCastHit
ColliderCastInput
ColliderKey
RaycastHit
RaycastInput
- Renamed the following members/type:
BodyAIndex
andBodyBIndex
are nowBodyIndexA
andBodyIndexB
across the codebase for consistency.ComponentExtensions.GetAngularVelocity()
andSetAngularVelocity()
are nowGetAngularVelocityWorldSpace()
andSetAngularVelocityWorldSpace()
, respectively.ComponentExtensions.GetCenterOfMass()
andSetCenterOfMass()
are nowGetCenterOfMassWorldSpace()
andSetCenterOfMassWorldSpace()
.JointFrame
is nowBodyFrame
- Changed the following members/types:
- Replaced all usages of
NativeSlice
withNativeArray
. - Replaced pair interfaces on events and modifiers (
CollisionEvent
,TriggerEvent
,ModifiableContactHeader
,ModifiableBodyPair
andModifiableJacobianHeader
) with direct accessors:EntityPair
is nowEntityA
andEntityB
BodyIndexPair
is nowBodyAIndex
andBodyBIndex
ColliderKeyPair
is nowColliderKeyA
andColliderKeyB
CustomTagsPair
is nowCustomTagsA
andCustomTagsB
Material.MaterialFlags
is now internal. Access flags through individual properties (CollisionResponse
,EnableMassFactors
andEnableSurfaceVelocity
).Joint
is now a fixed size.Joint.EnableCollision
is nowbyte
instead ofint
.Joint.JointData
has been deprecated. UseAFromJoint
,BFromJoint
,Constraints
, andVersion
instead.
PhysicsJoint
is now mutable.PhysicsJoint.CreatePrismatic()
factory does not take adistanceFromAxis
parameter (in contrast toJointData
factory)PhysicsJoint.CreateRagdoll()
factory now takes perpendicular angular limits in the range (-pi/2, pi/2) instead of (0, pi) in oldJointData
factory.
- Replaced all usages of
- Deprecated the following members/types:
EndFramePhysicsSystem.HandlesToWaitFor
(useAddInputDependency()
instead).FinalJobHandle
on all core physics systems (BuildPhysicsWorld
,StepPhysicsWorld
,ExportPhysicsWorld
andEndFramePhysicsSystem
) (useGetOutputDependency()
instead).JointData
Material.IsTrigger
(useCollisionResponse
instead)Material.EnableCollisionEvents
(useCollisionResponse
instead)PhysicsJoint.EntityA
(now defined onPhysicsConstrainedBodyPair
)PhysicsJoint.EntityB
(now defined onPhysicsConstrainedBodyPair
)PhysicsJoint.EnableCollision
(now defined onPhysicsConstrainedBodyPair
)PhysicsJoint.JointData
(useBodyAFromJoint
,BodyBFromJoint
, andGetConstraints()
/SetConstraints()
instead).SimulationContext.Reset()
passingPhysicsWorld
(use signature passingSimulationStepInput
instead).
- Removed the following members/types:
CollisionFilter.IsValid
CollisionWorld.ScheduleUpdateDynamicLayer()
Constraint
factory signatures passingfloat
values for ranges:Cone()
Cylindrical()
Planar()
Twist()
ISimulation.ScheduleStepJobs()
signature without callbacks and thread count hint (as well as all implementations)JointData
factory signatures passingfloat3
andquaternion
pairs for joint frames, as well asConstraint[]
:CreateFixed()
CreateHinge()
CreateLimitedHinge()
CreatePrismatic()
CreateRagdoll()
MassFactors.InvInertiaAndMassFactorA
MassFactors.InvInertiaAndMassFactorB
MotionData.GravityFactor
(useMotionVelocity.GravityFactor
instead)MotionVelocity.InverseInertiaAndMass
RigidBody.HasCollider
SimplexSolver.Solve()
signature passingPhysicsWorld
SimulationStepInput.ThreadCountHint
- Added the following new types:
Authoring/Conversion API
- Added the following types
BeginJointConversionSystem
EndJointConversionSystem
(allows other conversion systems to find joint entities created during conversion)PhysicsMaterialTemplate.CollisionResponse
PhysicsShapeAuthoring.CollisionResponse
PhysicsShapeAuthoring.OverrideCollisionResponse
- Added the following members
PhysicsStepAuthoring.EnableSolverStabilizationHeuristic
to enable solver stabilization heuristic with default settingsPhysicsStepAuthoring.SynchronizeCollisionWorld
- Deprecated the following members/types:
LegacyJointConversionSystem
has been marked obsolete and will be made internal in the future. UseBeginJointConversionSystem
andEndJointConversionSystem
to schedule system updates as needed.PhysicsMaterialTemplate.IsTrigger
(useCollisionResponse
property instead)PhysicsMaterialTemplate.RaisesCollisionEvents
(useCollisionResponse
property instead)PhysicsShapeAuthoring.IsTrigger
(useCollisionResponse
property instead)PhysicsShapeAuthoring.RaisesCollisionEvents
(useCollisionResponse
property instead)PhysicsShapeAuthoring.OverrideIsTrigger
(useOverrideCollisionResponse
property instead)PhysicsShapeAuthoring.OverrideRaisesCollisionEvents
(useOverrideCollisionResponse
property instead)
- Removed the following expired members:
LegacyColliderConversionSystem.ProduceMaterial()
(removed without expiration; class is not intended to be sub-classed outside the package)PhysicsShapeAuthoring.GetCapsuleProperties()
signature returningCapsuleGeometry
PhysicsShapeAuthoring.SetCapsule()
signature passingCapsuleGeometry
- Added the following types
Run-Time Behavior
BuildPhysicsWorld.JointEntityGroup
now requires both aPhysicsJoint
andPhysicsConstrainedBodyPair
component.Constraint
factory methods taking aFloatRange
swizzle the input value if needed to ensure thatMin
cannot be greater thanMax
.RigidBody
queries (Raycast()
,ColliderCast()
,PointDistance()
, andColliderDistance()
) now use world space input, and provide world space output, instead of using body space.
Authoring/Conversion Behavior
- It is now possible to create a compound collider by adding multiple
PhysicsShapeAuthoring
components to a single GameObject. - It is now possible to convert a GameObject with multiple
Joint
components on it.
- It is now possible to create a compound collider by adding multiple
Fixes
- When using Unity 2019.3.1f1 and newer, making changes to a
PhysicsMaterialTemplate
asset or aMesh
asset will now trigger a reimport of any sub-scenes containing shapes that reference it. IBodyPairsJob
now skips all joint pairs, when previously it didn't skip the joint pair if it was the first one in the list.- Fixed the issue of the
CompoundCollider
with no colliding children (all children are triggers) having invalid mass properties. - Fixed a potential race condition when
SynchronizeCollisionWorld
was set to true in theSimulationStepInput
. CollisionFilter
andAdvanced
material properties in the Inspector can now be expanded by clicking the label.
[0.3.2-preview] - 2020-04-16
Upgrade guide
- All
PhysicsShapeAuthoring
components that were newly added after version 0.3.0 were incorrectly initialized to have a bevel radius of 0. It is recommended that you audit recently authored content to assign reasonable non-zero values.
Changes
Dependencies
- Updated Collections from
0.5.2-preview.8
to0.7.1-preview.3
- Updated Entities from
0.6.0-preview.24
to0.9.0-preview.6
- Updated Jobs from
0.2.5-preview.20
to0.2.8-preview.3
- Updated Collections from
Run-Time Behavior
- In order to test gameplay end to end determinism users should:
- Navigate to UnityPhysicsEndToEndDeterminismTest.cs (and HavokPhysicsEndToEndDeterminsmTest.cs if using HavokPhysics)
- Remove #if !UNITY_EDITOR guards around [TestFixture] and [UnityTest] attributes (alternatively, users can run the tests in standalone mode without the need to remove #ifs)
- Add scene that needs to be tested (File -> Build Settings -> Add Open Scenes)
- Make sure that synchronous burst is enabled
- Run the test in Test Runner
- In order to test gameplay end to end determinism users should:
Authoring/Conversion Behavior
- Compound conversion system is now deterministic between runs.
Fixes
- Volume of dynamic meshes is now being approximated with the volume of the mesh AABB, as opposed to previously being set to 0.
- Fixed regression causing newly added
PhysicsShapeAuthoring
components to initialize with a bevel radius of 0.
Known Issues
[0.3.1-preview] - 2020-03-19
Upgrade guide
- User implemented query collectors (
ICollector<T>
) may no longer work. The reason is thatICollector<T>.TransformNewHits()
was removed. To get the collectors working again, move all logic fromICollector<T>.TransformNewHits()
toICollector<T>.AddHit()
. All the information is now available inICollector<T>.AddHit()
. Also,IQueryResult.Transform()
was removed, and user implementations of it will not get called anywhere in the engine.
Changes
Dependencies
- Updated Burst from
1.3.0-preview.3
to1.3.0-preview.7
- Updated Burst from
Run-Time API
- The following properties are added to
IQueryResult
interface:RigidBodyIndex
ColliderKey
Entity
ICollector.AddHit()
now has all the information ready to perform custom logic, instead of waiting for TransformNewHits().- Removed
Transform()
fromIQueryResult
interface and from all its implementations. - Removed both
TransformNewHits()
methods fromICollector
interface and from all its implementations. All the information is now ready inICollector.AddHit()
.
- The following properties are added to
Fixes
- Setting
Collider.Filter
now increments the header version so that the simulation backends can recognise the change. - Asking for collision/trigger events in scenes with no dynamic bodies no longer throws errors.
- Updated to new version of Burst, which fixes a regression that caused
ConvexCollider.Create()
to produce hulls with a very small bevel radius. - DOTS Run-time failures due to multiple inheritance of jobs have now been fixed.
- Changed
Math.IsNormalized
to use a larger tolerance when comparing float3 length.
[0.3.0-preview.1] - 2020-03-12
Upgrade guide
- In order to lead to more predictable behavior and allow for repositioning instantiated prefabs, static bodies are no longer un-parented during conversion. For best performance and guaranteed up-to-date values, it is still recommended that static bodies either be root-level entities, or that static shapes be set up as compounds. Dynamic and kinematic bodies are still un-parented. If your game code assumes static bodies are converted into world space, you may need to decompose
LocalToWorld
usingMath.DecomposeRigidBodyTransform()
rather than reading directly fromTranslation
andRotation
.
Changes
Dependencies
- Updated Entities from
0.3.0-preview.4
to0.6.0-preview.24
- Added Burst
1.3.0-preview.3
- Added Collections
0.5.2-preview.8
- Added Jobs
0.2.5-preview.20
- Added Mathematics
1.1.0
- Updated Entities from
Run-Time API
- Added the following new types:
CollisionEvents
(allows iterating through events directly using aforeach
loop, rather than only viaICollisionEventsJob
)DispatchPairSequencer
IBodyPairsJobBase
ICollisionEventsJobBase
IContactsJobBase
IJacobiansJobBase
ITriggerEventsJobBase
Integrator
JointFrame
Math.FloatRange
NarrowPhase
SimulationContext
SimulationJobHandles
Solver
TriggerEvents
(allows iterating through events directly using aforeach
loop, rather than only viaITriggerEventsJob
)Velocity
- Added the following members:
CollisionWorld.DynamicBodies
CollisionWorld.NumDynamicBodies
CollisionWorld.NumStaticBodies
CollisionWorld.StaticBodies
CollisionWorld.BuildBroadphase()
CollisionWorld.FindOverlaps()
CollisionWorld.Reset()
CollisionWorld.ScheduleBuildBroadphaseJobs()
CollisionWorld.ScheduleFindOverlapsJobs()
CollisionWorld.ScheduleUpdateDynamicTree()
CollisionWorld.UpdateDynamicTree()
DynamicsWorld.Reset()
Math.DecomposeRigidBodyOrientation()
Math.DecomposeRigidBodyTransform()
MassFactors.InverseInertiaFactorA
MassFactors.InverseInertiaFactorB
MassFactors.InverseMassFactorA
MassFactors.InverseMassFactorB
MotionVelocity.InverseInertia
MotionVelocity.InverseMass
Simulation.CollisionEvents
Simulation.TriggerEvents
Simulation.StepImmediate()
- Changed the following members/types:
CollisionWorld
constructor now requires specifying the number of dynamic and static bodies separatelyCollisionWorld.NumBodies
is now read-onlyDynamicsWorld.NumJoints
is now read-onlyDynamicsWorld.NumMotions
is now read-onlyISimulation.ScheduleStepJobs()
now requires callbacks and thread count hintITreeOverlapCollector.AddPairs()
now has optional bool parameter to swap the bodiesJoint.JointData
is nowBlobAssetReference<Joint>
instead ofJoint*
RigidBody.Collider
is nowBlobAssetReference<Collider>
instead ofCollider*
- The following types no longer implement
ICloneable
. TheirClone()
methods now return instances of their respective types rather thanobject
:CollisionWorld
DynamicsWorld
PhysicsWorld
- The following types now implement
IEquatable<T>
:Constraint
- Deprecated the following members:
CollisionFilter.IsValid
(use its opposite,CollisionFilter.IsEmpty
instead)CollisionWorld.ScheduleUpdateDynamicLayer()
(useScheduleUpdateDynamicTree()
instead)Constraint.StiffSpring()
(useConstraint.LimitedDistance()
instead)Constraint
factory signatures passingfloat
values for ranges (use new signatures takingFloatRange
instead):Cone()
Cylindrical()
Planar()
Twist()
JointData.Create()
signature passingMTransform
andConstraint[]
(use new signature that takesJointFrame
andNativeArray<Constraint>
instead)JointData.CreateStiffSpring()
(useJointData.CreateLimitedDistance()
instead)JointData
factory signatures passingfloat3
andquaternion
pairs for joint frames (use new signatures takingJointFrame
instead):CreateFixed()
CreateHinge()
CreateLimitedHinge()
CreatePrismatic()
CreateRagdoll()
MassFactors.InvInertiaAndMassFactorA
(useInverseInertiaFactorA
and/orInverseMassFactorA
instead)MassFactors.InvInertiaAndMassFactorB
(useInverseInertiaFactorB
and/orInverseMassFactorB
instead)MotionVelocity.InverseInertiaAndMass
(useInverseInertia
and/orInverseMass
instead)RigidBody.HasCollider
(useCollider.IsCreated
instead)SimplexSolver.Solve()
signature passingPhysicsWorld
(use new signature that does not require one, as it is not used)SimulationStepInput.ThreadCountHint
(supply desired value directly toScheduleStepJobs()
)
- Removed the following expired members:
Broadphase.ScheduleBuildJobs()
signature that does not specify gravityCollisionWorld.ScheduleUpdateDynamicLayer()
signature that does not specify gravityJointData.NumConstraints
MeshCollider.Create()
signatures takingNativeArray<int>
PhysicsWorld.CollisionTolerance
SimplexSolver.Solve()
signature takingNativeArray<SurfaceConstraintInfo>
SimulationStepInput.Callbacks
(removed without expiration; pass callbacks toScheduleStepJobs()
)
- Added the following new types:
Authoring/Conversion API
- Added the following new types:
LegacyJointConversionSystem
CapsuleGeometryAuthoring
- Added the following members:
PhysicsShapeAuthoring.GetCapsuleProperties()
signature returningCapsuleGeometryAuthoring
PhysicsShapeAuthoring.SetCapsule()
signature passingCapsuleGeometryAuthoring
- Deprecated the following members:
PhysicsShapeAuthoring.GetCapsuleProperties()
signature returningCapsuleGeometry
PhysicsShapeAuthoring.SetCapsule()
signature passingCapsuleGeometry
- Removed the following expired members/types:
BaseShapeConversionSystem<T>.ProduceColliderBlob()
DisplayCollisionEventsSystem.DisplayCollisionEventsJob
DisplayCollisionEventsSystem.FinishDisplayCollisionEventsJob
DisplayCollisionEventsSystem.ScheduleCollisionEventsJob()
DisplayContactsSystem.DisplayContactsJob
DisplayContactsSystem.FinishDisplayContactsJob
DisplayContactsSystem.ScheduleContactsJob()
DisplayTriggerEventsSystem.DisplayTriggerEventsJob
DisplayTriggerEventsSystem.FinishDisplayTriggerEventsJob
DisplayTriggerEventsSystem.ScheduleTriggerEventsJob()
PhysicsShapeAuthoring.GetMeshProperties()
usingNativeList<int>
. Use the signature takingNativeList<int3>
instead
- Added the following new types:
Run-Time Behavior
- The data protocol for static rigid bodies has changed so that at least one of
Translation
,Rotation
, orLocalToWorld
is required.- If a static body as a
Parent
, then its transform is always decomposed from itsLocalToWorld
component (which may be the result of last frame's transformations if you have not manually updated it). - If there is no
Parent
, then the body is assumed to be in world space and itsTranslation
andRotation
are read directly as before, if they exist; otherwise corresponding values are decomposed fromLocalToWorld
if it exists. - In any case where a value must be decomposed from
LocalToWorld
but none exists, then a corresponding identity value is used (float3.zero
forTranslation
andquaternion.identity
forRotation
).
- If a static body as a
- The following
CollisionWorld
queries no longer assert if the supplied collision filter is empty:CalculateDistance()
CastCollider()
CastRay()
OverlapAabb()
Simulation.ScheduleStepJobs()
can now schedule different types of simulation:- Providing a valid
threadCountHint
(>0) as the last parameter will schedule a multi-threaded simulation - Not providing a
threadCount
or providing an invalid value (<=0) will result in a simulation with a very small number of jobs being spawned (one per step phase) - Both simulation types offer the exact same customization options (callbacks) and outputs (events)
- Providing a valid
ISimulation.Step()
is intended to allow you to step a simulation immediately in the calling code instead of spawning jobs- Unfortunately,
Unity.Physics.Simulation
is currently not Burst-compatible, and therefore can't be wrapped in a Burst compiled job Simulation.StepImmediate()
should be wrapped in a single Burst compiled job for lightweight stepping logic; however, it doesn't support callbacks- If callbacks are needed, one should implement the physics step using a set of function calls that represent different phases of the physics engine and add customization logic in between these calls; this should all be wrapped in a Burst compiled job; check
Simulation.StepImmediate()
for the full list of functions that need to be called
- Unfortunately,
- Previously, if an Entity referenced by a
PhysicsJoint
component was deleted,BuildPhysicsWorld.CreateJoints()
would assert after failing to find a valid rigid body index. Now, if no valid body is found, theJoint.BodyIndexPair
is marked as invalid instead and the simulation will ignore them. - Triggers no longer influence the center of mass or inertia of any compound colliders that they are part of.
- The data protocol for static rigid bodies has changed so that at least one of
Authoring/Conversion Behavior
- Implicitly static shapes (as well as explicitly static bodies) in a hierarchy are no longer un-parented during the conversion process. Dynamic and kinematic bodies still are.
- Bevel radius and convex hull simplification tolerance are no longer modified by an object's scale when it is converted.
- Improved performance of converting mesh colliders and convex hulls, particularly when they appear as multiple child instances in a compound collider.
- Improved visualization of primitive shapes in the SceneView.
PhysicsShapeAuthoring
components are now editable from within the SceneView.PhysicsShapeAuthoring
primitives are now oriented more correctly when non uniformly scaled.
Fixes
- Fixed regression where displaying a mesh or convex hull preview on a shape authoring component immediately after a domain reload would trigger an assert.
- Fixed possible bug where classic
MeshCollider
components might convert to the incorrect shape. - Frame Selected (F key in scene view) now properly focuses on the collision shape bounds.
ConvexCollider.Create()
had been allocating too much memory forFaceVerticesIndex
array.MotionVelocity.CalculateExpansion()
formula changed to reduce expansion of AABB due to rotation.ForceUnique
checkbox in the Inspector is no longer disabled for primitivePhysicsShape
types.- Fixed a bug in scheduling resulting in race conditions during the solving phase.
PhysicsStepAuthoring
andPhysicsDebugDisplayAuthoring
no longer throw exceptions when embedded in a sub-scene.
Known Issues
- Due to a bug in the
TRSToLocalToParent
system, static bodies in a hierarchy will always cause the broad phase to be rebuilt. This will be fixed in the next version of entities after 0.6.0. - Not all properties on classic joint components are converted yet:
- Converted properties include connected bodies, axes, collisions, anchors, and linear/angular limits.
- Motors, spring forces, mass scale, break limits, and projection settings are currently ignored.
- Swapping bodies on
ConfigurableJoint
is not yet supported. ConfigurableJoint
setups with at least one free axis of angular motion are only stable if both other axes are locked (hinge), or both other axes are free (ball-and-socket).- Because solver behavior differs, some configurations also currently have a different feel from their classic counterparts.
- Modifying classic joints with Live Link enabled will currently leak memory.
- SceneView editing of
PhysicsShapeAuthoring
components currently only affects their size, but not their center offset.
[0.2.5-preview.1] - 2019-12-05
Fixes
- Fixed a bug that could cause compound colliders to not update with Live Link when moving around a mesh collider in the compound's hierarchy.
- Fixed possible incorrect instancing of colliders with different inputs
[0.2.5-preview] - 2019-12-04
Upgrade guide
- By default,
PhysicsColliders
that share the same set of inputs and that originate from the same sub-scene should reference the same data at run-time. This change not only reduces memory pressure, but also speeds up conversion. If you were alteringPhysicsCollider
data at run-time, you need to enable theForceUnique
setting on the respectivePhysicsColliderAuthoring
component. This setting guarantees the object will always convert into a unique instance. - Any usages of
BlockStream
should be replaced with theNativeStream
type from the com.unity.collections package.
Changes
Run-Time API
- Removed
BlockStream
and migrated all usages toNativeSteam
. - Access to
JointData.Constraints
has changed to an indexer. This means that to change the values of aConstraint
, a copy should be made first. E.g.,c# var c = JointData.Constraints[index]; c.Min = 0; JointData.Constraints[index] = c;
- Added
maxVelocity
parameter toSimplexSolver.Solve()
to clamp the solving results to the maximum value. - Added
SurfaceConstraintInfo.IsTooSteep
to indicate that a particular surface constraint has a slope bigger than the slope character controller supports. MeshCollider.Create()
now takes grouped triangle indices (NativeArray) instead of a flat list of indices (NativeArray ) as input. - Removed the following expired members/types:
BoxCollider.ConvexRadius
(renamed toBevelRadius
)CyllinderCollider.ConvexRadius
(renamed toBevelRadius
)- Collider factory methods passing nullable types and numeric primitives:
BoxCollider.Create()
CyllinderCollider.Create()
CapsuleCollider.Create()
ConvexCollider.Create()
MeshCollider.Create()
PolygonCollider.CreateQuad()
PolygonCollider.CreateTriangle()
SphereCollider.Create()
TerrainCollider.Create()
ComponentExtensions
members passing Entity (use components or variants passing component data instead):ApplyAngularImpulse()
ApplyImpulse()
ApplyLinearImpulse()
GetAngularVelocity()
GetCenterOfMass()
GetCollisionFilter()
GetEffectiveMass()
GetLinearVelocity()
GetMass()
GetPosition()
GetRotation()
GetVelocities()
SetAngularVelocity()
SetLinearVelocity()
SetVelocities()
CustomDataPair
ISimulation.ScheduleStepJobs()
JacobianFlags.EnableEnableMaxImpulse
MaterialFlags.EnableMaxImpulse
ModifiableContactHeader.BodyCustomDatas
ModifiableJacobianHeader.HasMaxImpulse
ModifiableJacobianHeader.MaxImpulse
ModifiableContactJacobian.CoefficientOfRestitution
ModifiableContactJacobian.FrictionEffectiveMassOffDiag
PhysicsCustomData
SimplexSolver.c_SimplexSolverEpsilon
SimplexSolver.Solve()
withoutminDeltaTime
parameter
- Removed
Authoring/Conversion API
- Added
PhysicsShapeAuthoring.ForceUnique
. - Added the following conversion systems:
BeginColliderConversionSystem
BuildCompoundCollidersConversionSystem
EndColliderConversionSystem
PhysicsShapeAuthoring.GetMeshProperties()
now populates aNativeList<int3>
for indices, instead of aNativeList<int>
.- The following public members have been made protected:
DisplayCollisionEventsSystem.FinishDisplayCollisionEventsJob
DisplayTriggerEventsSystem.FinishDisplayTriggerEventsJob
- Removed the following expired members/types:
BaseShapeConversionSystem<T>.GetCustomFlags()
DisplayCollidersSystem.DrawComponent
DisplayCollidersSystem.DrawComponent.DisplayResult
DisplayContactsJob
DisplayJointsJob
FinishDisplayContactsJob
PhysicsShapeAuthoring
members:SetConvexHull()
passing only a meshGetMesh()
replaced withGetMeshProperties
ConvexRadius
replaced withBevelRadius
GetBoxProperties()
returningvoid
SetBox()
passing a box center, size and orientation. PassBoxGeometry
instead.GetCapsuleProperties()
returningvoid
SetCapsule()
passing a capsule center, height, radius and orientation. PassCapsuleGeometry
instead.GetCylinderProperties()
returningvoid
SetCylinder()
passing a cylinder center, height, radius and orientation. PassCylinderGeometry
instead.GetSphereProperties()
returningvoid
SetSphere()
passing a sphere center, radius and orientation. PassSphereGeometry
instead.
- The following components have been removed:
PhysicsBody
(renamed toPhysicsBodyAuthoring
)PhysicsShape
(renamed toPhysicsShapeAuthoring
)PhysicsStep
(renamed toPhysicsStepAuthoring
)PhysicsDebugDisplay
(renamed toPhysicsDebugDisplayAuthoring
)
- Added
Run-Time Behavior
CompoundCollider.Create()
is now compatible with Burst.CompoundCollider.Create()
now correctly shares memory among repeated instances in the list of children.
Authoring/Conversion Behavior
- If mesh and convex
PhysicsShapeAuthoring
components have not explicitly opted in toForceUnique
, they may share the samePhysicsCollider
data at run-time, if their inputs are the same. - Classic
MeshCollider
instances with the same inputs will always share the same data at run-time when converted in a sub-scene. - Further improved performance of collider conversion for all types.
- If mesh and convex
Fixes
JointData.Version
was not being incremented with changes to its properties.- Fixed the issue of uninitialized array when scheduling collision event jobs with no dynamic bodies in the scene.
- Fixed the issue of
CollisionEvent.CalculateDetails()
reporting 0 contact points in some cases. - Fixed the issue of joints with enabled collisions being solved after contacts for the same body pair.
- Fixed exception and leak caused by trying to display a convex hull preview for a physics shape with no render mesh assigned.
- Fixed bug causing incremental changes to a compound collider to accumulate ghost colliders when using Live Link.
- Fixed an issue where kinematic (i.e. infinite mass dynamic) bodies did not write to the collision event stream correctly.
Known Issues
- Compound collider mass properties are not correctly updated while editing using Live Link.
[0.2.4-preview] - 2019-09-19
Changes
- Updated dependency on
com.unity.entities
to version0.1.1-preview
. If you need to stay on entities version0.0.12-preview.33
then you can use the previous version of this package,0.2.3-preview
, which is feature equivalent:
[0.2.3-preview] - 2019-09-19
Upgrade guide
- Implicitly static shapes (i.e. those without a
PhysicsBodyAuthoring
orRigidbody
) in a hierarchy under a GameObject withStaticOptimizeEntity
are now converted into a single compoundPhysicsCollider
on the entity with theStatic
tag. If your queries or contact events need to know about data associated with the entities from which these leaf shapes were created, you need to explicitly addPhysicsBodyAuthoring
components with static motion type, in order to prevent them from becoming part of the compound.
Changes
Run-Time API
- Deprecated
Broadphase.ScheduleBuildJobs()
and provided a new implementation that takes gravity as input. - Deprecated
CollisionWorld.ScheduleUpdateDynamicLayer()
and provided a new implementation that takes gravity as input. - Deprecated
PhysicsWorld.CollisionTolerance
and moved it toCollisionWorld
. - Deprecated
ManifoldQueries.BodyBody()
and provided a new implementation that takes two bodies and two velocities. - Added
CollisionEvent.CalculateDetails()
which provides extra information about the collision event:- Estimated impulse
- Estimated impact position
- Array of contact point positions
- Removed
CollisionEvent.AccumulatedImpulses
and providedCollisionEvent.CalculateDetails()
which gives a more reliable impulse value.
- Deprecated
Authoring/Conversion API
- Removed the following expired ScriptableObject:
CustomFlagNames
- Removed the following expired members:
PhysicsShapeAuthoring.GetBelongsTo()
PhysicsShapeAuthoring.SetBelongsTo()
PhysicsShapeAuthoring.GetCollidesWith()
PhysicsShapeAuthoring.SetCollidesWith()
PhysicsShapeAuthoring.OverrideCustomFlags
PhysicsShapeAuthoring.CustomFlags
PhysicsShapeAuthoring.GetCustomFlag()
PhysicsShapeAuthoring.SetCustomFlag()
PhysicsMaterialTemplate.GetBelongsTo()
PhysicsMaterialTemplate.SetBelongsTo()
PhysicsMaterialTemplate.GetCollidesWith()
PhysicsMaterialTemplate.SetCollidesWith()
PhysicsMaterialTemplate.CustomFlags
PhysicsMaterialTemplate.GetCustomFlag()
PhysicsMaterialTemplate.SetCustomFlag()
- Removed the following expired ScriptableObject:
Run-Time Behavior
- Gravity is now applied at the beginning of the step, as opposed to previously being applied at the end during integration.
Authoring/Conversion Behavior
- Implicitly static shapes in a hierarchy under a GameObject with
StaticOptimizeEntity
are now converted into a single compoundPhysicsCollider
.
- Implicitly static shapes in a hierarchy under a GameObject with
Fixes
- Fixed issues preventing compatibility with DOTS Runtime.
- Fixed occasional tunneling of boxes through other boxes and mesh triangles.
- Fixed incorrect AABB sweep direction during collisions with composite colliders, potentially allowing tunneling.
- Fixed obsolete
MeshCollider.Create()
creating an empty mesh. - Fixed obsolete
ConvexCollider.Create()
resulting in infinite recursion. - Fixed simplex solver bug causing too high output velocities in 3D solve case.
- Fixed bug causing custom meshes to be ignored on convex shapes when the shape's transform was bound to a skinned mesh.
- Fixed Burst incompatibilities in the following types:
BoxGeometry
CapsuleGeometry
CollisionFilter
ConvexHullGenerationParameters
CylinderGeometry
Material
SphereGeometry
- Improved performance of
MeshConnectivityBuilder.WeldVertices()
. - Fixed a potential assert when joints are created with a static and dynamic body (in that order).
Known Issues
[0.2.2-preview] - 2019-09-06
Fixes
- Added internal API extensions to work around an API updater issue with Unity 2019.1 to provide a better upgrading experience.
[0.2.1-preview] - 2019-09-06
Upgrade guide
- A few changes have been made to convex hulls that require double checking convex
PhysicsShapeAuthoring
components:- Default parameters for generating convex hulls have been tweaked, which could result in minor differences.
- Bevel radius now applies a shrink to the shape rather than an expansion (as with primitive shape types).
- Mesh
PhysicsShapeAuthoring
objects with no custom mesh assigned now include points from enabled mesh renderers on their children (like convex shapes). Double check any mesh shapes in your projects. - Due to a bug in version 0.2.0, any box colliders added to uniformly scaled objects had their scale baked into the box size parameter when initially added and/or when fit to render geometry. Double check box colliders on any uniformly scaled objects and update them as needed (usually by just re-fitting them to the render geometry).
- The serialization layout of
PhysicsShapeAuthoring
has changed. Values previously saved in them_ConvexRadius
field will be migrated tom_ConvexHullGenerationParameters.m_BevelRadius
, and am_ConvexRadius_Deprecated
field will then store a negative value to indicate the old data have been migrated. Because this happens automatically when objects are deserialized, prefab instances may mark this field dirty even if the prefab has already been migrated. Double check prefab overrides for Bevel Radius on your prefab instances.
Changes
- Run-Time API
- Added the following new members:
BodyIndexPair.IsValid
Math.Dotxyz1()
using doublePlane.Projection()
Plane.SignedDistanceToPoint()
- Added the following structs:
BoxGeometry
CapsuleGeometry
CylinderGeometry
SphereGeometry
ConvexHullGenerationParameters
Constraint
now implementsIEquatable<Constraint>
to avoid boxing allocations.- All previous
SphereCollider
,CapsuleCollider
,BoxCollider
andCylinderCollider
properties are now read only. A newGeometry
property allows reading or writing all the properties at once. BoxCollider.Create()
now usesBoxGeometry
. The signature passing nullable types has been deprecated.CapsuleCollider.Create()
now usesCapsuleGeometry
. The signature passing nullable types has been deprecated.ConvexCollider.Create()
now usesConvexHullGenerationParameters
. The signature passing nullable types has been deprecated.CylinderCollider.Create()
now usesCylinderGeometry
. The signature passing nullable types has been deprecated.MeshCollider.Create()
now uses native containers. The signature using managed containers has been deprecated.PolygonCollider.CreateQuad()
signature passing nullable types has been deprecated.PolygonCollider.CreateTriangle()
signature passing nullable types has been deprecated.SphereCollider.Create()
now usesSphereGeometry
. The signature passing nullable types has been deprecated.TerrainCollider.Create()
signature passing pointer and nullable types has been deprecated.SimplexSolver.Solve()
taking therespectMinDeltaTime
has been deprecated. Use the newSimplexSolver.Solve()
method that takesminDeltaTime
instead.- Renamed
BoxCollider.ConvexRadius
toBevelRadius
. - Renamed
CylinderCollider.ConvexRadius
toBevelRadius
. - Deprecated
SimplexSolver.c_SimplexSolverEpsilon
. - Deprecated the following methods in
ComponentExtensions
taking anEntity
as the first argument.GetCollisionFilter()
GetMass()
GetEffectiveMass()
GetCenterOfMass()
GetPosition()
GetRotation()
GetVelocities()
SetVelocities()
GetLinearVelocity()
SetLinearVelocity()
GetAngularVelocity()
SetAngularVelocity()
ApplyImpulse()
ApplyLinearImpulse()
ApplyAngularImpulse()
- Removed the following expired members:
ColliderCastInput.Direction
ColliderCastInput.Position
Ray(float3, float3)
Ray.Direction
Ray.ReciprocalDirection
RaycastInput.Direction
RaycastInput.Position
- Added the following new members:
- Authoring/Conversion API
- Renamed
PhysicsBody
toPhysicsBodyAuthoring
. - Renamed
PhysicsShape
toPhysicsShapeAuthoring
. PhysicsShapeAuthoring.BevelRadius
now returns the serialized bevel radius data in all cases, instead of returning the shape radius when the type was either sphere or capsule, or a value of 0 for meshes. Its setter now only clamps the value if the shape type is box or cylinder.PhysicsShapeAuthoring.GetBoxProperties()
now returnsBoxGeometry
. The signature containing out parameters has been deprecated.PhysicsShapeAuthoring.SetBox()
now usesBoxGeometry
. The signature passing individual parameters has been deprecated.PhysicsShapeAuthoring.GetCapsuleProperties()
now returnsCapsuleGeometry
. The signature containing out parameters has been deprecated.PhysicsShapeAuthoring.SetCapsule()
now usesCapsuleGeometry
. The signature passing individual parameters has been deprecated.PhysicsShapeAuthoring.GetCylinderGeometry()
now returnsCylinderGeometry
. The signature containing out parameters has been deprecated.PhysicsShapeAuthoring.SetCylinder()
now usesCylinderGeometry
. The signature passing individual parameters has been deprecated.PhysicsShapeAuthoring.GetSphereProperties()
now returnsSphereGeometry
. The signature containing out parameters has been deprecated.PhysicsShapeAuthoring.SetSphere()
now usesSphereGeometry
. The signature passing individual parameters has been deprecated.PhysicsShapeAuthoring.SetConvexHull()
now usesConvexHullGenerationParameters
. The old signature has been deprecated.PhysicsShapeAuthoring.ConvexRadius
has been deprecated. Instead useBevelRadius
values returned by geometry structs.PhysicsShapeAuthoring.GetConvexHullProperties()
now returns points fromSkinnedMeshRenderer
components that are bound to the shape's transform, or to the transforms of its children that are not children of some other shape, when no custom mesh has been assigned.- Added
PhysicsShapeAuthoring.SetConvexHull()
signature specifying minimum skinned vertex weight for inclusion. - Added
PhysicsShapeAuthoring.ConvexHullGenerationParameters
property. PhysicsShapeAuthoring.GetMesh()
has been deprecated.- Added
PhysicsShapeAuthoring.GetMeshProperties()
. When no custom mesh has been assigned, this will return mesh data from all render geometry in the shape's hierarchy, that are not children of some other shape. PhysicsShapeAuthoring.FitToEnabledRenderMeshes()
now takes an optional parameter for specifying minimum skinned vertex weight for inclusion.- Removed the
OutputStream
field from various deprecated debug drawing jobs. These will be redesigned in a future release, and you are advised to not try to extend them yet. - Removed the following expired members:
PhysicsShapeAuthoring.FitToGeometry()
.PhysicsShapeAuthoring.GetCapsuleProperties()
returning raw points.PhysicsShapeAuthoring.GetPlaneProperties()
returning raw points.FirstPassLegacyRigidbodyConversionSystem
.FirstPassPhysicsBodyConversionSystem
.SecondPassLegacyRigidbodyConversionSystem
.SecondPassPhysicsBodyConversionSystem
.
- Renamed
- Run-Time Behavior
BoxCollider.Create()
is now compatible with Burst.CapsuleCollider.Create()
is now compatible with Burst.ConvexCollider.Create()
is now compatible with Burst.CylinderCollider.Create()
is now compatible with Burst.MeshCollider.Create()
is now compatible with Burst.SphereCollider.Create()
is now compatible with Burst.TerrainCollider.Create()
is now compatible with Burst.
- Authoring/Conversion Behavior
- Converting mesh and convex shapes is now several orders of magnitude faster.
- Convex meshes are more accurate and less prone to jitter.
PhysicsShapeAuthoring
components set to convex now display a wire frame preview at edit time.PhysicsShapeAuthoring
components set to cylinder can now specify how many sides the generated hull should have.- Inspector controls for physics categories, custom material tags, and custom body tags now have a final option to select and edit the corresponding naming asset.
Fixes
- Body hierarchies with multiple shape types (e.g., classic collider types and
PhysicsShapeAuthoring
) now produce a single flatCompoundCollider
tree, instead of a tree with severalCompoundCollider
leaves. - Fixed issues causing dynamic objects to tunnel through thin static objects (most likely meshes)
- Fixed incorrect behavior of Constraint.Twist() with limitedAxis != 0
- Fixed regression introduced in 0.2.0 causing box shapes on uniformly scaled objects to always convert into a box with size 1 on all sides.
- Fixed exception when calling
Dispose()
on an uninitializedCollisionWorld
.
Known Issues
- Wire frame previews for convex
PhysicsShapeAuthoring
components can take a while to generate. - Wire frame previews for convex
PhysicsShapeAuthoring
components do not currently illustrate effects of bevel radius in the same way as primitives. - The first time you convert convex or mesh shapes in the Editor after a domain reload, you will notice a delay while the conversion jobs are Burst compiled. all subsequent conversions should be significantly faster until the next domain reload.
- Updated dependency on
com.unity.burst
to version1.1.2
.
[0.2.0-preview] - 2019-07-18
Upgrade guide
- If you created per-body custom data using
PhysicsShape.CustomFlags
then you should instead do it usingPhysicsBody.CustomTags
. - Some public API points were removed, either because they were not intended to be public or because they introduce other problems (see Changes below).
- Some of these API points may later be reintroduced on a case-by-case basis to enable customization for advanced use cases. Please provide feedback on the forums if these removals have affected current use cases so we can prioritize them.
- Some public API points were replaced with another one in a way that cannot be handled by the script updater, so they must be manually fixed in your own code (see Changes below).
- All public types in test assemblies were never intended to be public and have been made internal.
- Some properties on
PhysicsMaterialTemplate
andPhysicsShape
now returnPhysicsCategoryTags
instead ofint
. Use itsValue
property if you need to get/set a rawint
value (see Changes below).
Changes
- Run-Time API
- Added first draft of a new
TerrainCollider
struct. Terrain geometry is defined by a height field. It requires less memory than an equivalent mesh and is faster to query. It also offers a fast, low-quality option for collision detection.- Added
ColliderType.Terrain
. - Added
CollisionType.Terrain
. - Added
DistanceQueries.ConvexTerrain<T>()
. - Added
DistanceQueries.PointTerrain<T>()
.
- Added
- Shapes and bodies how have their own separate custom data.
- Added
Material.CustomTags
(for shapes). - Replaced
PhysicsCustomData
withPhysicsCustomTags
(for bodies). - Replaced
ContactHeader.BodyCustomDatas
withContactHeader.BodyCustomTags
. - Replaced
CustomDataPair
withCustomTagsPair
. - Replaced
RigidBody.CustomData
withRigidBody.CustomTags
.
- Added
- Removed coefficient of restitution concept from Jacobians. All restitution calculations are approximated and applied before the solve, so restitution changes at this point in the simulation have no effect.
ModifiableContactJacobian.CoefficientOfRestitution
is now obsolete.
ModifiableContactJacobian.FrictionEffectiveMassOffDiag
is now obsolete. It was not possible to make any meaningful changes to it without fully understanding friction solving internals.- Removed max impulse concept from Jacobians. Solver design implies impulses are pretty unpredictable, making it difficult to choose maximum impulse value in practice.
JacobianFlags.EnableMaxImpulse
is now obsolete.- Underlying values of
JacobianFlags
have been changed. - Added
JacobianFlags.UserFlag2
.
- Underlying values of
Material.EnableMaxImpulse
is now obsolete.MaterialFlags.EnableMaxImpulse
is now obsolete.ModifiableJacobianHeader.HasMaxImpulse
is now obsolete.ModifiableJacobianHeader.MaxImpulse
is now obsolete.
- Removed the following members:
CollisionFilter.CategoryBits
CollisionFilter.MaskBits
- Removed the following types from public API and made them internal:
AngularLimit1DJacobian
AngularLimit2DJacobian
AngularLimit3DJacobian
BaseContactJacobian
BoundingVolumeHierarchy.BuildBranchesJob
BoundingVolumeHierarchy.BuildFirstNLevelsJob
BoundingVolumeHierarchy.FinalizeTreeJob
Broadphase
ColliderCastQueries
CollisionEvent
CollisionEvents
ContactHeader
ContactJacobian
ConvexConvexDistanceQueries
ConvexHull
ConvexHullBuilder
ConvexHullBuilderExtensions
DistanceQueries
ElementPool<T>
(Unity.Collections)Integrator
IPoolElement
(Unity.Collections)JacobianHeader
JacobianIterator
JacobianUtilities
LinearLimitJacobian
ManifoldQueries
Mesh
MotionExpansion
NarrowPhase
OverlapQueries
QueryWrappers
RaycastQueries
Scheduler
Simulation.Context
Solver
StaticLayerChangeInfo
TriggerEvent
TriggerEvents
TriggerJacobian
- Removed the following members from public API and made them internal:
- Aabb.CreateFromPoints(float3x4)
BoundingVolumeHierarchy.BuildBranch()
BoundingVolumeHierarchy.BuildCombinedCollisionFilter()
BoundingVolumeHierarchy.BuildFirstNLevels()
BoundingVolumeHierarchy.CheckIntegrity()
- All explicit
ChildCollider
constructors ColliderKeyPath(ColliderKey, uint)
ColliderKeyPath.Empty
ColliderKeyPath.GetLeafKey()
ColliderKeyPath.PopChildKey()
ColliderKeyPath.PushChildKey()
CollisionWorld.Broadphase
CompoundCollider.BoundingVolumeHierarchy
Constraint.ConstrainedAxis1D
Constraint.Dimension
Constraint.FreeAxis2D
ConvexCollider.ConvexHull
MeshCollider.Mesh
MotionVelocity.CalculateExpansion()
SimulationCallbacks.Any()
SimulationCallbacks.Execute()
ChildCollider.TransformFromChild
is now a readonly property instead of a field.- Removed
BuildPhysicsWorld.m_StaticLayerChangeInfo
. - Added
FourTranposedAabbs.DistanceFromPointSquared()
signatures passing scale parameter. - Changed
ISimulation
interface (i.e.Simulation
class).- Added
ISimulation.FinalJobJandle
. - Added
ISimulation.FinalSimulationJobJandle
. - Added simpler
ISimulation.ScheduleStepJobs()
signature and marked previous one obsolete.
- Added
- Added
RigidBody.HasCollider
. SimplexSolver.Solve()
now takes an optional bool to specify whether it should respect minimum delta time.SurfaceVelocity.ExtraFrictionDv
has been removed and replaced with more usableLinearVelocity
andAngularVelocity
members.
- Added first draft of a new
- Authoring/Conversion API
- Added
CustomBodyTagNames
. - Renamed
CustomMaterialTagNames.FlagNames
toCustomMaterialTagNames.TagNames
. - Renamed
CustomFlagNames
toCustomPhysicsMaterialTagNames
. - Renamed
CustomPhysicsMaterialTagNames.FlagNames
toCustomPhysicsMaterialTagNames.TagNames
. - Added
PhysicsCategoryTags
,CustomBodyTags
, andCustomMaterialTags
authoring structs. - The following properties now return
PhysicsCategoryTags
instead ofint
:PhysicsMaterialTemplate.BelongsTo
PhysicsMaterialTemplate.CollidesWith
PhysicsShape.BelongsTo
PhysicsShape.CollidesWith
- The following members on
PhysicsMaterialTemplate
are now obsolete:GetBelongsTo()
SetBelongsTo()
GetCollidesWith()
SetCollidesWith()
- The following members on
PhysicsShape
are now obsolete:GetBelongsTo()
SetBelongsTo()
GetCollidesWith()
SetCollidesWith()
- Added
PhysicsMaterialTemplate.CustomTags
.CustomFlags
,GetCustomFlag()
andSetCustomFlag()
are now obsolete.
- Added
PhysicsShape.CustomTags
.CustomFlags
,GetCustomFlag()
andSetCustomFlag()
are now obsolete.
- Added
PhysicsBody.CustomTags
. - Renamed
PhysicsShape.OverrideCustomFlags
toPhysicsShape.OverrideCustomTags
. - Renamed
PhysicsShape.CustomFlags
toPhysicsShape.CustomTags
. - Renamed
PhysicsShape.GetCustomFlag()
toPhysicsShape.GetCustomTag()
. - Renamed
PhysicsShape.SetCustomFlag()
toPhysicsShape.SetCustomTag()
. - Overload of
PhysicsShape.GetCapsuleProperties()
is now obsolete. - Overload of
PhysicsShape.GetPlaneProperties()
is now obsolete. - Removed
PhysicsBody.m_OverrideDefaultMassDistribution
(backing field never intended to be public). PhysicsShape.GetBoxProperties()
now returns underlying serialized data instead of reorienting/resizing when aligned to local axes.BaseShapeConversionSystem.GetCustomFlags()
is now obsolete.- Parameterless constructors have been made private for the following types because they should not be used (use instead ScriptableObjectCreateInstance
() or GameObject.AddComponent () as applicable): CustomPhysicsMaterialTagNames
PhysicsCategoryNames
PhysicsMaterialTemplate
PhysicsBody
PhysicsShape
- The following types have been made sealed:
LegacyBoxColliderConversionSystem
LegacyCapsuleColliderConversionSystem
LegacySphereColliderConversionSystem
LegacyMeshColliderConversionSystem
LegacyRigidbodyConversionSystem
PhysicsBodyConversionSystem
PhysicsShapeConversionSystem
DisplayContactsJob
has been deprecated in favor of protectedDisplayContactsSystem.DisplayContactsJob
.FinishDisplayContactsJob
has been deprecated in favor of protectedDisplayContactsSystem.FinishDisplayContactsJob
.DisplayJointsJob
has been deprecated in favor of protectedDisplayJointsSystem.DisplayJointsJob
.FinishDisplayTriggerEventsJob
has been deprecated in favor of protectedDisplayTriggerEventsSystem.FinishDisplayTriggerEventsJob
.- The following types have been deprecated and will be made internal in a future release:
DisplayBodyColliders.DrawComponent
DisplayCollisionEventsSystem.FinishDisplayCollisionEventsJob
- Added
- Run-Time Behavior
- Collision events between infinite mass bodies (kinematic-kinematic and kinematic-static) are now raised. The reported impulse will be 0.
- The default value of
Unity.Physics.PhysicsStep.ThreadCountHint
has been increased from 4 to 8. EndFramePhysicsSystem
no longer waits forHandlesToWaitFor
, instead it produces aFinalJobHandle
which is a combination of those jobs plus the built-in physics jobs. Subsequent systems that depend on all physics jobs being complete can use that as an input dependency.
- Authoring/Conversion Behavior
PhysicsCustomData
is now converted fromPhysicsBody.CustomTags
instead of using the flags common to all leaf shapes.PhysicsShape.CustomTags
is now converted intoMaterial.CustomTags
.- If a shape conversion system throws an exception when producing a
PhysicsCollider
, then it is simply skipped and logs an error message, instead of causing the entire conversion process to fail. PhysicsShape
Inspector now displays suggestions of alternative primitive shape types if a simpler shape would yield the same collision result as the current configuration.PhysicsShape
Inspector now displays error messages if a custom mesh or discovered mesh is not compatible with run-time conversion.
Fixes
- Draw Collider Edges now supports spheres, capsules, cylinders and compound colliders.
- Fixed bug causing editor to get caught in infinite loop when adding
PhysicsShape
component to a GameObject with deactivated children withMeshFilter
components. - Fixed bug resulting in the creation of
PhysicMaterial
objects in sub-scenes when converting legacy colliders. - Fixed bug when scaling down friction on bounce in Jacobian building. Once a body was declared to bounce (apply restitution), all subsequent body Jacobians had their friction scaled down to 25%.
- Fixed bug resulting in the broadphase for static bodies possibly not being updated when adding or moving a static body, causing queries and collisions to miss.
- Fixed bug with restitution impulse during penetration recovery being too big due to wrong units used.
- Fixed bug with energy gain coming from restitution impulse with high restitution values.
- Fixed Jacobian structures being allocated at non 4 byte aligned addresses, which caused crashes on Android
- Removed Solver & Scheduler asserts from Joints between two static bodies #383.
- Fixed bug preventing the conversion of classic
BoxCollider
components with small sizes. - Fixed bug where
PhysicsShape.ConvexRadius
setter was clamping already serialized value instead of newly assigned value. - Fixed bug where
PhysicsShape
orientation, size, and convex radius values might undergo changes during conversion resulting in identical volumes; only objects inheriting non-uniform scale now exhibit this behavior. - Fixed bug causing minor drawing error for cylinder
PhysicsShape
with non-zero convex radius. - Fixed crash when trying to run-time convert a
MeshCollider
orPhysicsShape
with a non-readable mesh assigned. Conversion system now logs an exception instead. - Fixed crash when constructing a
MeshCollider
with no input triangles. A valid (empty) mesh is still created. - Fixed bugs building to IL2CPP resulting in unresolved external symbols in
BvhLeafProcessor
,ConvexCompoundLeafProcessor
, andConvexMeshLeafProcessor
. - Fixed bug causing physics IJob's to not be burst compiled (ICollisionEventsJob, ITriggerEventsJob, IBodyPairsJob, IContactsJob, IJacobiansJob)
[0.1.0-preview] - 2019-05-31
Upgrade guide
- Any run-time code that traversed the transform hierarchy of physics objects to find other entities must instead store references to entity IDs of interest through a different mechanism.
- Baking of non-uniform scale for parametric
PhysicsShape
types has changed to more predictably approximate skewed render meshes. Double check the results on any non-uniformly scaled objects in your projects. - Angular Velocity is currently set in Motion Space. The Motion Space orientation of dynamic bodies may have changed with the changes to the conversion pipeline. If dynamic bodies are now rotating differently, check the values of
Initial Angular Velocity
in thePhysicsBody
component, or values set toAngular
in thePhysicsVelocity
component. - Convex
PhysicsShape
objects with no custom mesh assigned now include points from enabled mesh renderers on their children. Double check any convex objects in your projects. - The
RaycastInput
andColliderCastInput
structs have changed. See below for details.
Changes
- Run-Time API
- Renamed
CollisionFilter.CategoryBits
toCollisionFilter.BelongsTo
. - Renamed
CollisionFilter.MaskBits
toCollisionFilter.CollidesWith
. RaycastInput
andColliderCastInput
have changed:- At the input level, start and end positions are now specified rather then an initial position and a displacement.
Start
replacesPosition
.End
replacesDirection
which had been confusing as it was actually a displacement vector to a second point on the ray.Ray
has been made internal as a lower level interface and updated to be less ambiguous.
- Added job interfaces for easier reading of simulation events, instead of having to work directly with block streams.
ICollisionEventsJob
callsExecute()
for every collision event produced by the solver.ITriggerEventsJob
callsExecute()
for every trigger event produced by the solver.- These events now also include the Entity's involved, not just the rigid body indices.
- Added job interfaces for easier modification of simulation data, instead of having to work directly with block streams.
IBodyPairsJob
callsExecute()
for every body pair produced by the broad phase.IContactsJob
callsExecute()
for every contact manifold produced by the narrowphase.IJacobiansJob
callsExecute()
for every contact jacobian before it is solved.
- Renamed
- Authoring/Conversion API
- Renamed
SecondPassLegacyRigidbodyConversionSystem
toLegacyRigidbodyConversionSystem
. - Deprecated
FirstPassPhysicsBodyConversionSystem
. - Renamed
SecondPassPhysicsBodyConversionSystem
toPhysicsBodyConversionSystem
. - Deprecated
FirstPassLegacyRigidbodyConversionSystem
. - Deprecated overload of
PhysicsShape.GetCapsuleProperties()
returning raw points. - Deprecated overload of
PhysicsShape.GetPlaneProperties()
returning raw points. - Renamed
PhysicsShape.FitToGeometry()
toPhysicsShape.FitToEnabledRenderMeshes()
. New method accounts for enabledMeshRenderer
components on child objects with the same physics body and leaf shape. PhysicsShape.GetConvexHullProperties()
now includes points from enabledMeshRenderer
components on child objects with the same physics body and leaf shape when no custom mesh has been assigned.
- Renamed
- Run-Time Behavior
- Added a fixed angle constraint to prismatic joints so they no longer rotate freely.
- Any Entity with a
PhysicsVelocity
component will be added to thePhysicsWorld
and integrated, even if it has noPhysicsCollider
.
- Authoring/Conversion Behavior
- Physics data on deactivated objects in the hierarchy are no longer converted.
- All physics objects (i.e. bodies) are now un-parented (required since all simulation happens in world space).
- Legacy
Collider
components are no longer converted if they are disabled. - Converted
PhysicsShape
objects with non-uniform scale now bake more predictable results when theirTransform
is skewed. - All menu paths for custom assets and authoring components have changed from 'DOTS Physics' to 'DOTS/Physics'.
Fixes
- Fixed trigger events not being raised between kinematic-vs-kinematic or kinematic-vs-static body pairs.
- Fixed crash in BuildPhysicsWorld when creating a dynamic body without a
PhysicsMass
component - Cylinder/sphere GameObjects no longer appear in first frame when draw colliders is enabled on
PhysicsDebugDisplay
. - Fix bugs in
BoundingVolumeHierarchy.Build
which now producesBoundingVolumeHierarchy
of greater quality. This will affect performance of BVH queries, and most notably it will significantly improve performance ofDynamicVsDynamicFindOverlappingPairsJob
- Fixed incorrect 3DOF angular constraint solving with non-identity joint orientation
- Fixed bug where converted
SphereCollider
would apply incorrect center offset when in a hierarchy with non-uniform scale. - Fixed bug where converted
PhysicsShape
would not become part of a compound collider at run-time if the firstPhysicsBody
ancestor found higher up the hierarchy was disabled. - Fixed bug where leaves of compound shapes in a hierarchy might be added to the wrong entity if it had disabled
UnityEngine.Collider
components. - Fixed bug causing leaves of compound shapes on prefabs to convert into individual static colliders.
- Fixed restitution response to be more bouncy for convex objects with high restitution values
- Fixed bug where a converted GameObject in a hierarchy would have the wrong translation and rotation at run-time.
- Fixed bug where objects with
StaticOptimizeEntity
would not be converted into physics world. - Preview for Mesh
PhysicsShape
no longer culls back faces. - Inspector control for convex radius on
PhysisShape
now appears when shape type is convex hull.
Known Issues
- Attempting to fit a non-uniformly scaled
PhysicsShape
to its render meshes may produce unexpected results. - Physics objects loaded from sub-scenes may have the wrong transformations applied on Android.
- Dragging a control label to modify the orientation of a
PhysicsShape
sometimes produces small changes in its size. - If gizmos are enabled in the Game tab, the 'Physics Debug Display' viewers are incorrectly rendered. Debug viewers render correctly in the Scene tab.
[0.0.2-preview] - 2019-04-08
Upgrade guide
- Any assembly definitions referencing
Unity.Physics.Authoring
assembly by name must be updated to instead referenceUnity.Physics.Hybrid
.
Changes
- Renamed
Unity.Physics.Authoring
assembly toUnity.Physics.Hybrid
. (All of its types still exist in theUnity.Physics.Authoring
namespace.) - Radius of cylinder
PhysicsShape
is no longer non-uniformly scaled when converted.
Fixes
- Fixed exception when converting a box
PhysicsShape
with negative scale. - Fixed incorrect orientation when fitting capsule, cylinder, or plane
PhysicsShape
to render mesh. - Fixed convex radius being too large when switching
PhysicsShape
from plane to box or cylinder. - Fixed calculation of minimum half-angle between faces in convex hulls.
- Fixed collision/trigger event iterators skipping some events when iterating.
- Fixed memory leak when enabling "Draw colliders" in the Physics Debug Display.
Known Issues
- Physics systems are tied to (variable) rendering frame rate when using automatic world bootstrapping. See
FixedTimestep
examples in ECS Samples project for currently available approaches. - IL2CPP player targets have not yet been fully validated.
- Some tests might occasionally fail due to JobTempAlloc memory leak warnings.
- Swapping
PhysicsShape
component between different shape types may produce non-intuitive results when nested in hierarchies with non-uniform scale. - Some
PhysicsShape
configurations do not bake properly when nested in hierarchies with non-uniform scale. PhysicsShape
does not yet visualize convex hull shapes at edit-time.- Drag values on classic
Rigidbody
components are not currently converted correctly.
[0.0.1-preview] - 2019-03-12
- Initial package version