mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2025-06-13 14:56:18 +02:00
Custom encoding/decoding.
Custom vector3 encoding/decoding test. removed normal decoding from VA functions, this should now be done outside this function to allow easy switching of decoders. Co-Authored-By: Neeto-rzo <68438932+Neeto-rzo@users.noreply.github.com>
This commit is contained in:
@ -6,70 +6,75 @@ using UnityEngine;
|
||||
|
||||
namespace TAO.VertexAnimation
|
||||
{
|
||||
//TODO: SetComponent.
|
||||
//TODO: Disable thread safety.
|
||||
//TODO: Blob data for static animation data.
|
||||
|
||||
|
||||
//public class VA_AnimatorSystem : SystemBase
|
||||
//{
|
||||
// private EndSimulationEntityCommandBufferSystem endSimulationEntityCommandBufferSystem;
|
||||
|
||||
// protected override void OnCreate()
|
||||
// {
|
||||
// base.OnCreate();
|
||||
|
||||
// endSimulationEntityCommandBufferSystem = World.GetExistingSystem<EndSimulationEntityCommandBufferSystem>();
|
||||
// }
|
||||
|
||||
// protected override void OnUpdate()
|
||||
// {
|
||||
// var ecb = endSimulationEntityCommandBufferSystem.CreateCommandBuffer().AsParallelWriter();
|
||||
|
||||
// Entities.ForEach((Entity entity, int entityInQueryIndex, in VA_AnimatorComponent ac, in DynamicBuffer<Child> children) =>
|
||||
// {
|
||||
// for (int i = 0; i < children.Length; i++)
|
||||
// {
|
||||
// // Get child.
|
||||
// Entity child = children[i].Value;
|
||||
|
||||
// // Overwrite existing component.
|
||||
// ecb.AddComponent(entityInQueryIndex, child, new VA_AnimationTimeComponent { Value = ac.animationTime });
|
||||
// ecb.AddComponent(entityInQueryIndex, child, new VA_AnimationIndexComponent { Value = ac.animationIndex });
|
||||
// }
|
||||
// })
|
||||
// .ScheduleParallel();
|
||||
|
||||
// endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(Dependency);
|
||||
// }
|
||||
// private EndSimulationEntityCommandBufferSystem endSimulationEntityCommandBufferSystem;
|
||||
|
||||
// protected override void OnCreate()
|
||||
// {
|
||||
// base.OnCreate();
|
||||
|
||||
// endSimulationEntityCommandBufferSystem = World.GetExistingSystem<EndSimulationEntityCommandBufferSystem>();
|
||||
// }
|
||||
|
||||
// protected override void OnUpdate()
|
||||
// {
|
||||
// var ecb = endSimulationEntityCommandBufferSystem.CreateCommandBuffer().AsParallelWriter();
|
||||
|
||||
// Entities.ForEach((Entity entity, int entityInQueryIndex, in VA_AnimatorComponent ac, in DynamicBuffer<Child> children) =>
|
||||
// {
|
||||
// for (int i = 0; i < children.Length; i++)
|
||||
// {
|
||||
// // Get child.
|
||||
// Entity child = children[i].Value;
|
||||
|
||||
// // Overwrite existing component.
|
||||
// ecb.AddComponent(entityInQueryIndex, child, new VA_AnimationTimeComponent { Value = ac.animationTime });
|
||||
// ecb.AddComponent(entityInQueryIndex, child, new VA_AnimationIndexComponent { Value = ac.animationIndex });
|
||||
// }
|
||||
// })
|
||||
// .ScheduleParallel();
|
||||
|
||||
// endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(Dependency);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//[UpdateBefore(typeof(HybridRendererSystem))]
|
||||
public class VA_AnimatorSystem : SystemBase
|
||||
{
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
var atc = GetComponentDataFromEntity<VA_AnimationTimeComponent>(false);
|
||||
var aic = GetComponentDataFromEntity<VA_AnimationIndexComponent>(false);
|
||||
|
||||
var aic = GetComponentDataFromEntity<VA_AnimationIndexComponent>(false);
|
||||
|
||||
Entities.ForEach((ref VA_AnimatorComponent ac, in DynamicBuffer<Child> children) =>
|
||||
{
|
||||
for (int i = 0; i < children.Length; i++)
|
||||
{
|
||||
// Get child.
|
||||
Entity child = children[i].Value;
|
||||
|
||||
// Get a copy of the time Component of the child.
|
||||
VA_AnimationTimeComponent atcCopy = atc[child];
|
||||
// Set new value.
|
||||
atcCopy.Value = ac.animationTime;
|
||||
// Update original.
|
||||
atc[child] = atcCopy;
|
||||
|
||||
VA_AnimationIndexComponent aicCopy = aic[child];
|
||||
aicCopy.Value = ac.animationIndex;
|
||||
aic[child] = aicCopy;
|
||||
}
|
||||
})
|
||||
.Run();
|
||||
}
|
||||
{
|
||||
for (int i = 0; i < children.Length; i++)
|
||||
{
|
||||
// Get child.
|
||||
Entity child = children[i].Value;
|
||||
|
||||
// Get a copy of the time Component of the child.
|
||||
VA_AnimationTimeComponent atcCopy = atc[child];
|
||||
// Set new value.
|
||||
atcCopy.Value = ac.animationTime;
|
||||
// Update original.
|
||||
atc[child] = atcCopy;
|
||||
|
||||
VA_AnimationIndexComponent aicCopy = aic[child];
|
||||
aicCopy.Value = ac.animationIndex;
|
||||
aic[child] = aicCopy;
|
||||
}
|
||||
})
|
||||
.Run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class VA_AnimatorSystem2 : SystemBase
|
||||
{
|
||||
protected override void OnCreate()
|
||||
@ -128,8 +133,9 @@ namespace TAO.VertexAnimation
|
||||
{
|
||||
Entities.ForEach((Entity entity, ref VA_AnimatorComponent ac) =>
|
||||
{
|
||||
int index = entity.Index % 2;
|
||||
ac.animationIndex = index;
|
||||
//int index = entity.Index % 2;
|
||||
//ac.animationIndex = index;
|
||||
ac.animationIndex = 0;
|
||||
}).ScheduleParallel();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user