浏览代码

-Finally figured out the wave offset issues

/dots-physics
Mike Geig 5 年前
当前提交
8f75f0ab
共有 4 个文件被更改,包括 11 次插入9 次删除
  1. 6
      Assets/Unity Physics Items/BuoyancyVisualizer.cs
  2. 1
      Assets/Unity Physics Items/BuoyantObject_DOTS.cs
  3. 3
      Assets/Unity Physics Items/Systems/ApplyBuoyancyForceSystem.cs
  4. 10
      Assets/Unity Physics Items/Systems/GertsnerSystem.cs

6
Assets/Unity Physics Items/BuoyancyVisualizer.cs


return;
DynamicBuffer<VoxelHeight> heights = World.Active.EntityManager.GetBuffer<VoxelHeight>(boat);
DynamicBuffer<VoxelOffset> offsets = World.Active.EntityManager.GetBuffer<VoxelOffset>(boat);
Gizmos.color = Color.red;

Gizmos.DrawSphere(heights[i].Value, .1f);
Gizmos.DrawSphere(new Vector3(transform.position.x + offsets[i].Value.x, heights[i].Value.y, offsets[i].Value.z + transform.position.z), .1f);
if (boat == Entity.Null)
{
boat = conversionSystem.GetPrimaryEntity(transform.parent);

1
Assets/Unity Physics Items/BuoyantObject_DOTS.cs


private void Start()
{
//Application.targetFrameRate = (int)(1f / Time.fixedDeltaTime);
_guid = gameObject.GetInstanceID();
Init();

3
Assets/Unity Physics Items/Systems/ApplyBuoyancyForceSystem.cs


lastTime = Time.time;
var job = new ForceJob()
{
dt = Time.deltaTime,
dt = Time.fixedDeltaTime,
offsetBuffer = GetBufferFromEntity<VoxelOffset>(false),
heightBuffer = GetBufferFromEntity<VoxelHeight>(false)
};

float submergedAmount = 0f;
//Debug.Log("new pass: " + entity.ToString());
float3 avPos = float3.zero;
float3 avForce = float3.zero;
float avgHeight = 0;

10
Assets/Unity Physics Items/Systems/GertsnerSystem.cs


{
var job = new HeightJob {
waveData = waveData,
time = Time.deltaTime,
time = Time.time,
offsetBuffer = GetBufferFromEntity<VoxelOffset>(false),
heightBuffer = GetBufferFromEntity<VoxelHeight>(false)
};

[BurstCompile]
public struct HeightJob : IJobForEachWithEntity<Translation, BuoyantData>
public struct HeightJob : IJobForEachWithEntity<Translation, Rotation, BuoyantData>
{
[ReadOnly]
public NativeArray<Wave> waveData; // wave data stroed in vec4's like the shader version but packed into one

public BufferFromEntity<VoxelHeight> heightBuffer;
// The code actually running on the job
public void Execute(Entity entity, int i, [ReadOnly] ref Translation translation, ref BuoyantData data)
public void Execute(Entity entity, int i, [ReadOnly] ref Translation translation, ref Rotation rot, ref BuoyantData data)
var entityTransform = new RigidTransform(rot.Value, translation.Value);
float3 voxelPos = translation.Value + offsets[vi].Value;
float3 voxelPos = math.transform(entityTransform, offsets[vi].Value);
var waveCountMulti = 1f / waveData.Length;
float3 wavePos = new float3(0f, 0f, 0f);

正在加载...
取消
保存