Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [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
  • Loading branch information
Unity Technologies committed Feb 13, 2024
1 parent c7c53db commit 40d124d
Show file tree
Hide file tree
Showing 11 changed files with 460 additions and 162 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ uid: unity-physics-changelog

# Changelog

## [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
Expand Down
2 changes: 2 additions & 0 deletions Documentation~/custom-samples-physics-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ To import the **Custom Physics Authoring** sample, open the Package Manager wind

## Custom authoring components

By manually importing the **Custom Physics Authoring** sample into your project, the following components will be added under **Assets > Samples** (folder).

* [Custom Shape Component](custom-shapes.md)
* [Custom Material](custom-materials.md)
* [Custom Body Component](custom-bodies.md)
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Unity Physics copyright © 2020 Unity Technologies ApS
Unity Physics copyright © 2024 Unity Technologies ApS

Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).

Expand Down
2 changes: 2 additions & 0 deletions Tests/PlayModeTests/Collision/Queries/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public unsafe void ConvexConvexDistanceTest()
// are validated in the same way as those in ConvexConvexDistanceTest().
// If the test fails, it will report a pair of seeds. Set dbgShape to the first and dbgTest to the second to run the failing case alone.
[Test]
[Timeout(300000)]
public unsafe void ConvexConvexDistanceEdgeCaseTest()
{
Random rnd = new Random(0x90456148);
Expand Down Expand Up @@ -486,6 +487,7 @@ static unsafe void WorldRaycastTest(ref Physics.PhysicsWorld world, RaycastInput
#if UNITY_ANDROID_ARM7V || UNITY_IOS
[Ignore("This test causes out of memory crashes on armv7 builds, due to the memory restrictions on such devices.")]
#endif
[Timeout(300000)]
public unsafe void WorldQueryTest()
{
// todo.papopov: switch the seed back to 0x12345678 when [UNI-281] is resolved
Expand Down
51 changes: 49 additions & 2 deletions Unity.Physics/Collision/World/CollisionWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,42 @@ public void UpdateDynamicTree(ref PhysicsWorld world, float timeStep, float3 gra
Broadphase.BuildDynamicTree(world.DynamicBodies, world.MotionVelocities, gravity, timeStep, aabbMargin);
}

/// <summary> Rebuild the static collision world. </summary>
///
/// <param name="world"> [in,out] The world. </param>
public void UpdateStaticTree(ref PhysicsWorld world)
{
float aabbMargin = world.CollisionWorld.CollisionTolerance * 0.5f;
Broadphase.BuildStaticTree(world.StaticBodies, aabbMargin);
}

/// <summary>
/// Schedule a set of jobs to update the static collision world.
/// </summary>
///
/// <param name="world"> [in,out] The world. </param>
/// <param name="buildStaticTree"> The build static tree. </param>
/// <param name="inputDeps"> The input deps. </param>
/// <param name="multiThreaded"> (Optional) True if multi threaded. </param>
///
/// <returns> A JobHandle. </returns>
public JobHandle ScheduleUpdateStaticTree(ref PhysicsWorld world,
NativeReference<int>.ReadOnly buildStaticTree, JobHandle inputDeps, bool multiThreaded = true)
{
if (!multiThreaded)
{
return new UpdateStaticTreeJob
{
World = world
}.Schedule(inputDeps);
}
else
{
// Thread count is +1 for main thread
return Broadphase.ScheduleStaticTreeBuildJobs(ref world, JobsUtility.JobWorkerCount + 1, buildStaticTree, inputDeps);
}
}

/// <summary>
/// Schedule a set of jobs to synchronize the collision world with the dynamics world.
/// </summary>
Expand All @@ -234,7 +270,7 @@ public JobHandle ScheduleUpdateDynamicTree(ref PhysicsWorld world, float timeSte
{
if (!multiThreaded)
{
return new UpdateDynamicLayerJob
return new UpdateDynamicTreeJob
{
World = world,
TimeStep = timeStep,
Expand Down Expand Up @@ -278,7 +314,7 @@ internal static void ExecuteImpl(int i, NativeArray<MotionData> motionDatas, Nat
}

[BurstCompile]
private struct UpdateDynamicLayerJob : IJob
struct UpdateDynamicTreeJob : IJob
{
public PhysicsWorld World;
public float TimeStep;
Expand All @@ -289,6 +325,17 @@ public void Execute()
World.CollisionWorld.UpdateDynamicTree(ref World, TimeStep, Gravity);
}
}
[BurstCompile]
struct UpdateStaticTreeJob : IJob
{
public PhysicsWorld World;
public NativeReference<int>.ReadOnly buildStaticTree;
public void Execute()
{
if(buildStaticTree.Value != 0)
World.CollisionWorld.UpdateStaticTree(ref World);
}
}

#endregion

Expand Down
11 changes: 11 additions & 0 deletions Unity.Physics/Dynamics/Simulation/Simulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,17 @@ public SimulationJobHandles ScheduleSolveAndIntegrateJobs(SimulationStepInput in
return m_StepHandles;
}

/// <summary>
/// Resets the simulation storage
/// - Reallocates input velocities storage if necessary
/// - Disposes event streams and allocates new ones with a single work item
/// </summary>
/// <param name="input"> The input. </param>
public void ResetSimulationContext(SimulationStepInput input)
{
SimulationContext.Reset(input);
}

/// <summary> Steps the world immediately. </summary>
///
/// <param name="input"> The input. </param>
Expand Down
Loading

0 comments on commit 40d124d

Please sign in to comment.