Releases: needle-mirror/com.unity.physics
1.0.0-pre.65
[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
[1.0.0-pre.44] - 2023-02-13
Added
- legacy icons to the physics authoring components
PhysicsShapeandPhysicsBody. - 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.WorldScalewhen using Transform_V2 instead ofTransformAspect.Position,TransformAspect.Rotation,TransformAspect.Scale. BaseShapeBakingSystemandBuildCompoundCollidersBakingSystemhave been modified to useIJobEntityinstead ofEntities.ForEach().
Removed
Attributes.csscript has been removed since thecom.unity.propertiespackage 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
[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
[CreateBefore(typeof(BroadphaseSystem))]forPhysicsSimulationPickerSystemwithinUnityPhysicsSimulationSystems.csscript file.- Functions that allow you to set 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
- Removing dependencies
com.unity.jobspackage. - dependency on
com.unity.test-framework.performancepackage.
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.
- 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
- 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
1.0.0-exp.12
[1.0.0-exp.12] - 2022-10-19
Added
[CreateBefore(typeof(BroadphaseSystem))]forPhysicsSimulationPickerSystemwithinUnityPhysicsSimulationSystems.csscript file.
1.0.0-exp.8
[1.0.0-exp.8] - 2022-09-21
Upgrade guide
- The physics pipeline has been reworked. -
PhysicsSystemGroupis introduced. It is aComponentSystemGroupthat covers all physics jobs. It consists ofPhysicsInitializeGroup,PhysicsSimulationGroup, andExportPhysicsWorld.PhysicsSimulationGroupfurther consists ofPhysicsCreateBodyPairsGroup,PhysicsCreateContactsGroup,PhysicsCreateJacobiansGroup,PhysicsSolveAndIntegrateGroupwhich run in that order. See documentation for details. -StepPhysicsWorldandEndFramePhysicsSystemsystems have been removed,BuildPhysicsWorldhas 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)ExportPhysicsWorldreplace 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
PhysicsWorldis achieved differently. Previously, it was necessary to get it directly fromBuildPhysicsWorldsystem. Now,PhysicsWorldis 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 fromBuildPhysicsWorld, but is not recommended, as it can cause race conditions. This is only affecting thePhysicsWorldmanaged by the engine. Users still can create and manage their ownPhysicsWorld. Check out documentation for more information. - Retrieval of
Simulationis achieved differently. Previously, it was neccessary to get it directly fromStepPhysicsWorldsystem. Now,Simulationis 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 retrievingPhysicsWorldandSimulation. There is no need to callRegisterPhysicsSystems(ReadOnly|ReadWrite),AddInputDependency()orAddInputDependencyToComplete()and these functions were removed. ITriggerEventsJob,ICollisionEventsJob,IBodyPairsJob,IContactsJobandIJacobiansJobno longer takeISimulationas an argument forSchedule()method, but instead takeSimulationSingleton. UseGetSingleton<SimulationSingleton>()forITriggerEventsJobandICollisionEventsJob,GetSingletonRW<SimulationSingleton>()forIBodyPairsJob,IContactsJobandIJacobiansJob. 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 4PhysicsSimulationGroupsubgroups. - 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. -
Scalecomponent 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 creatingRigidBodystruct instances directly, since the scale will be initialized to zero. Set it to1.0fto return to previous behaviour. -ColliderCastandColliderDistancequeries now support uniform scale for colliders that you are querying with.ColliderDistanceInputandColliderCastInputtherefore 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.0fto 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,PhysicsWorldStepperandPhysicsWorldExporter. Now it is possible to instantiate aCustomPhysicsSystemGroupwith 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.MTransformbut supports uniform scale. - Operator which converts a
float4into aUnity.Physics.Plane. PhysicsComponentExtensions.ApplyScale(in this PhysicsMass pm, in Scale scale)- an extension method which scales up thePhysicsMasscomponent.- The following extension methods have recieved a version which takes a
Scaleargument. 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.SimulationSingletonIComponentData 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.PhysicsWorldSingletonIComponentData is added. It implementsICollidableand has access to the storedPhysicsWorldand it's utility methods.NativeReference<int> HaveStaticBodiesChangedget property is added toBuildPhysicsWorld.- The following system groups are introduced: -
PhysicsSystemGroup- covers all physics systems -PhysicsInitializeGroup,PhysicsSimulationGroup- subgroups ofPhysicsSystemGroup-PhysicsCreateBodyPairsGroup,PhysicsCreateContactsGroup,PhysicsCreateJacobiansGroupandPhysicsSolveAndIntegrateGroup- subgroups ofPhysicsSimulationGroup - Impulse events to allow users to break joints
- Supports the following types of motors: rotational, linear velocity, rotational, angular velocity
CustomPhysicsSystemGroupandCustomPhysicsSystemGroupBasefor providing mulitple worlds support.CustomPhysicsProxyDriverIComponentData, 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 ...
0.51.1-preview.21
[0.51.1] - 2022-06-27
Changed
- Package Dependencies
com.unity.entitiesto version0.51.1com.unity.collectionsto version1.4.0
[0.51.0] - 2022-05-04
Changed
- Package Dependencies
com.unity.entitiesto version0.51.0com.unity.jobsto version0.51.0com.unity.mathematicsto version1.2.6com.unity.collectionsto version1.3.0
Fixed
PhysicsShapeAuthoring.SetCylinder()now takes into account provided geometry's side count.
0.51.0-preview.32
[0.51.0] - 2022-05-04
Changed
- Package Dependencies
com.unity.entitiesto version0.51.0com.unity.jobsto version0.51.0com.unity.mathematicsto version1.2.6com.unity.collectionsto version1.3.0
Fixed
PhysicsShapeAuthoring.SetCylinder()now takes into account provided geometry's side count.
[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.50.0-preview.43
[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.50.0-preview.24
[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
Removed
- All usages of PhysicsExclude from Demo and Runtime code.
[0.10.0-preview.1] - 9999-12-31
Upgrade guide
- Added
PhysicsWorldIndexshared component, which is required on every Entity that should be involved in physics simulation (body or joint). ItsValuedenotes the index of physics world that the Entity belongs to (0 for defaultPhysicsWorldprocessed byBuildPhysicsWorld,StepPhysicsWorldandExportPhysicsWorldsystems). Note that Entities for different physics worlds will be stored in separate chunks, due to different values of shared component. PhysicsExcludecomponent is obsolete, but will still work at least until 2021-10-01. Instead of addingPhysicsExcludewhen you want to exclude an Entity from physics simulation, you can achieve the same thing by removing the requiredPhysicsWorldIndexshared component.HaveStaticBodiesChangedwas added toSimulationStepInput. It's a NativeArray of size 1, used for optimization of static body synchronization.
Changes
- Dependencies
- Run-Time API
- Added
BlobAssetReferenceColliderExtensionfunctions for ease of use and to help avoid unsafe code- Added reinterpret_cast-like logic via
BlobAssetReference<Collider>.As<To>whereTois 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>whereTois the destination collider struct type. The extension will return a pointer to the desired type. - Added an easy conversion helper to
PhysicsColliderviaBlobAssetReference<Collider>.AsComponent() - Added
ColliderCastInputandColliderDistanceInputconstructors that do not require unsafe code, along withSetColliderfunction to change a collider after creation of the input struct.
- Added reinterpret_cast-like logic via
PhysicsWorldDatais a new structure encapsulatingPhysicsWorldand other data and queries that are necessary for simulating a physics world.PhysicsWorldBuilderandPhysicsWorldExporterare new utility classes providing methods for building aPhysicsWorldand exporting its data to ECS components, with options to tweak queries that fetch Entities for the physics world.PhysicsWorldStepperis a new helper class for scheduling physics simulation jobs. ItsSimulationCreatordelegate and methods that need to instantiate anISimulationrequire physics world index to be passed in.BuildPhysicsWorldwas refactored to keep the data inPhysicsWorldDataand usePhysicsWorldBuilder.WorldFilterfield holds its physics world index (0).StepPhysicsWorldwas refactored to usePhysicsWorldStepper.ExportPhysicsWorldwas refactored to usePhysicsWorldExporter, which knows how to copyCollisionWorldand export data to Entities fetched by its queries.- Optimized
Collider.Clone()to no longer create an extra copy of theCollidermemory during the clone process.
- Added
- Authoring/Conversion API
- Physics Body authoring component has a new field
WorldIndexin 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.CustomTagsfield was moved to the Advanced section. PhysicsRuntimeExtensionshas 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 separateComponentDatatype 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
PhysicsWorldIndexshared component. Storage ofPhysicsWorldis 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
LocalToWorldwas not updated if rendering and physics were exactly in sync. - Fixed the spring constant calculation during joint conversion
- Fixed the configurable joint linear limit during joint conversion
- Physics Debug Display: Draw Collider Edges performance improved
- Physics Debug Display: Draw Collider Edges for sphere colliders improved
[0.9.0-preview.4] - 2021-05-19
Upgrade guide
- An extra check was added to verify that the data provided to the 'Start/End' properties of 'RayCastInput/ColliderCastInput' does not generate a cast length that is not too long. The maximum length allowed is half of 'float.MaxValue'
- Integrity checks can be now be enabled and disabled by toggling the new "DOTS/Physics/Enable Integrity Checks" menu item. Integrity checks should be enabled when checking simulation quality and behaviour. Integrity checks should be disabled when measuring performance. When enabled, Integrity checks will be included in a in Development build of a standalone executable, but are always excluded in release builds.
- An extra check was added to verify that the data provided to the
Start&Endproperties ofRayCastInput&ColliderCastInputdoes 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
partialkeyword 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
CalculateAabbmethod 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.22to0.17.0-preview.10 - Updated Entities from
0.18.0-preview.42to0.19.0-preview.17 - Updated Jobs from
0.9.0-preview.24to0.10.0-preview.10
- Updated Collections from
-
Run-Time API
- Made
CollisionEventandTriggerEventimplement a commonISimulationEventinterface allowing them to be equatable and comparable. - Made
ColliderKeycomparable. - Exposed a
MotionVelocity.IsKinematicproperty. - Exposed a
PhysicsMass.IsKinematicproperty. - Added a
PhysicsMassOverride.SetVelocityToZerofield. 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.SetVelocityToZerois also a non-zero value, the kinematic body will ignore the values in the associatedPhysicsVelocitycomponent 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 aGroupIndexon theFilterthat is not 0. - Added an extra change check on the
Parentcomponent type toCheckStaticBodyChangesJobin theBuildPhysicsWorldsystem.
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 theirUpdateBeforeandUpdateAftersystems 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 theDependencyproperty 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.DefaultSpringFrequencyandConstraint.DefaultSpringDampingvalues have been changed. The original defaults were setup to match the defaultfixedDeltaTimeand 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
- Dependenci...
0.6.0-preview.3
[0.6.0-preview.3] - 2021-01-18
Upgrade guide
PhysicsStep.ThreadCountHinthas 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.MultiThreadedto false. Otherwise, it will be set to true, meaning you'll get a default multi threaded simulation as ifPhysicsStep.ThreadCountHintis a positive number.
Changes
-
Dependencies
- Updated minimum Unity Editor version from
2020.1.0f1to2020.1.9f1 - Updated Burst from
1.3.7to1.4.1 - Updated Collections from
0.14.0-preview.16to0.15.0-preview.21 - Updated Entities from
0.16.0-preview.21to0.17.0-preview.41 - Updated Jobs from
0.7.0-preview.17to0.8.0-preview.23
- Updated minimum Unity Editor version from
-
Run-Time API
- Added a
Collider.Clone()function. - Added
MaterialtoIQueryResultinterface and its implementations (RaycastHit,ColliderCastHit,DistanceHit). All hits now have material information of the primitive that was hit. - Added the following interfaces to
ICollidableand 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
IJobChunkwithIJobEntityBatchorIJobEntityBatchWithIndexfor better performance. CollisionWorldandDynamicsWorldnow 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.
BuildPhysicsWorldsystem updates the maps on update. If updating the world manually then callPhysicsWorld.UpdateIndexMaps()to refresh.
- Use
- Removed
PhysicsStep.ThreadCountHintsince the value is now retrieved fromJobsUtility.JobWorkerCount. - Added
PhysicsStep.SingleThreadedto request the simulation with a very small number of single threaded jobs (previouslyPhysicsStep.ThreadCountHint<= 0). - Added
MeshCollider.FilterandCompoundCollider.Filtersetters 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. Collidernow has aFiltersetter regardless of the type of the collider.Collidernow has aRespondsToCollisiongetter that shows if it will participate in collision, or only move and intercept queries.
- Added a
-
Authoring/Conversion API
-
Run-Time Behavior
ExportPhysicsWorldsystem should now only get updated when there is at least one entity satisfyingBuildPhysicsWorld.DynamicEntityGroupentity query.
-
Authoring/Conversion Behavior
Fixes
- Fixed the issue of
BuildPhysicsWorldsystem not being run when there are not entities in the scene, leading toStepPhysicsWorldsystem 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
ExportPhysicsWorldsystem would not get run if there wasn't at least one entity that hasPhysicsCollidercomponent. - 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.