Netcode Bootstrap
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Rukhanka.Hybrid
|
||||
{
|
||||
[RequireComponent(typeof(Renderer))]
|
||||
public class GPUAttachmentAuthoring: MonoBehaviour
|
||||
{
|
||||
public int attachedBoneIndex = -1;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GPUAttachmentBaker: Baker<GPUAttachmentAuthoring>
|
||||
{
|
||||
public override void Bake(GPUAttachmentAuthoring a)
|
||||
{
|
||||
var e = GetEntity(a, TransformUsageFlags.Dynamic);
|
||||
|
||||
var ga = new GPUAttachmentComponent()
|
||||
{
|
||||
attachedBoneIndex = GetComponentInParent<RigDefinitionAuthoring>(a) != null ? -1 : a.attachedBoneIndex
|
||||
};
|
||||
AddComponent(e, ga);
|
||||
AddComponent<GPUAttachmentBoneIndexMPComponent>(e);
|
||||
AddComponent<GPUAttachmentToBoneTransformMPComponent>(e);
|
||||
AddComponent<GPURigEntityLocalToWorldMPComponent>(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14b34ef51d48dc546b4e80ec8bf8d424
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 298480
|
||||
packageName: Rukhanka Animation System 2
|
||||
packageVersion: 2.9.0
|
||||
assetPath: Packages/com.rukhanka.animation/Rukhanka.Hybrid/GPUAnimationEngine/GPUAttachmentAuthoring.cs
|
||||
uploadId: 897522
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Entities.Hybrid.Baking;
|
||||
using Unity.Rendering;
|
||||
using UnityEngine;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Rukhanka.Hybrid
|
||||
{
|
||||
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
|
||||
[RequireMatchingQueriesForUpdate]
|
||||
public partial class GPUAttachmentMeshBakingSystem: SystemBase
|
||||
{
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
var ecb = new EntityCommandBuffer(CheckedStateRef.WorldUpdateAllocator);
|
||||
|
||||
// GPU attachments support for submesh render entities
|
||||
foreach(var (aeb, gac0, gac1, gac2, e) in SystemAPI.Query
|
||||
<DynamicBuffer<AdditionalEntitiesBakingData>,
|
||||
GPUAttachmentBoneIndexMPComponent,
|
||||
GPUAttachmentToBoneTransformMPComponent,
|
||||
GPURigEntityLocalToWorldMPComponent>()
|
||||
.WithNone<MaterialMeshInfo>()
|
||||
.WithEntityAccess()
|
||||
.WithOptions(EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities))
|
||||
{
|
||||
// This is submesh render entity. Propagate GPU attachment components from parent to the children
|
||||
for (var i = 0; i < aeb.Length; ++i)
|
||||
{
|
||||
var childRenderEntity = aeb[i].Value;
|
||||
ecb.AddComponent(childRenderEntity, gac0);
|
||||
ecb.AddComponent(childRenderEntity, gac1);
|
||||
ecb.AddComponent(childRenderEntity, gac2);
|
||||
}
|
||||
ecb.RemoveComponent<GPUAttachmentBoneIndexMPComponent>(e);
|
||||
ecb.RemoveComponent<GPUAttachmentToBoneTransformMPComponent>(e);
|
||||
ecb.RemoveComponent<GPURigEntityLocalToWorldMPComponent>(e);
|
||||
}
|
||||
|
||||
ecb.Playback(EntityManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5f84bde5c6c372488dead3e80bcee4e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 298480
|
||||
packageName: Rukhanka Animation System 2
|
||||
packageVersion: 2.9.0
|
||||
assetPath: Packages/com.rukhanka.animation/Rukhanka.Hybrid/GPUAnimationEngine/GPUAttachmentMeshBakingSystem.cs
|
||||
uploadId: 897522
|
||||
Reference in New Issue
Block a user