Skip to content

Commit

Permalink
Version 0.11.5 Release [Bugfix]
Browse files Browse the repository at this point in the history
Bugfix release
  • Loading branch information
Dreaming381 committed Nov 3, 2024
1 parent d2ce82a commit 381a77d
Show file tree
Hide file tree
Showing 16 changed files with 250 additions and 31 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

You can find changelogs for the individual modules in the [official Latios Framework Documentation repository](https://github.com/Dreaming381/Latios-Framework-Documentation).

## [0.11.5] – 2024-11-2

Officially supports Entities [1.3.5]

### Changed

- Updated Psyshock to v0.11.5
- Updated Kinemation to v0.11.5

## [0.11.4] – 2024-10-19

Officially supports Entities [1.3.5]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Latios.Kinemation.Authoring.Systems
{
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
[UpdateInGroup(typeof(SmartBlobberBakingGroup))]
[UpdateInGroup(typeof(TransformBakingSystemGroup), OrderFirst = true)]
[DisableAutoCreation]
public partial class KinemationPreTransformsBakingGroup : ComponentSystemGroup
{
Expand Down
57 changes: 45 additions & 12 deletions Kinemation/Systems/Culling/SkinningDispatchSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Latios.Transforms.Abstract;
using Latios.Unsafe;
using Unity.Burst;
using Unity.Burst.CompilerServices;
using Unity.Burst.Intrinsics;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
Expand Down Expand Up @@ -2081,9 +2082,17 @@ void ProcessExposed(in ArchetypeChunk chunk, ref PerChunkPrefixSums prefixSums,
boneTransformsUploadBuffer[(int)prefixSums.boneTransformsToUpload] = TransformQvvs.identity;
for (int i = 1; i < bones.Length; i++)
{
var entity = bones[i].bone;
var boneWorldTransform = previousTransformLookup[entity].worldTransform;
var boneToRoot = qvvs.inversemulqvvs(in skeletonWorldTransform, in boneWorldTransform);
var entity = bones[i].bone;
if (Hint.Unlikely(!previousTransformLookup.TryGetComponent(entity, out var previousTransform)))
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
UnityEngine.Debug.LogError(
$"Bone {entity.ToFixedString()} at index {i} does not have the required PreviousTransform. Using WorldTansform instead.");
#endif
previousTransform.worldTransform = worldTransformLookup[entity].worldTransformQvvs;
}
var boneToRoot = qvvs.inversemulqvvs(in skeletonWorldTransform,
in previousTransform.worldTransform);
boneTransformsUploadBuffer[(int)prefixSums.boneTransformsToUpload + i] = boneToRoot;
}

Expand All @@ -2103,9 +2112,17 @@ void ProcessExposed(in ArchetypeChunk chunk, ref PerChunkPrefixSums prefixSums,
boneTransformsUploadBuffer[(int)prefixSums.boneTransformsToUpload] = TransformQvvs.identity;
continue;
}
var entity = bones[offsets[i]].bone;
var boneWorldTransform = previousTransformLookup[entity].worldTransform;
var boneToRoot = qvvs.inversemulqvvs(in skeletonWorldTransform, in boneWorldTransform);
var entity = bones[offsets[i]].bone;
if (Hint.Unlikely(!previousTransformLookup.TryGetComponent(entity, out var previousTransform)))
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
UnityEngine.Debug.LogError(
$"Bone {entity.ToFixedString()} at index {i} does not have the required PreviousTransform. Using WorldTansform instead.");
#endif
previousTransform.worldTransform = worldTransformLookup[entity].worldTransformQvvs;
}
var boneToRoot = qvvs.inversemulqvvs(in skeletonWorldTransform,
in previousTransform.worldTransform);
boneTransformsUploadBuffer[(int)prefixSums.boneTransformsToUpload + i] = boneToRoot;
}

Expand All @@ -2120,9 +2137,17 @@ void ProcessExposed(in ArchetypeChunk chunk, ref PerChunkPrefixSums prefixSums,
boneTransformsUploadBuffer[(int)prefixSums.boneTransformsToUpload] = TransformQvvs.identity;
for (int i = 1; i < bones.Length; i++)
{
var entity = bones[i].bone;
var boneWorldTransform = twoAgoTransformLookup[entity].worldTransform;
var boneToRoot = qvvs.inversemulqvvs(in skeletonWorldTransform, in boneWorldTransform);
var entity = bones[i].bone;
if (Hint.Unlikely(!twoAgoTransformLookup.TryGetComponent(entity, out var twoAgoTransform)))
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
UnityEngine.Debug.LogError(
$"Bone {entity.ToFixedString()} at index {i} does not have the required TwoAgoTransform. Using WorldTansform instead.");
#endif
twoAgoTransform.worldTransform = worldTransformLookup[entity].worldTransformQvvs;
}
var boneToRoot = qvvs.inversemulqvvs(in skeletonWorldTransform,
in twoAgoTransform.worldTransform);
boneTransformsUploadBuffer[(int)prefixSums.boneTransformsToUpload + i] = boneToRoot;
}

Expand All @@ -2142,9 +2167,17 @@ void ProcessExposed(in ArchetypeChunk chunk, ref PerChunkPrefixSums prefixSums,
boneTransformsUploadBuffer[(int)prefixSums.boneTransformsToUpload] = TransformQvvs.identity;
continue;
}
var entity = bones[offsets[i]].bone;
var boneWorldTransform = twoAgoTransformLookup[entity].worldTransform;
var boneToRoot = qvvs.inversemulqvvs(in skeletonWorldTransform, in boneWorldTransform);
var entity = bones[offsets[i]].bone;
if (Hint.Unlikely(!twoAgoTransformLookup.TryGetComponent(entity, out var twoAgoTransform)))
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
UnityEngine.Debug.LogError(
$"Bone {entity.ToFixedString()} at index {i} does not have the required TwoAgoTransform. Using WorldTansform instead.");
#endif
twoAgoTransform.worldTransform = worldTransformLookup[entity].worldTransformQvvs;
}
var boneToRoot = qvvs.inversemulqvvs(in skeletonWorldTransform,
in twoAgoTransform.worldTransform);
boneTransformsUploadBuffer[(int)prefixSums.boneTransformsToUpload + i] = boneToRoot;
}

