Changelog
[1.3.5] - 2024-10-04
Added
- Motor Jacobians have access to the Jacobian header in the Solve methods now
Changed
- Documentation updates
- Updated Burst dependency to version 1.8.18
- Updated Unity Test Framework dependency to version 1.4.5
- Updated Mathematics dependency to version 1.3.2
- Updated entities packages dependencies
Fixed
- The "Use Spring" feature in the built-in
HingeJoint
now works correctly. Both the joint force values and the constraint relaxation parameters are set to the appropriate values in the underlying engine and the Unity Physics simulation behavior now closely matches the behavior in built-in physics. - Fixed a case that could lead to invalid data in the impulse handling within the LinearLimitJacobian
- Limits in Hinge Joint authoring components, enabled via the "Use Limits" option, are now respected when the "Use Spring" option is also enabled.
[1.3.2] - 2024-09-06
Changed
- Updated entities packages dependencies
Changed
- Documentation updates
- Updated Burst dependency to version 1.8.17
- Updated Unity Test Framework dependency to version 1.4.5
Fixed
- Fixed an issue with negative collider scales during baking. Negative scales in GameObjects are now correctly interpreted and can be used to correctly flip GameObjects together with their associated colliders.
[1.3.0-pre.4] - 2024-07-17
Added
- The collision tolerance in the
CollisionWorld
, which defines the minimum distance required for creating contacts between rigid bodies, is now configurable. The default value has been changed to a smaller, more performant value of 0.01 meters. If you observe any tunneling issues in your use case, please increase the value via thePhysicsStepAuthoring
component.
Changed
- Updated Burst dependency to version 1.8.16
Fixed
- Prevent
Entity.Null
entries in thePhysicsColliderKeyEntityPair
buffer of rigid body entities with compound colliders.
[1.3.0-exp.1] - 2024-06-11
Added
- Motors authored via built-in component, api, or custom component now use spring frequency and the damping ratio to fine-tune the motor behaviour.
- New
Collider.BakeTransform
function which allows deforming a collider at runtime. This function is implemented for all collider types except theTerrainCollider
and applies a provided affine transformation to the collider geometry, rotating, translating, scaling and shearing it accordingly. The geometric transformation will be either perfect for mesh types, or approximate for primitives. Specific deformations will be perfect even for primitives depending on the type of deformation and the primitive's parametrization. As such aBoxCollider
with identity orientation in local space will be uniformly scaled, updating its width, height and length perfectly, if the provided affine transformation is a pure scaling matrix. - The broadphase can now be changed to operate incrementally using the
PhysicsStepAuthoring
component (see parametersIncremental Dynamic Broadphase
andIncremental Static Broadphase
), and thePhysicsStep
Entities components. When the feature is enabled, the bounding volume hierarchy inside the broadphase, used for spatial acceleration during collision detection and for collider queries such as ray and collider casts, is no longer built from scratch every frame, but incrementally updated from one frame to the next. This can lead to drastic performance improvements for scenes with large numbers of rigid bodies of which only a very small subset changes between frames, that is, changes to rigid body transformations or colliders are rare. This feature can be enabled for dynamic bodies and static bodies separately, which makes it applicable to large and mostly static worlds with massive numbers of static rigid bodies and a reasonable number of dynamic bodies. By default this feature is disabled. - Through the new
CompoundCollider.Update
function, the shape or transformation of children in a compound collider can now be safely modified. By calling the provided function, the compound collider's bounding volume information and optionally also its mass properties are updated in accordance with the modifications of its child colliders, thereby ensuring correct behavior in collision detection and collider queries. - Added a new
CollisionWorld.Clone()
function which allows cloning a collision world and deep copying select colliders which otherwise would be shared across clones. Deep copying is important in cases where the collision world clone is used over multiple frames and colliders are modified, which is frequently the case in Netcode environments with lag compensation for physics queries (seeUnity.NetCode.PhysicsWorldHistorySingleton
). For these cases, the colliders which are likely to be modified or deleted (such as colliders in dynamic rigid bodies) can now be deep copied, ensuring independent collision world clones. Without deep copying in these cases, modifying colliders in the original collision world after having cloned it will inadvertently also affect the clone, which can lead to erroneous collision queries and crashes. - By setting the "Provides Contacts" option in built-in collider authoring components, users can now enable collision event reporting for physically simulated rigid bodies. The collision events can be received by using an
ICollisionEventsJob
.
Changed
- When baking a built-in hinge joint as a rotation motor, the Joint.Motor.Force parameter must be non-zero. This value is baked into the maximum impulse of the motor.
- Add missing
[BurstCompile]
attributes in the collider blob systems to ensure maximum performance. - In
EnsureUniqueColliderBlobSystem
, prevent extra delay in adding the required unique collider blob cleanup components by using a different ECB system. This change also batches the corresponding commands with the commands coming from other physics systems, preventing an unnecessary extra sync point in the overall simulation.
Fixed
- Possible race condition in debug displays when modifying the geometry of colliders.
- Prevent unnecessary memory allocations in builds due to the editor-only debug display.
- Fixed errors caused by memory corruption when selecting mesh-based custom Physics Shape Authoring components in the editor.
- Prevent slowdowns caused by physics analytics data gathering through job parallelization and by disabling the analytics jobs when editor analytics are disabled.
- Prevent crash in debug display caused by dangling system pointer in certain cases.
- Fully remove any trace of the integrity checks unless we are in the editor or in a development build.
- Fixed an issue that prevented contacts in the Physics Debug Display to show up when Draw Contacts was enabled.
- Prevent a
NullReferenceException
during incremental compound collider baking in the editor, by ensuring that the child collider blobs have not been removed by the blob asset store's garbage collection when creating the compound collider.
[1.2.4] - 2024-08-14
Changed
- Updated entities packages dependencies
[1.2.3] - 2024-05-30
Changed
IntegrityChecks
is now underProjectSettings
>Physics
>Unity Physics
>Enable Integrity Checks
.- Updated entities packages dependencies
[1.2.1] - 2024-04-26
Changed
- Updated Burst dependency to version 1.8.13
- Updated entities packages dependencies
[1.2.0] - 2024-03-22
Fixed
- Fix a number of memory leaks in the package and its test code.
- Make sure that the
ColliderBlobCleanupSystem
does not dispose the same collider blob multiple times in Netcode environments, preventing a crash.
[1.2.0-pre.12] - 2024-02-13
Added
- ScheduleUpdateBroadphase and UpdateBroadphaseImmediate to update the Broadphase instead of doing a full rebuild.
- ScheduleUpdateMotionData and UpdateMotionDataImmediate to update the pre-existing MotionData without recreating them.
- BuildPhysicsWorldData.CompleteInputDependency method to complete the InputDependency if necessary.
- Simulaton.ResetSimulationContext to make it possible reset the current simulation context.
Changed
- Updated Burst dependency to version 1.8.12
Fixed
- Fixed errors caused by memory corruption when selecting mesh-based custom Physics Shape Authoring components in the editor.
Updated
- Upgraded Test Framework version to 1.4.3
[1.2.0-pre.6] - 2023-12-13
Changed
- Promotion preparation
[1.2.0-pre.4] - 2023-11-28
Changed
- Updated Burst dependency to 1.8.10
[1.2.0-exp.3] - 2023-11-09
Added
- Added extension functions
PhysicsCollider.ToMesh()
andCollider.ToMesh()
for the creation ofUnityEngine.Mesh
objects from colliders. - use of
PhysicsMaterial
instead ofPhysicMaterial
andPhysicMaterialCombine
toPhysicsMaterialCombine
API when the editor is newer than2023.3
. - The
Layer Overrides
properties specified inCollider
andRigidbody
authoring components are now baked into theCollisionFilter
of the resultant Unity Physics colliders. For each individualCollider
authoring component, the layer overrides on itsRigidbody
and the collider itself are combined and together form theCollidesWith
mask in theCollisionFilter
of the baked collider. The collider collides with layers which are included, and does not collide with layers which are excluded. Furthermore, exclusions have precedence over inclusions. MassProperties.Scale
function allows uniformly scaling mass properties in a physically correct manner, assuming unit mass.
Changed
- Update package
com.unity.mathematics
from1.2.6
to1.3.1
version. - Analytics API update to
SceneSimulationAnalytics.cs
file. - collider files renamed to
BoxCollider.cs
,CapsuleCollider.cs
,Collider.cs
,MeshCollider.cs
,SphereCollider.cs
andTerrainCollider.cs
. - The
EnsureUniqueColliderSystem
now runs first in theBeforePhysicsSystemGroup
instead of after theAfterPhysicsSystemGroup
. A system that instantiates prefabs using unique colliders during runtime should run in theBeforePhysicsSystemGroup
to avoid a bug where colliders would not be unique during prefab instantiation. - The minimum supported editor version is now 2022.3.11f1
Removed
RayCastNode
andColliderCastNode
Fixed
- Prevent crash in debug display when exiting editor application.
[1.1.0-pre.3] - 2023-10-17
Added
- The
Physics Debug Display
component can now display colliders of typeTerrainCollider
. - The
Layer Overrides
properties specified inCollider
andRigidbody
authoring components are now baked into theCollisionFilter
of the resultant Unity Physics colliders. For each individualCollider
authoring component, the layer overrides on itsRigidbody
and the collider itself are combined and together form theCollidesWith
mask in theCollisionFilter
of the baked collider. The collider collides with layers which are included, and does not collide with layers which are excluded. Furthermore, exclusions have precedence over inclusions. MassProperties.Scale
function allows uniformly scaling mass properties in a physically correct manner, assuming unit mass.MassProperties.CreateSphere
function for creation of the mass properties of a sphere with the provided radius, assuming unit mass.
Changed
- Significantly improved performance of
Physics Debug Display
through a reduced need for thread synchronization via batching of debug display data. - The
Physics Debug Display
now automatically resizes its debug draw data buffers dynamically to ensure all entities are drawn. - Game objects with built-in or custom collider authoring components that have a purely uniform scale at edit-time, will now have the scale carried over into their
LocalTransform
component'sScale
property during entity baking. Thus far, any scale, including a purely uniform scale, was baked into the Unity Physics collider geometry instead and the corresponding entity'sLocalTransform.Scale
property was set to 1 rather than to the desired uniform scale value. This is no longer the case, and users can now expect to find the uniform edit-time scale they assign to their game objects also in the resultant, baked entities during run-time, making run-time modifications of already uniformly scaled objects much more intuitive and less cumbersome. - Rigid bodies baked from game objects which have any world-space scale or shear at edit-time can now be scaled at runtime using their
LocalTransform
component'sScale
property. Previously, this was not possible. Runtime scaling using theLocalTransform.Scale
property was only possible when the edit-time scale of the baked game object was identity, and no shear was present. Entity
references inCompoundCollider
children are no longer automatically set during baking since these references are not guaranteed to be valid in theWorld
after baking. Only those entity references that appear in components and buffers, such as thePhysicsColliderKeyEntityPair
buffer, are always guaranteed to be valid. Note that thePhysicsColliderKeyEntityPair
buffer is still present on entities which contain a baked compound collider. Via collider keys, this buffer provides a mapping between the child colliders and the original entities that they were in at bake time.
Fixed
- Prevent race condition between the systems that produce the debug draw data and the display system that renders the data. This allows the debug data to be fully produced before the display system attempts to render it.
- Fix draw of collider entities without
LocalToWorld
component when selectingPostIntegration
in the Physics Debug Display. - Avoid leftover debug draw when switching scenes and new scene has no
Physics Debug Display
. - Mass properties debug display now correctly considers the rigid body scale, and correctly handles cases with unphysical inertia tensors.
- Custom mass properties specified using the
Override Default Mass Distribution
option in the customPhysics Body Authoring
component now work correctly even if no collider is present. - A rigid body's uniform scale value (
LocalTransform.Scale
) is now always considered correctly in the simulation. Previously, when the rigid body entity also contained aPostTransformMatrix
component, its uniform scale was not applied to its collider and mass properties, leading to erroneous mass properties and missed collisions (if uniform scale > 1) or ghost collisions (if uniform scale < 1). - Collider debug display now correctly displays colliders with uniform scale other than 1 in accordance with their
LocalTransform
component'sScale
value. - Collider debug display now correctly displays rigid body entities with
Parent
component.
[1.1.0-exp.1] - 2023-09-18
Added
- Tests for ensuring proper joint anchor and mass property baking
- new demo scene (5m. Collider Modifications) demonstrating how to create colliders during runtime
- Utility functions were added for the creation of MeshCollider blob assets from UnityEngine.Mesh, UnityEngine.MeshData and UnityEngine.MeshDataArray. These functions are located in the
MeshCollider
class asMeshCollider.Create
variants with different function signatures. - Users can now verify if a collider blob is unique, and make it unique easily if required. The newly introduced
PhysicsCollider.IsUnique
property lets users check if aPhysicsCollider
is unique and turn it into a unique collider if desired via the functionPhysicsCollider.MakeUnique()
. Making a collider unique with this function also takes care of the collider blob lifetime management and will automatically dispose it if it is no longer needed. - Added a custom entity inspector for the collider blob asset stored in the
PhysicsCollider
component. This inspector allows for two-way interaction with the collider. The displayed values update in accordance with the collider's latest runtime state, and the UI can be used in order to interact with the collider manually when it is unique (seePhysicsCollider.IsUnique
). Among others, this lets users try out different material properties at runtime, such as friction and restitution, or modify the collider's size, local position or orientation.
Changed
- Changed the
bool
flags in thePhysics Debug Display
authoring component for drawing colliders, collider edges and axis-aligned bounding boxes of colliders to an enum calledDisplayMode
. With the display mode you can now choose whether to draw these elements at the beginning of the simulation step or at the end of the simulation step after the rigid bodies have been integrated, meaning, they have been moved forward in time. - Convert SystemBase to ISystems.
- Joint baking for built-in 3D physics joints has been improved, leading to the expected simulation results. Now, when the
Spring
andDamping
properties in Configurable and Character Joints are both set to 0 for limits, a hard limit is modeled. This is equivalent to the behavior in built-in 3D physics. Also, theDamping
parameter is now correctly converted from damping coefficient to the Unity Physics damping ratio for joints, yielding the correct damping force. Furthermore, joint baking now considers the scale of game objects. Anchor points are now affected by the scale accordingly. - The formula which converts the user-specified joint relaxation parameters (spring frequency and damping ratio) to the internal constraint regularization parameters (tau and damping) was rewritten as an optimized closed-form expression with constant time complexity. The regularization parameters can now be efficiently computed regardless of the chosen solver iteration count.
PhysicsGraphicalSmoothing
has been added to.WithAll<>()
from.WithAllRW<>()
in theSmoothedDynamicBodiesQuery
variable withinSmoothRigidBodiesGraphicalMotion.cs
system file.- Updating APIs to
GetScriptingDefineSymbols()
andSetScriptingDefineSymbols()
. - Included ragdoll authoring in documentation
- Prefab instances will now contain unique colliders if the "force unique" collider authoring option is used. This allows collider runtime modifications without manual collider blob cloning now also on prefab instances. Note that prefab instances that contain "force unique" colliders will be made unique only after the next physics system group update following the prefab instantiation. Until then, the
PhysicsCollider.IsUnique
property will be false. If users require a unique collider immediately after prefab instantiation for runtime collider modifications, they can safely use the newPhysicsCollider.MakeUnique()
function immediately after instantiation. - The internal component
DrawComponent
, required by thePhysics Debug Display
, is now hidden in the hierarchy.
Deprecated
- The
Constraint.DefaultSpringDamping
variable was deprecated. UseConstraint.DefaultDampingRatio
instead. The same applies to theConstraint.SpringDamping
property which was deprecated. Instead the newConstraint.DampingRatio
property should be used.
Removed
- Remove unused internal debug draw functionalities which were causing slowdowns during world initialization
Fixed
- BuildCompoundCollidersBakingSystem no longer leaks memory when the world is disposed.
- Convert SystemBase to ISystems
- When using the built-in
Rigidbody
andCollider
authoring components, the inertia tensor of the resultant rigid body in Unity Physics is now set correctly in all situations. Previously, in certain cases, the default inertia tensor was used. - A problem which prevented the solver to respect the user-specified joint spring frequency and damping ratios in certain cases has been fixed, enabling physically-plausible modeling of joints under all operating conditions.
- Link to changelog in documentation now fixed
- Physics Shape components with type Mesh now correctly only use the Custom Mesh for MeshCollider creation if specified rather than also incorrectly including the game object's render mesh and any render mesh found in the game object's children. The previous erroneous behavior could lead to significant performance problems in the narrow phase (contact creation) of the physics simulation group for affected meshes.
- Updated documentation to reflect that the Built-In TerrainCollider is not yet supported by Unity Physics
[1.0.16] - 2023-09-11
Changed
- Updated Burst dependency to version 1.8.8
Fixed
- Bugfix: The
AngularDamping
component ofRigidbodyAspect
is now writing to the correct value instead of toLinearDamping
[1.0.14] - 2023-07-27
Added
- Added support for overriding mass properties when baking
Rigidbody
authoring components. Now, when setting theRigidBody.automaticCenterOfMass
orRigidBody.automaticInertiaTensor
properties to false, the corresponding mass property data values are correctly baked into the Unity Physics rigid body entity and appear as expected in the entity'sPhysicsMass
component.
Changed
- Updated Burst dependency to version 1.8.7
[1.0.11] - 2023-06-19
Changed
- Prevent spawning
ParallelSolverJobs
unnecessarily ahead of time, which was leading to a potentially high overhead in time consumption. Instead, schedule the right number of jobs for the dispatch pair phases created by the scheduler to prevent scheduling and processing overheads. This leads to speed-ups in the time consumed by jobs in theSolveAndIntegrateSystem
specifically in cases with low to medium joint and contact counts. - The
PhysicsColliderKeyEntityPair
buffer is now added only when needed and its internal capacity of the buffer is set to zero, ensuring its content always lives outside of the chunk. This way, we don't unnecessarily increase the rigid body sizes in chunks, allowing for a larger number of rigid bodies in a single chunk, which improves performance.
Fixed
- Fixed regression in accessibility of
PhysicsShapeAuthoring
API. The functionsGetCapsuleProperties()
andSetCapsule()
were made internal by accident during the move of the custom physics authoring components from the package API to a package sample and are now public again.
[1.0.10] - 2023-05-23
Added
- Added missing API documentation and tooltips.
- preprocessors against performance tests package
Changed
- Changed visibility of
BaseJointBaker
class. It is now internal. - Changed visibility of
ColliderGeometry
struct. It is now internal. - Changed visibility of
PrimitiveColliderGeometries
struct. It is now internal.
Fixed
- The relative velocity in the angular velocity motor is now calculated correctly and the relative orientation between the two connected rigid bodies is correctly taken into account. This makes the motor work properly in all configurations.
- Prevent issues with update order for
ModifyJointLimitsSystem
in netcode multiplayer use case in which the system could not be placed after thePhysicsSystemGroup
since both were no longer in the same group.
[1.0.8] - 2023-04-17
Added
- Add
PhysicsWorldIndexAuthoring
component which allows specifying non-default world indices for bodies which are modeled using aRigidbody
component.
Changed
- With the removal of the custom Unity Physics authoring experience, a behavior change has been introduced when mixing built-in physics authoring components with custom physics authoring components. It is now no longer supported to add built-in colliders, such as the Box Collider, to a rigid body created using the
PhysicsBodyAuthoring
component. The inverse however, addingPhysicsShapeAuthoring
components to a rigid body created using the built-inRigidbody
component, is still supported. - Updated Burst version to 1.8.4
Removed
- UpgradePhysicsData window has been removed.
- The custom Unity Physics authoring experience, built around the
PhysicsBodyAuthoring
andPhysicsShapeAuthoring
components, has been removed from the package and turned into a package sample. It is recommended to use the built-in physics authoring components instead, e.g., theRigidbody
and collider components. To continue using the custom authoring experience in your projects, simply import the Custom Physics Authoring sample from the Unity Physics package into your project via the Package Manager window. - Depedendency on com.unity.test-framework
Fixed
- Colliders created from PhysicsShapeAuthoring components with the "Force Unique" flag set to true now are ensured to have unique collider blobs that are not shared across rigid bodies when they have identical properties, thus enabling runtime modification of individual colliders.
[1.0.0-pre.65] - 2023-03-21
Changed
- Updated Burst version in use to 1.8.3
- Debug display systems now only update when the PhysicsDebugDisplayData component is present (e.g., through the PhysicsDebugDisplayAuthoring game object component) and are only created within the editor.
Fixed
- Physics Debug Display for enabled Collider Edges now draws correctly if the collider scale is modified during runtime
- Debug display systems no longer stall and instead execute their jobs asynchronously
- Debug draw of collider faces and AABBs now account for uniform scaling of the rigid body
- Rigidbody components that move in PlayMode will now correctly snap back to their original position when exiting PlayMode while the containing sub scene is open for editing. As part of the fix, the classic PhysX-based physics simulation is now temporarily and globally disabled while in PlayMode with an open sub scene that contains classic Rigidbody authoring components. The Unity Physics-based physics simulation is unaffected during that time.
[1.0.0-pre.44] - 2023-02-13
Added
- legacy icons to the physics authoring components
PhysicsShape
andPhysicsBody
. - Help icon now always points to latest version of documentation for physics authoring components
- Unit tests for Motors
- Unit tests for some Jacobian methods
- Internal API to help with connecting bodyB to bodyA for joints/motor configuration
Changed
- Added functions that allow you to set impulse event threshold on all constraint joints, or only one of them.
- Replaced PhysicsTransformAspect with TransformAspect
- Increased testing of position motor in Position Motor demo scene, and re-enabled Position Motor package test.
- Cleanup and simplification of position motor joint code
- Use of
TransformAspect.WorldPosition
,TransformAspect.WorldRotation
,TransformAspect.WorldScale
when using Transform_V2 instead ofTransformAspect.Position
,TransformAspect.Rotation
,TransformAspect.Scale
. BaseShapeBakingSystem
andBuildCompoundCollidersBakingSystem
have been modified to useIJobEntity
instead ofEntities.ForEach()
.
Removed
Attributes.cs
script has been removed since thecom.unity.properties
package is part of the editor as a module.- the gap left due to the old references being removed on the .asmdef files.
Fixed
- Fixed bug when an extra ConfigurableJoint constraint was created when baking a motored Configurable Joint
- Fixed bug where target wasn't calculated correctly when baking a motored Configurable Joint
- Duplicate component error when switching Smoothing type to anything but None in Physics Body
- Immediately reset component in PhysicsShapeAuthoring's Reset() function to avoid sequential coupling issues
- During conversion from Game Object physics joints to Unity Physics joints the joint's spring coefficient is correctly considered.
[1.0.0-pre.15] - 2022-11-16
Added
- For all 4 motor types, added a new field for the maximum impulse that can be exerted by the motor constraint
- GameObjects that use axis-aligned motors are now converted during baking
- Support for validation of position motors in Simulation Validation System
UnityPhysicsStep
component does not show Havok physics engine in the dropdown field whencom.havok.physics
package is not installed.- Functions that allow you to set an impulse event threshold on all constraint joints, or only one of them.
Changed
- The UI for each motor type in the Physics Samples has been simplified to allow for more intuitive configuration
- When creating the constraints for motors, the ordering has been changed so that the motor is always last.
- The physics baking systems obey the GameObject static flag, in addition to the StaticOptimizeEntity component.
- Adding '.AsArray()' method to do explicit cast for the test scenes.
- API for motor creation have an additional argument for the max impulse of a motor. If this argument is not specified, a default value of infinity will be used.
- Naming path for Unity Physics Authoring components and material components.
Removed
- Dependancy on
com.unity.jobs
package. - Dependency on
com.unity.test-framework.performance
package.
Fixed
- For a linear velocity motor using Unity.Physics, fixed a bug where the target wasn't accurate if body was rotated
- Linear Velocity Motor target calculation fixed for when bodyA is rotated
- Fixed bug in Position Motor target error calculation for when bodyA is rotated
- Fixed bug in Linear Velocity Motor regarding the timestep
- Fixed bug in Position Motor regarding the timestep
- Motion should be not exported for physics entities that have the Simulate component disabled.
- Fixed a bug in which scale value was read from LocalTransform array even if the array had zero size.
- It is now possible to enable impulse events feature using Constraint creation methods.
- When baking a configurable joint into a motor, the Break Force and Break Torque now update the Max Impulse for breakable events
- Duplicate component error when switching Smoothing type to anything but None in Physics Body
- Immediately reset component in PhysicsShapeAuthoring's Reset() function to avoid sequential coupling issues
- During conversion from Game Object physics joints to Unity Physics joints the joint's spring coefficient is correctly considered.
- Physics debug display now shows colliders again in edit mode and not only in play mode
[1.0.0-exp.12] - 2022-10-19
Added
[CreateBefore(typeof(BroadphaseSystem))]
forPhysicsSimulationPickerSystem
withinUnityPhysicsSimulationSystems.cs
script file.
[1.0.0-exp.8] - 2022-09-21
Upgrade guide
- The physics pipeline has been reworked. -
PhysicsSystemGroup
is introduced. It is aComponentSystemGroup
that covers all physics jobs. It consists ofPhysicsInitializeGroup
,PhysicsSimulationGroup
, andExportPhysicsWorld
.PhysicsSimulationGroup
further consists ofPhysicsCreateBodyPairsGroup
,PhysicsCreateContactsGroup
,PhysicsCreateJacobiansGroup
,PhysicsSolveAndIntegrateGroup
which run in that order. See documentation for details. -StepPhysicsWorld
andEndFramePhysicsSystem
systems have been removed,BuildPhysicsWorld
has been moved toPhysicsInitializeGroup
: - If you hadUpdate(Before|After)StepPhysicsWorld
, replace it with:[UpdateInGroup(typeof(PhysicsSystemGroup))][Update(After|Before)(typeof(PhysicsSimulationGroup))]
. - If you hadUpdate(Before|After)BuildPhysicsWorld
, replace it with:[UpdateBefore(typeof(PhysicsSystemGroup))]
or[UpdateInGroup(typeof(PhysicsSystemGroup))][UpdateAfter(typeof(PhysicsInitializeGroup))]
- If you hadUpdate(Before|After)ExportPhysicsWorld
replace it with:[UpdateInGroup(typeof(PhysicsSystemGroup))][UpdateBefore(typeof(ExportPhysicsWorld))]
or[UpdateAfter(typeof(PhysicsSystemGroup))]
- If you had[Update(Before|After)EndFramePhysicsSystem]
replace it with:[UpdateAfter(typeof(PhysicsSystemGroup))]
- If you had combination of those (e.g.[UpdateAfter(typeof(BuildPhysicsWorld))][UpdateBefore(typeof(StepPhysicsWorld))
) take a look at the diagram in documentation. - All new systems are unmanaged, which means that they are more efficient, and theirOnUpdate()
is Burst friendly. You shouldn't callWorld.GetOrCreateSystem<AnyPhysicsSystem>()
as of this release and should be using singletons (see below). - Retrieval of
PhysicsWorld
is achieved differently. Previously, it was necessary to get it directly fromBuildPhysicsWorld
system. Now,PhysicsWorld
is retrieved by calling (SystemAPI|SystemBase|EntityQuery
).GetSingleton().PhysicsWorld in case read-only access is required, and by calling ( SystemAPI|SystemBase|EntityQuery
).GetSingletonRW().PhysicsWorld in case of a read-write access. It is still possible to get the world from BuildPhysicsWorld
, but is not recommended, as it can cause race conditions. This is only affecting thePhysicsWorld
managed by the engine. Users still can create and manage their ownPhysicsWorld
. Check out documentation for more information. - Retrieval of
Simulation
is achieved differently. Previously, it was neccessary to get it directly fromStepPhysicsWorld
system. Now,Simulation
is retrieved by calling (SystemAPI|SystemBase|EntityQuery
).GetSingleton().AsSimulation() in case read-only access is required, and by calling ( SystemAPI|SystemBase|EntityQuery
).GetSingletonRW().AsSimulation() in case of read-write access. Check out documentation for more information. - The dependencies between physics systems now get sorted automatically as long as
GetSingleton<>()
approach is used for retrievingPhysicsWorld
andSimulation
. There is no need to callRegisterPhysicsSystems(ReadOnly|ReadWrite)
,AddInputDependency()
orAddInputDependencyToComplete()
and these functions were removed. ITriggerEventsJob
,ICollisionEventsJob
,IBodyPairsJob
,IContactsJob
andIJacobiansJob
no longer takeISimulation
as an argument forSchedule()
method, but instead takeSimulationSingleton
. UseGetSingleton<SimulationSingleton>()
forITriggerEventsJob
andICollisionEventsJob
,GetSingletonRW<SimulationSingleton>()
forIBodyPairsJob
,IContactsJob
andIJacobiansJob
. All of these jobs can be now scheduled in Burst friendly way.- Callbacks between simulation stages have been removed. To get the same functionality, you now need to:
- Create a system
- Make it
[UpdateInGroup(typeof(PhysicsSimulationGroup))]
and make it[UpdateBefore]
and[UpdateAfter]
one of 4PhysicsSimulationGroup
subgroups. - In
OnUpdate()
of the system, recreate the functionality of a callback by scheduling one of the specialised jobs:IBodyPairsJob
,IContactsJob
,IJacobiansJob
. - See documentation for details and examples.
- Uniform scale is now supported. -
Scale
component is now taken into account when creating physics bodies. The component doesn't get created byBaking
(previously known asConversion
) in the Editor. Scale set in Editor gets baked into the collider geometry. If you want to dynamically scale bodies, add this component to physics body entities. - You might get problems if you were creatingRigidBody
struct instances directly, since the scale will be initialized to zero. Set it to1.0f
to return to previous behaviour. -ColliderCast
andColliderDistance
queries now support uniform scale for colliders that you are querying with.ColliderDistanceInput
andColliderCastInput
therefore have a new field that enables you to set it. Same asRigidBody
, you might get problems since the scale will be initialized to zero. Set it to1.0f
to return to previous behaviour. - Positive and negative values of scale are supported. - Multiple worlds support has been reworked. To support this use case previously, it was necessary to create a physics pipeline on your own, by using helpers such as
PhysicsWorldData
,PhysicsWorldStepper
andPhysicsWorldExporter
. Now it is possible to instantiate aCustomPhysicsSystemGroup
with a proper world index, which will run the physics simulation on non-default world index bodies. Check out the documentation for more information.
Added
- Reference to com.unity.render-pipelines.universal version 10.7
- new shaders in the sammpler that are SRP batcher and universal render pipeline compliant compliant
- New struct -
Unity.Physics.Math.ScaledMTransform
: Provides the same utility asUnity.Physics.Math.MTransform
but supports uniform scale. - Operator which converts a
float4
into aUnity.Physics.Plane
. PhysicsComponentExtensions.ApplyScale(in this PhysicsMass pm, in Scale scale)
- an extension method which scales up thePhysicsMass
component.- The following extension methods have recieved a version which takes a
Scale
argument. The old versions are not deprecated, and they assume identity scale. -PhysicsComponentExtensions.GetEffectiveMass(in this PhysicsMass bodyMass, in Translation bodyPosition, in Rotation bodyOrientation, in Scale bodyScale, float3 impulse, float3 point)
-PhysicsComponentExtensions.GetCenterOfMassWorldSpace(in this PhysicsMass bodyMass, in Scale bodyScale, in Translation bodyPosition, in Rotation bodyOrientation)
-PhysicsComponentExtensions.GetImpulseFromForce(in this PhysicsMass bodyMass, in Scale bodyScale, in float3 force, in ForceMode mode, in float timestep, out float3 impulse, out PhysicsMass impulseMass)
-PhysicsComponentExtensions.ApplyExplosionForce(ref this PhysicsVelocity bodyVelocity, in PhysicsMass bodyMass, in PhysicsCollider bodyCollider, in Translation bodyPosition, in Rotation bodyOrientation, in Scale bodyScale,
float explosionForce, in float3 explosionPosition, in float explosionRadius, in float timestep, in float3 up, in CollisionFilter explosionFilter, in float upwardsModifier = 0, ForceMode mode = ForceMode.Force)
-PhysicsComponentExtensions.ApplyImpulse(ref this PhysicsVelocity pv, in PhysicsMass pm, in Translation t, in Rotation r, in Scale bodyScale, in float3 impulse, in float3 point)
-PhysicsComponentExtensions.ApplyLinearImpulse(ref this PhysicsVelocity velocityData, in PhysicsMass massData, in Scale bodyScale, in float3 impulse)
-PhysicsComponentExtensions.ApplyAngularImpulse(ref this PhysicsVelocity velocityData, in PhysicsMass massData, in Scale bodyScale, in float3 impulse)
bool OverlapAabb(OverlapAabbInput input, ref NativeList<int> allHits)
has been added toPhysicsWorld
.SimulationSingleton
IComponentData is added: - UseAsSimulation()
to get the simulation that is stored in it. - UseInitializeFromSimulation(ref Simulation)
if you need to create it. >Note - Physics engine internally manages oneSimulationSingleton
, so be careful if usingSetSingleton<>()
with the newly createdSimulationSingleton
, as it can override the one stored by the engine. You should be using this method if you are managing a local simulation and need a singleton to use events and simulation modification API.PhysicsWorldSingleton
IComponentData is added. It implementsICollidable
and has access to the storedPhysicsWorld
and it's utility methods.NativeReference<int> HaveStaticBodiesChanged
get property is added toBuildPhysicsWorld
.- The following system groups are introduced: -
PhysicsSystemGroup
- covers all physics systems -PhysicsInitializeGroup
,PhysicsSimulationGroup
- subgroups ofPhysicsSystemGroup
-PhysicsCreateBodyPairsGroup
,PhysicsCreateContactsGroup
,PhysicsCreateJacobiansGroup
andPhysicsSolveAndIntegrateGroup
- subgroups ofPhysicsSimulationGroup
- Impulse events to allow users to break joints
- Supports the following types of motors: rotational, linear velocity, rotational, angular velocity
CustomPhysicsSystemGroup
andCustomPhysicsSystemGroupBase
for providing mulitple worlds support.CustomPhysicsProxyDriver
IComponentData, with it's authoring (CustomPhysicsProxyAuthoring
) and a system (SyncCustomPhysicsProxySystem
), which enable you to drive an entity from one world by an entity from another, using kinematic velocities.
Changed
- All materials in the samples to be universal render pipeline compliant
- Restored many Gizmo/Mesh methods from DisplayCollidersSystem.cs, but placed in a Utility file instead
- Changed allocator label to
Allocator.Temp
internally when buildingCollisionWorld
fromCollisionWorldProxy
. - Physics Debug Display: Performance improvements when drawing colliders (faces, edges, AABBs), broadphase, mass properties and contacts
- Physics Debug Display: Drawing collider faces for Mesh and Convex Hull types use different rendering method
- Physics Debug Display: The original Collider Edge drawing code that uses Gizmos has been moved to class 'DisplayGizmoColliderEdges' and to class 'AppendMeshColliders'
- Using built-in resources for the reference mesh used by cube and icosahedron
- Resources/ (used by Debug Draw) has been renamed DebugDisplayResources/ and now loads assets differently
- Removed use of the obsolete AlwaysUpdateSystem attribute. The new RequireMatchingQueriesForUpdate attribute has been added where appropriate.
ColliderCastInput
now has a propertyQueryColliderScale
. It defaults to1.0f
, and represents the scale of the passed in input collider.ColliderCastInput
constructor has changed to take in uniform scale of the query collider as the last parameter. It defaults to1.0f
.- The following methods have a uniform scale argument added as the last argument (defaults to
1.0f
), and their arguments are reordered. The old versions are deprecated: -AppendMeshColliders.GetMeshes.AppendSphere(SphereCollider* sphere, RigidTransform worldFromCollider, ref List results) has been deprecated.
Use AppendSphere(ref List results, SphereCollider* sphere, RigidTransform worldFromCollider, float uniformScale = 1)
. -AppendMeshColliders.GetMeshes.AppendCapsule(CapsuleCollider* capsule, RigidTransform worldFromCollider, ref List results) has been deprecated. Use AppendCapsule(ref List results, CapsuleCollider* capsule, RigidTransform worldFromCollider, float uniformScale = 1).
-AppendMeshColliders.GetMeshes.AppendMesh(MeshCollider* meshCollider, RigidTransform worldFromCollider, ref List results) has been deprecated. Use AppendMesh(ref List results, MeshCollider* meshCollider, RigidTransform worldFromCollider, float uniformScale = 1).
-AppendMeshColliders.GetMeshes.AppendCompound(CompoundCollider* compoundCollider, RigidTransform worldFromCollider, ref List results) has been deprecated. Use AppendCompound(ref List results, CompoundCollider* compoundCollider, RigidTransform worldFromCollider, float uniformScale = 1).
-AppendMeshColliders.GetMeshes.AppendTerrain(TerrainCollider* terrainCollider, RigidTransform worldFromCollider, ref List results) has been deprecated. Use AppendTerrain(ref List results, TerrainCollider* terrainCollider, RigidTransform worldFromCollider, float uniformScale = 1).
-AppendMeshColliders.GetMeshes.AppendCollider(Collider* collider, RigidTransform worldFromCollider, ref List results) has been deprecated. Use AppendCollider(ref List results, Collider* collider, RigidTransform worldFromCollider, float uniformScale = 1).
-ColliderDistanceInput.ColliderDistanceInput(BlobAssetReference collider, RigidTransform transform, float maxDistance) has been deprecated. Use ColliderDistanceInput(BlobAssetReference collider, float maxDistance, RigidTransform transform, float uniformScale = 1).
-Collider.GetLeafCollider(Collider* root, RigidTransform rootTransform, ColliderKey key, out ChildCollider leaf) has been deprecated. Use Use GetLeafCollider(out ChildCollider leaf, Collider* root, ColliderKey key, RigidTransform rootTransform, float rootUniformScale = 1) instead.
-Math.TransformAabb(RigidTransform transform, Aabb aabb) hase been deprecated. Use Math.TransformAabb(Aabb aabb, RigidTransform transform, float uniformScale = 1) instead.
-Math.TransformAabb(MTransform transform, Aabb aabb) hase been deprecated. Use Math.TransformAabb(Aabb aabb, MTransform transform, float uniformScale = 1) instead.
-Schedule()
signatures that acceptISimulation
have been removed fromIBodyPairsJob
,IContactsJob
,IJacobiansJob
,ICollisionEventsJob
andITriggerEventsJob
. New signatures acceptSimulationSingleton
instead. -ColliderCastNode.KernelDefs.CollisionWorld
has been removed and replaced withColliderCastNode.KernelDefs.PhysicsWorld
. -RaycastNode.KernelDefs.CollisionWorld
has been removed and replaced withRaycastNode.KernelDefs.PhysicsWorld
. -DispatchPairSequencer
is now astruct
instead of aclass
. UseDispatchPairSequencer.Create()
to create an instance of this struct, as empty constructor calls will not properly initialize it. -Simulation
is now astruct
instead of aclass
. UseSimulation.Create()
to create an instance of this struct, as empty constructor calls will not properly initialize it. - The following methods and interfaces haveSimulationCallbacks
argument removed. -ISimulation.ScheduleStepJobs(SimulationStepInput input, SimulationCallbacks callbacksIn, JobHandle inputDeps, bool multiThreaded = true)
-Simulation.ScheduleStepJobs(SimulationStepInput input, SimulationCallbacks callbacksIn, JobHandle inputDeps, bool multiThreaded = true)
-Simulation
has new methods that enable stepping the simulation on a granularity of individual simulation phases: -Simulation.ScheduleBroadphaseJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
-Simulation.ScheduleNarrowphaseJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
-Simulation.ScheduleCreateJacobiansJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
-Simulation.ScheduleSolveAndIntegrateJobs(SimulationStepInput input, JobHandle inputDeps, bool multiThreaded = true)
BuildPhysicsWorld
is now astruct
instead of aclass
, and implementsISystem
instead ofSystemBase
.ExportPhysicsWorld
is now astruct
instead of aclass
, and implementsISystem
instead ofSystemBase
.PhysicsWorldBuilder.SchedulePhysicsWorldBuild(SystemBase system, ref PhysicsWorldData physicsData, in JobHandle inputDep, float timeStep, bool isBroadphaseBuildMultiThreaded, float3 gravity, uint lastSystemVersion )
signature has changed toPhysicsWorldBuilder.SchedulePhysicsWorldBuild(ref SystemState systemState, ref PhysicsWorldData physicsData, in JobHandle inputDep, float timeStep, bool isBroadphaseBuildMultiThreaded, float3 gravity, uint lastSystemVersion )
.PhysicsWorldBuilder.SchedulePhysicsWorldBuild(SystemBase system, ref PhysicsWorld world, ref NativeArray<int> haveStaticBodiesChanged, ref PhysicsWorld world, ref NativeReference<int> haveStaticBodiesChanged, in PhysicsWorldData.PhysicsWorldComponentHandles componentHandles, in JobHandle inputDep, float timeStep, bool isBroadphaseBuildMultiThreaded, float3 gravity, uint lastSystemVersion, EntityQuery dynamicEntityGroup, EntityQuery staticEntityGroup, EntityQuery jointEntityGroup)
signature has changed toPhysicsWorldBuilder.SchedulePhysicsWorldBuild(ref PhysicsWorld world, ref NativeReference<int> haveStaticBodiesChanged, in PhysicsWorldData.PhysicsWorldComponentHandles componentHandles, in JobHandle inputDep, float timeStep, bool isBroadphaseBuild,MultiThreadedfloat3 gravity, uint lastSystemVersion, EntityQuery dynamicEntityGroup, EntityQuery staticEntityGroup, EntityQuery jointEntityGroup)
.PhysicsWorldBuilder.ScheduleBroadphaseBVHBuild(ref PhysicsWorld world, ref NativeArray<int> haveStaticBodiesChanged, in JobHandle inputDep, float timeStep, bool isBroadphaseBuildMultiThreaded, float3 gravity)
signature has changed toPhysicsWorldBuilder.ScheduleBroadphaseBVHBuild(ref PhysicsWorld world, NativeReference<int> haveStaticBodiesChanged, in JobHandle inputDep, float timeStep, bool isBroadphaseBuildMultiThreaded, float3 gravity)
.PhysicsWorldBuilder.BuildPhysicsWorldImmediate(SystemBase system, ref PhysicsWorldData data, float timeStep, float3 gravity, uint lastSystemVersion)
signature has changed toPhysicsWorldBuilder.BuildPhysicsWorldImmediate(ref SystemState systemState, ref PhysicsWorldData data, float timeStep, float3 gravity, uint lastSystemVersion)
.PhysicsWorldBuilder.BuildPhysicsWorldImmediate(SystemBase system, ref PhysicsWorld world, ref NativeArray<int> haveStaticBodiesChanged, float timeStep, float3 gravity, uint lastSystemVersion, EntityQuery dynamicEntityGroup, EntityQuery staticEntityGroup, EntityQuery jointEntityGroup)
signature has changed toPhysicsWorldBuilder.BuildPhysicsWorldImmediate(ref PhysicsWorld world, NativeReference<int> haveStaticBodiesChanged, in PhysicsWorldData.PhysicsWorldComponentHandles, float timeStep, float3 gravity, uint lastSystemVersion, EntityQuery dynamicEntityGroup, EntityQuery staticEntityGroup, EntityQuery jointEntityGroup)
.PhysicsWorldData.HaveStaticBodiesChanged
is now aNativeReference<int>
instead ofNativeArray<int>
.PhysicsWorldData.PhysicsWorldComponentHandles
struct is added. It contains component handles to data types needed to create a PhysicsWorld. - AddedPhysicsWorldComponentHandles(ref SystemState systemState)
constructor. Call it from the system inOnCreate()
where you plan to usePhysicsWorldData
inOnUpdate()
, and not from some other system (can cause race conditions). - AddedUpdate(ref SystemState)
method. Call it from a system inOnUpdate()
.PhysicsWorldBuilder
methods already update component handles, and there is no need to call this method prior to callingPhysicsWorldBuilder.ScheduleBulilPhysicsWorld()/BuildPhysicsWorldImmediate())
PhysicsWorldData
also hasUpdate(ref SystemState)
method which just callsUpdate(ref SystemState)
onPhysicsWorldComponentHandles
.PhysicsWorldExporter.SchedulePhysicsWorldExport(SystemBase system, in PhysicsWorld world, in JobHandle inputDep, EntityQuery dynamicEntities)
signature has changed toPhysicsWorldExporter.SchedulePhysicsWorldExport(ref SystemState systemState, ref ExportPhysicsWorldTypeHandles componentTypeHandles, in PhysicsWorld world, in JobHandle inputDep, EntityQuery dynamicEntities)
.PhysicsWorldExporter.ExportPhysicsWorldImmediate(SystemBase system, in PhysicsWorld world, EntityQuery dynamicEntities)
signature has changed toPhysicsWorldExporter.ExportPhysicsWorldImmediate(ref SystemState systemState, ref ExportPhysicsWorldTypeHandles componentTypeHandles, in PhysicsWorld world, EntityQuery dynamicEntities)
.PhysicsWorldExporter.ExportPhysicsWorldTypeHandles
struct is added. It contains component handles to data types needed to export a PhysicsWorld to ECS data. - AddedExportPhysicsWorldTypeHandles(ref SystemState systemState)
constructor. Call it from the system inOnCreate()
where you plan to exportPhysicsWorld
inOnUpdate()
, and not from some other system (can cause race conditions). - AddedUpdate(ref SystemState systemState)
method. Call it from a system inOnUpdate()
.PhysicsWorldExporter
methods already update component handles, and there is no need to call this method prior to callingPhysicsWorldExporter.ScheduleExportPhysicsWorld()/ExportPhysicsWorldImmediate())
.- Joint Constraints container changed from FixedList128 to a custom internal container. Users will get a FixedList512 returned when retrieving constraints
- Replaced obsolete EntityQueryBuilder APIs with current ones.
- ISystem implementations with public data converted to using components for data access
Deprecated
CollisionWorld.CalculateAabb(RigidTransform transform) has been deprecated. Use CollisionWorld.CalculateAabb() without a parameter.
RigidBody.CalculateAabb(RigidTransform transform) has been deprecated. Use RigidBody.CalculateAabb() without a parameter.
PhysicsWorld.CalculateAabb(RigidTransform transform) has been deprecated. Use PhysicsWorld.CalculateAabb() without a parameter.
Removed
- Removed
ICollider.CalculateAabb(RigidTransform transform)
. AllICollider
implementations will still be able to callCalculateAabb(RigidTransform transform, float uniformScale = 1)
, exceptRigidBody
,PhysicsWorld
andCollisionWorld
, where these methods are deprecated. - Removed
CollisionWorldProxy
. UsePhysicsWorldSingleton
to achieve the same functionality. - Simulation callback mechanism has been removed. As a consequence, the following APIs are removed as well: - class
SimulationCallbacks
is removed. - enumSimulationCallbacks.Phase
is removed. - callback delegate :public delegate JobHandle Callback(ref ISimulation simulation, ref PhysicsWorld world, JobHandle inputDeps)
has been removed. - Removed
PhysicsWorld
getter fromBuildPhysicsWorld
. It is still possible to get aPhysicsWorld
reference throughBuildPhysicsWorld.PhysicsData.PhysicsWorld
but it isn't recommended since it can cause race conditions. - Removed
StepPhysicsWorld
system. - Removed
EndFramePhysicsSystem
system. - Removed
BuildPhysicsWorld.AddInputDependencyToComplete()
from public API. - Removed
BuildPhysicsWorld.AddInputDependency()
method. - Removed
BuildPhysicsWorld.GetOutputDependency()
method. - Removed
ExportPhysicsWorld.AddInputDependency()
method. - Removed
ExportPhysicsWorld.GetOutputDependency()
method. - Removed
static class
PhysicsRuntimeExtenstions
, as a consequence, the following extension methods are removed as well: -public static void RegisterPhysicsRuntimeSystemReadOnly(this SystemBase system)
-public static void RegisterPhysicsRuntimeSystemReadWrite(this SystemBase system)
-public static void RegisterPhysicsRuntimeSystemReadOnly<T>(this SystemBase system) where T : unmanaged, IComponentData
-public static void RegisterPhysicsRuntimeSystemReadWrite<T>(this SystemBase system) where T : unmanaged, IComponentData
- Removed
PhysicsWorldExporter.SharedData
struct. - Removed
PhysicsWorldExporter.ScheduleCollisionWorldProxy()
method. - Removed
PhysicsWorldExporter.ScheduleCollisionWorldCopy()
method. - Removed
PhysicsWorldExporter.CopyCollisionWorldImmediate()
method. - Removed
PhysicsWorldStepper
class.
Fixed
- SingleThreadedRagdoll test was broken
- Physics Debug Display: improved Sphere and Capsule Collider Edges drawing
- Physics Debug Display: corrected z-ordering when drawing collider faces
- Simplified math to improve performance in
CalculateTwistAngle()
- Fixed a bug in
ConvexHullBuilder.Compact()
where triangle indices in links were not properly updated after remapping.
Changed
- Package Dependencies
com.unity.entities
to version0.51.1
com.unity.physics
to version0.51.1
com.unity.collections
to version1.4.0
[0.51.0] - 2022-05-04
Changed
- Package Dependencies
com.unity.burst
to version1.6.6
com.unity.entities
to version0.51.0
com.unity.mathematics
to version1.2.6
com.unity.physics
to version0.51.0
com.unity.collections
to version1.3.1
[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] - 2021-09-17
Changed
- Upgraded com.unity.burst to 1.5.5
- Adjusted code to remove obsolete APIs across all jobs inheriting IJobEntityBatch
Removed
- All usages of PhysicsExclude from Demo and Runtime code.
[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
Known Issues
[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.,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