Expand Down
11 changes: 10 additions & 1 deletion Kinemation/Systems/LatiosEntitiesGraphicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,12 @@ private unsafe JobHandle OnPerformCulling(BatchRendererGroup rendererGroup, Batc
m_cullPassIndexThisFrame++;
#if !UNITY_6000_0_OR_NEWER
m_dispatchPassIndexThisFrame++;
if (m_dispatchPassIndexThisFrame > 1024)
{
JobHandle.CompleteAll(m_cullingCallbackFinalJobHandles.AsArray());
m_ThreadLocalAllocators.Rewind();
}
#endif

return finalize.finalHandle;
}

Expand All @@ -591,6 +595,11 @@ private unsafe void OnFinishedCulling(IntPtr customCullingResult)
m_cullingDispatchSuperSystem.Update();
m_cullPassIndexForLastDispatch = m_cullPassIndexThisFrame;
m_dispatchPassIndexThisFrame++;
if (m_dispatchPassIndexThisFrame > 1024)
{
JobHandle.CompleteAll(m_cullingCallbackFinalJobHandles.AsArray());
m_ThreadLocalAllocators.Rewind();
}
}
#endif
#endregion
Expand Down
3 changes: 1 addition & 2 deletions PsyshockPhysics/Physics/Authoring/ColliderAuthoring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public struct ColliderBakerWorker : ISmartBakeItem<ColliderAuthoring>

public bool Bake(ColliderAuthoring authoring, IBaker baker)
{
if (!authoring.enabled)
return false;
// Reminder: Unity does not bake disabled components!
if (authoring.colliderType == AuthoringColliderTypes.None)
return false;

Expand Down
4 changes: 1 addition & 3 deletions PsyshockPhysics/Physics/Authoring/UnityColliderBakers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ public static MultiColliderBakeMode GetMultiColliderBakeMode(this IBaker baker,

internal static MultiColliderBakeMode Evaluate(IBaker baker, UnityEngine.Collider authoring, bool ignoreMulti)
{
if (!authoring.enabled)
return MultiColliderBakeMode.Ignore;

// Reminder: Unity does not bake disabled components!
s_colliderCache.Clear();
baker.GetComponents(s_colliderCache);
int enabledCount = 1;
Expand Down
4 changes: 2 additions & 2 deletions PsyshockPhysics/Physics/Dynamics/UnitySim/UnitySimMotion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public struct MotionExpansion
/// Forces such as gravity should be applied to the velocity prior to calling this.
/// </summary>
/// <param name="velocity">The velocity of the object, after forces have been applied.</param>
/// <param name="deltaTime"></param>
/// <param name="angularExpansionFactor"></param>
/// <param name="deltaTime">The time step across which the expansion should account for</param>
/// <param name="angularExpansionFactor">The factor by which the AABB may expand as it rotates</param>
public MotionExpansion(in Velocity velocity, float deltaTime, float angularExpansionFactor)
{
var linear = velocity.linear * deltaTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace Latios.Psyshock
{
public static partial class UnitySim
{
/// <summary>
/// A struct which contains a solver-optimized form of a position constraint along 1, 2, or 3 dimensions.
/// </summary>
public struct PositionConstraintJacobianParameters
{
public float3 jointPositionInInertialPoseASpace;
Expand Down Expand Up @@ -33,6 +36,22 @@ public struct PositionConstraintJacobianParameters
public bool is1D;
}

/// <summary>
/// Constructs a position constraint
/// </summary>
/// <param name="parameters">The resulting constraint data</param>
/// <param name="inertialPoseWorldTransformA">The current world-space center of mass and inertia tensor diagonal orientation of the first body A</param>
/// <param name="jointPositionInInertialPoseASpace">The inertial-pose relative position of the "joint" in A,
/// which when the constraint is in the rest pose, the world-space version of position should match the world-space counterpart in B</param>
/// <param name="inertialPoseWorldTransformB">The current world-space center of mass and inertia tensor diagonal orientation of the second body B</param>
/// <param name="jointTransformInInertialPoseBSpace">The inertial-pose relative position and rotation of the "joint" in B,
/// which when the constraint is in the rest pose, the world-space version of position should match the world-space counterpart in A,
/// and the rotation should be aligned to the constraint axes</param>
/// <param name="minDistance">The minimum distance allowed between the joint positions in world space within the axis, plane, or volume of the constrained axes</param>
/// <param name="maxDistance">The maximum distance allowed between the joint positions in world space within the axis, plane, or volume of the constrained axes</param>
/// <param name="tau">The normalized stiffness factor</param>
/// <param name="damping">The normalized damping factor</param>
/// <param name="constrainedAxes">For each axis, true if it is constrained, false otherwise</param>
public static void BuildJacobian(out PositionConstraintJacobianParameters parameters,
in RigidTransform inertialPoseWorldTransformA, float3 jointPositionInInertialPoseASpace,
in RigidTransform inertialPoseWorldTransformB, in RigidTransform jointTransformInInertialPoseBSpace,
Expand Down Expand Up @@ -83,7 +102,19 @@ public static void BuildJacobian(out PositionConstraintJacobianParameters parame
parameters.initialError = CalculatePositionConstraintError(in parameters, in inertialPoseWorldTransformA, in inertialPoseWorldTransformB, out _);
}

// Returns the world-space impulse applied to A. The world-space impulse applied to B is simply the negative of this value.
/// <summary>
/// Solves the position constraint for the pair of bodies
/// </summary>
/// <param name="velocityA">The velocity of the first body</param>
/// <param name="inertialPoseWorldTransformA">The world-space center of mass and inertia tensor diagonal orientation of the first body</param>
/// <param name="massA">The mass of the first body</param>
/// <param name="velocityB">The velocity of the second body</param>
/// <param name="inertialPoseWorldTransformB">The world-space center of mass and inertia tensor diagonal orientation of the second body</param>
/// <param name="massB">The mass of the second body</param>
/// <param name="parameters">The constraint data</param>
/// <param name="deltaTime">The timestep over which this constraint is being solved</param>
/// <param name="inverseDeltaTime">The reciprocal of deltaTime, should be: 1f / deltaTime</param>
/// <returns>The world-space impulse applied to A. The world-space impulse applied to B is simply the negative of this value.</returns>
public static float3 SolveJacobian(ref Velocity velocityA, in RigidTransform inertialPoseWorldTransformA, in Mass massA,
ref Velocity velocityB, in RigidTransform inertialPoseWorldTransformB, in Mass massB,
in PositionConstraintJacobianParameters parameters, float deltaTime, float inverseDeltaTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace Latios.Psyshock
{
public static partial class UnitySim
{
/// <summary>
/// A struct which contains a solver-optimized form of a 1D rotation constraint.
/// </summary>
public struct Rotation1DConstraintJacobianParameters
{
public quaternion inertialPoseAInInertialPoseBSpace;
Expand All @@ -25,6 +28,21 @@ public struct Rotation1DConstraintJacobianParameters
public int axisIndex;
}

/// <summary>
/// Constructs a 1D rotaton constraint
/// </summary>
/// <param name="parameters">The resulting constraint data</param>
/// <param name="inertialPoseWorldRotationA">The current world rotation of the inertia tensor diagonal of the first body A</param>
/// <param name="jointRotationInInertialPoseASpace">The inertial-pose relative rotation of the "joint" in A,
/// which when the constraint is in the rest pose, the world-space version of rotation should match the world-space counterpart in B</param>
/// <param name="inertialPoseWorldRotationB">The current world rotation of the inertia tensor diagonal of the second body B</param>
/// <param name="jointRotationInInertialPoseBSpace">The inertial-pose relative rotation of the "joint" in B,
/// which when the constraint is in the rest pose, the world-space version of rotation should match the world-space counterpart in A</param>
/// <param name="minAngle">The minimum angle allowed in the range of [-2*pi, 2*pi]</param>
/// <param name="maxAngle">The maximum angle allowed in the range of [-2*pi, 2*pi]</param>
/// <param name="tau">The normalized stiffness factor</param>
/// <param name="damping">The normalized damping factor</param>
/// <param name="axisIndex">The axis within the joint that is constrained</param>
public static void BuildJacobian(out Rotation1DConstraintJacobianParameters parameters,
quaternion inertialPoseWorldRotationA, quaternion jointRotationInInertialPoseASpace,
quaternion inertialPoseWorldRotationB, quaternion jointRotationInInertialPoseBSpace,
Expand All @@ -45,7 +63,17 @@ public static void BuildJacobian(out Rotation1DConstraintJacobianParameters para
parameters.initialError = CalculateRotation1DConstraintError(in parameters, parameters.inertialPoseAInInertialPoseBSpace);
}

// Returns the scalar impulse applied only to the angular velocity for the constrained axis.
/// <summary>
/// Solves the 1D rotation constraint for the pair of bodies
/// </summary>
/// <param name="velocityA">The velocity of the first body</param>
/// <param name="massA">The mass of the first body</param>
/// <param name="velocityB">The velocity of the second body</param>
/// <param name="massB">The mass of the second body</param>
/// <param name="parameters">The constraint data</param>
/// <param name="deltaTime">The timestep over which this constraint is being solved</param>
/// <param name="inverseDeltaTime">The reciprocal of deltaTime, should be: 1f / deltaTime</param>
/// <returns>The scalar impulse applied onlt to the angular velocity for the constrained axis</returns>
public static float SolveJacobian(ref Velocity velocityA, in Mass massA, ref Velocity velocityB, in Mass massB,
in Rotation1DConstraintJacobianParameters parameters, float deltaTime, float inverseDeltaTime)
{
Expand Down
Loading

0 comments on commit 381a77d

Please sign in to comment.