浏览代码

-Added recent tests for further work

/dots-input
Mike Geig 5 年前
当前提交
abbc0594
共有 7 个文件被更改,包括 107 次插入644 次删除
  1. 29
      Assets/Unity Physics Items/ApplyBuoyancyForceSystem.cs
  2. 7
      Assets/Unity Physics Items/BuoyantObject2.cs
  3. 658
      Assets/Unity Physics Items/Physics Scene.unity
  4. 22
      Assets/Unity Physics Items/Physics Settings.prefab
  5. 3
      Packages/com.verasl.water-system/Scripts/BuoyantObject.cs
  6. 21
      Assets/Unity Physics Items/PhysicsConversionSystem.cs
  7. 11
      Assets/Unity Physics Items/PhysicsConversionSystem.cs.meta

29
Assets/Unity Physics Items/ApplyBuoyancyForceSystem.cs


[UpdateAfter(typeof(GertsnerSystem)), UpdateAfter(typeof(ExportPhysicsWorld))]
public class ApplyBuoyancyForceSystem : JobComponentSystem
{
float lastTime = 0;
Debug.Log(string.Format("DeltaTime: {0}, Time.time {1}, Calc Delta: {2}", Time.deltaTime, Time.time, Time.time - lastTime));
lastTime = Time.time;
var job = new ForceJob()
{
dt = Time.deltaTime,

DynamicBuffer<VoxelOffset> offsets = offsetBuffer[entity];
DynamicBuffer<VoxelHeight> heights = heightBuffer[entity];
var vel2 = vel;
float3 totalForce = float3.zero;
float3 averagePos = float3.zero;
int total = 0;
//Apply buoyant force
for (var i = 0; i < offsets.Length; i++)
{

submergedAmount += subFactor;//(math.clamp(waterLevel - (wp.y - voxelResolution), 0f, voxelResolution * 2f) / (voxelResolution * 2f)) / voxels.Count;
var force2 = data.localArchimedesForce * subFactor;
//var force2 = data.localArchimedesForce * subFactor;
var velocity = ComponentExtensions.GetLinearVelocity(vel, mass, pos, rot, wp);
var velocity = ComponentExtensions.GetLinearVelocity(vel2, mass, pos, rot, wp);
totalForce += force;
averagePos += wp;
total++;
Debug.Log(string.Format("Position: {0:f1} -- Force: {1:f2} -- Height: {2:f2}\nVelocty: {3:f2} -- Damp: {4:f2} -- Mass: {5:f1} -- K: {6:f2}", wp, force, waterLevel, velocity, localDampingForce, math.rcp(mass.InverseMass), data.localArchimedesForce));
Debug.Log(string.Format("Position: {0:f1} -- Force: {1:f2} -- Height: {2:f2}\nVelocty: {3:f2} -- Damp: {4:f2} -- Mass: {5:f1} -- K: {6:f2}", wp, force, waterLevel, velocity, localDampingForce, math.rcp(mass.InverseMass), dt));
//if(total != 0)
//ComponentExtensions.ApplyImpulse(ref vel, mass, pos, rot, totalForce / math.rcp(mass.InverseMass) * dt, averagePos / total);
Debug.Log("Total Force: " + totalForce);
//submergedAmount /= offsets.Length;
//damping.Linear = Mathf.Lerp(data.baseDrag, 1f, submergedAmount);
//damping.Angular = Mathf.Lerp(data.baseAngularDrag, 1f, submergedAmount);

7
Assets/Unity Physics Items/BuoyantObject2.cs


using UnityEngine;
using Unity.Mathematics;
using Unity.Entities;
//using Unity.Physics;
public class BuoyantObject2 : MonoBehaviour, IConvertGameObjectToEntity
public class BuoyantObject2 : MonoBehaviour//, IConvertGameObjectToEntity
{
public BuoyancyType _buoyancyType; // type of buoyancy to calculate
public float density; // density of the object, this is calculated off it's volume and mass

dstManager.AddBuffer<VoxelOffset>(entity);
dstManager.AddBuffer<VoxelHeight>(entity);
//var mass = dstManager.GetComponentData<Unity.Physics.PhysicsMass>(entity);
//mass.Transform.pos = centerOfMass;
//dstManager.SetComponentData(entity, mass);
DynamicBuffer<VoxelOffset> offsets = dstManager.GetBuffer<VoxelOffset>(entity);
DynamicBuffer<VoxelHeight> heights = dstManager.GetBuffer<VoxelHeight>(entity);

658
Assets/Unity Physics Items/Physics Scene.unity


m_Name:
m_EditorClassIdentifier:
_buoyancyType: 3
density: 10
volume: 64
density: 640
volume: 1
- {x: -3.75, y: -0.25, z: -3.75}
- {x: -3.75, y: -0.25, z: -3.25}
- {x: -3.75, y: -0.25, z: -2.75}
- {x: -3.75, y: -0.25, z: -2.25}
- {x: -3.75, y: -0.25, z: -1.75}
- {x: -3.75, y: -0.25, z: -1.25}
- {x: -3.75, y: -0.25, z: -0.75}
- {x: -3.75, y: -0.25, z: -0.25}
- {x: -3.75, y: -0.25, z: 0.25}
- {x: -3.75, y: -0.25, z: 0.75}
- {x: -3.75, y: -0.25, z: 1.25}
- {x: -3.75, y: -0.25, z: 1.75}
- {x: -3.75, y: -0.25, z: 2.25}
- {x: -3.75, y: -0.25, z: 2.75}
- {x: -3.75, y: -0.25, z: 3.25}
- {x: -3.75, y: -0.25, z: 3.75}
- {x: -3.75, y: 0.25, z: -3.75}
- {x: -3.75, y: 0.25, z: -3.25}
- {x: -3.75, y: 0.25, z: -2.75}
- {x: -3.75, y: 0.25, z: -2.25}
- {x: -3.75, y: 0.25, z: -1.75}
- {x: -3.75, y: 0.25, z: -1.25}
- {x: -3.75, y: 0.25, z: -0.75}
- {x: -3.75, y: 0.25, z: -0.25}
- {x: -3.75, y: 0.25, z: 0.25}
- {x: -3.75, y: 0.25, z: 0.75}
- {x: -3.75, y: 0.25, z: 1.25}
- {x: -3.75, y: 0.25, z: 1.75}
- {x: -3.75, y: 0.25, z: 2.25}
- {x: -3.75, y: 0.25, z: 2.75}
- {x: -3.75, y: 0.25, z: 3.25}
- {x: -3.75, y: 0.25, z: 3.75}
- {x: -3.25, y: -0.25, z: -3.75}
- {x: -3.25, y: -0.25, z: -3.25}
- {x: -3.25, y: -0.25, z: -2.75}
- {x: -3.25, y: -0.25, z: -2.25}
- {x: -3.25, y: -0.25, z: -1.75}
- {x: -3.25, y: -0.25, z: -1.25}
- {x: -3.25, y: -0.25, z: -0.75}
- {x: -3.25, y: -0.25, z: -0.25}
- {x: -3.25, y: -0.25, z: 0.25}
- {x: -3.25, y: -0.25, z: 0.75}
- {x: -3.25, y: -0.25, z: 1.25}
- {x: -3.25, y: -0.25, z: 1.75}
- {x: -3.25, y: -0.25, z: 2.25}
- {x: -3.25, y: -0.25, z: 2.75}
- {x: -3.25, y: -0.25, z: 3.25}
- {x: -3.25, y: -0.25, z: 3.75}
- {x: -3.25, y: 0.25, z: -3.75}
- {x: -3.25, y: 0.25, z: -3.25}
- {x: -3.25, y: 0.25, z: -2.75}
- {x: -3.25, y: 0.25, z: -2.25}
- {x: -3.25, y: 0.25, z: -1.75}
- {x: -3.25, y: 0.25, z: -1.25}
- {x: -3.25, y: 0.25, z: -0.75}
- {x: -3.25, y: 0.25, z: -0.25}
- {x: -3.25, y: 0.25, z: 0.25}
- {x: -3.25, y: 0.25, z: 0.75}
- {x: -3.25, y: 0.25, z: 1.25}
- {x: -3.25, y: 0.25, z: 1.75}
- {x: -3.25, y: 0.25, z: 2.25}
- {x: -3.25, y: 0.25, z: 2.75}
- {x: -3.25, y: 0.25, z: 3.25}
- {x: -3.25, y: 0.25, z: 3.75}
- {x: -2.75, y: -0.25, z: -3.75}
- {x: -2.75, y: -0.25, z: -3.25}
- {x: -2.75, y: -0.25, z: -2.75}
- {x: -2.75, y: -0.25, z: -2.25}
- {x: -2.75, y: -0.25, z: -1.75}
- {x: -2.75, y: -0.25, z: -1.25}
- {x: -2.75, y: -0.25, z: -0.75}
- {x: -2.75, y: -0.25, z: -0.25}
- {x: -2.75, y: -0.25, z: 0.25}
- {x: -2.75, y: -0.25, z: 0.75}
- {x: -2.75, y: -0.25, z: 1.25}
- {x: -2.75, y: -0.25, z: 1.75}
- {x: -2.75, y: -0.25, z: 2.25}
- {x: -2.75, y: -0.25, z: 2.75}
- {x: -2.75, y: -0.25, z: 3.25}
- {x: -2.75, y: -0.25, z: 3.75}
- {x: -2.75, y: 0.25, z: -3.75}
- {x: -2.75, y: 0.25, z: -3.25}
- {x: -2.75, y: 0.25, z: -2.75}
- {x: -2.75, y: 0.25, z: -2.25}
- {x: -2.75, y: 0.25, z: -1.75}
- {x: -2.75, y: 0.25, z: -1.25}
- {x: -2.75, y: 0.25, z: -0.75}
- {x: -2.75, y: 0.25, z: -0.25}
- {x: -2.75, y: 0.25, z: 0.25}
- {x: -2.75, y: 0.25, z: 0.75}
- {x: -2.75, y: 0.25, z: 1.25}
- {x: -2.75, y: 0.25, z: 1.75}
- {x: -2.75, y: 0.25, z: 2.25}
- {x: -2.75, y: 0.25, z: 2.75}
- {x: -2.75, y: 0.25, z: 3.25}
- {x: -2.75, y: 0.25, z: 3.75}
- {x: -2.25, y: -0.25, z: -3.75}
- {x: -2.25, y: -0.25, z: -3.25}
- {x: -2.25, y: -0.25, z: -2.75}
- {x: -2.25, y: -0.25, z: -2.25}
- {x: -2.25, y: -0.25, z: -1.75}
- {x: -2.25, y: -0.25, z: -1.25}
- {x: -2.25, y: -0.25, z: -0.75}
- {x: -2.25, y: -0.25, z: -0.25}
- {x: -2.25, y: -0.25, z: 0.25}
- {x: -2.25, y: -0.25, z: 0.75}
- {x: -2.25, y: -0.25, z: 1.25}
- {x: -2.25, y: -0.25, z: 1.75}
- {x: -2.25, y: -0.25, z: 2.25}
- {x: -2.25, y: -0.25, z: 2.75}
- {x: -2.25, y: -0.25, z: 3.25}
- {x: -2.25, y: -0.25, z: 3.75}
- {x: -2.25, y: 0.25, z: -3.75}
- {x: -2.25, y: 0.25, z: -3.25}
- {x: -2.25, y: 0.25, z: -2.75}
- {x: -2.25, y: 0.25, z: -2.25}
- {x: -2.25, y: 0.25, z: -1.75}
- {x: -2.25, y: 0.25, z: -1.25}
- {x: -2.25, y: 0.25, z: -0.75}
- {x: -2.25, y: 0.25, z: -0.25}
- {x: -2.25, y: 0.25, z: 0.25}
- {x: -2.25, y: 0.25, z: 0.75}
- {x: -2.25, y: 0.25, z: 1.25}
- {x: -2.25, y: 0.25, z: 1.75}
- {x: -2.25, y: 0.25, z: 2.25}
- {x: -2.25, y: 0.25, z: 2.75}
- {x: -2.25, y: 0.25, z: 3.25}
- {x: -2.25, y: 0.25, z: 3.75}
- {x: -1.75, y: -0.25, z: -3.75}
- {x: -1.75, y: -0.25, z: -3.25}
- {x: -1.75, y: -0.25, z: -2.75}
- {x: -1.75, y: -0.25, z: -2.25}
- {x: -1.75, y: -0.25, z: -1.75}
- {x: -1.75, y: -0.25, z: -1.25}
- {x: -1.75, y: -0.25, z: -0.75}
- {x: -1.75, y: -0.25, z: -0.25}
- {x: -1.75, y: -0.25, z: 0.25}
- {x: -1.75, y: -0.25, z: 0.75}
- {x: -1.75, y: -0.25, z: 1.25}
- {x: -1.75, y: -0.25, z: 1.75}
- {x: -1.75, y: -0.25, z: 2.25}
- {x: -1.75, y: -0.25, z: 2.75}
- {x: -1.75, y: -0.25, z: 3.25}
- {x: -1.75, y: -0.25, z: 3.75}
- {x: -1.75, y: 0.25, z: -3.75}
- {x: -1.75, y: 0.25, z: -3.25}
- {x: -1.75, y: 0.25, z: -2.75}
- {x: -1.75, y: 0.25, z: -2.25}
- {x: -1.75, y: 0.25, z: -1.75}
- {x: -1.75, y: 0.25, z: -1.25}
- {x: -1.75, y: 0.25, z: -0.75}
- {x: -1.75, y: 0.25, z: -0.25}
- {x: -1.75, y: 0.25, z: 0.25}
- {x: -1.75, y: 0.25, z: 0.75}
- {x: -1.75, y: 0.25, z: 1.25}
- {x: -1.75, y: 0.25, z: 1.75}
- {x: -1.75, y: 0.25, z: 2.25}
- {x: -1.75, y: 0.25, z: 2.75}
- {x: -1.75, y: 0.25, z: 3.25}
- {x: -1.75, y: 0.25, z: 3.75}
- {x: -1.25, y: -0.25, z: -3.75}
- {x: -1.25, y: -0.25, z: -3.25}
- {x: -1.25, y: -0.25, z: -2.75}
- {x: -1.25, y: -0.25, z: -2.25}
- {x: -1.25, y: -0.25, z: -1.75}
- {x: -1.25, y: -0.25, z: -1.25}
- {x: -1.25, y: -0.25, z: -0.75}
- {x: -1.25, y: -0.25, z: -0.25}
- {x: -1.25, y: -0.25, z: 0.25}
- {x: -1.25, y: -0.25, z: 0.75}
- {x: -1.25, y: -0.25, z: 1.25}
- {x: -1.25, y: -0.25, z: 1.75}
- {x: -1.25, y: -0.25, z: 2.25}
- {x: -1.25, y: -0.25, z: 2.75}
- {x: -1.25, y: -0.25, z: 3.25}
- {x: -1.25, y: -0.25, z: 3.75}
- {x: -1.25, y: 0.25, z: -3.75}
- {x: -1.25, y: 0.25, z: -3.25}
- {x: -1.25, y: 0.25, z: -2.75}
- {x: -1.25, y: 0.25, z: -2.25}
- {x: -1.25, y: 0.25, z: -1.75}
- {x: -1.25, y: 0.25, z: -1.25}
- {x: -1.25, y: 0.25, z: -0.75}
- {x: -1.25, y: 0.25, z: -0.25}
- {x: -1.25, y: 0.25, z: 0.25}
- {x: -1.25, y: 0.25, z: 0.75}
- {x: -1.25, y: 0.25, z: 1.25}
- {x: -1.25, y: 0.25, z: 1.75}
- {x: -1.25, y: 0.25, z: 2.25}
- {x: -1.25, y: 0.25, z: 2.75}
- {x: -1.25, y: 0.25, z: 3.25}
- {x: -1.25, y: 0.25, z: 3.75}
- {x: -0.75, y: -0.25, z: -3.75}
- {x: -0.75, y: -0.25, z: -3.25}
- {x: -0.75, y: -0.25, z: -2.75}
- {x: -0.75, y: -0.25, z: -2.25}
- {x: -0.75, y: -0.25, z: -1.75}
- {x: -0.75, y: -0.25, z: -1.25}
- {x: -0.75, y: -0.25, z: -0.75}
- {x: -0.75, y: -0.25, z: -0.25}
- {x: -0.75, y: -0.25, z: 0.25}
- {x: -0.75, y: -0.25, z: 0.75}
- {x: -0.75, y: -0.25, z: 1.25}
- {x: -0.75, y: -0.25, z: 1.75}
- {x: -0.75, y: -0.25, z: 2.25}
- {x: -0.75, y: -0.25, z: 2.75}
- {x: -0.75, y: -0.25, z: 3.25}
- {x: -0.75, y: -0.25, z: 3.75}
- {x: -0.75, y: 0.25, z: -3.75}
- {x: -0.75, y: 0.25, z: -3.25}
- {x: -0.75, y: 0.25, z: -2.75}
- {x: -0.75, y: 0.25, z: -2.25}
- {x: -0.75, y: 0.25, z: -1.75}
- {x: -0.75, y: 0.25, z: -1.25}
- {x: -0.75, y: 0.25, z: -0.75}
- {x: -0.75, y: 0.25, z: -0.25}
- {x: -0.75, y: 0.25, z: 0.25}
- {x: -0.75, y: 0.25, z: 0.75}
- {x: -0.75, y: 0.25, z: 1.25}
- {x: -0.75, y: 0.25, z: 1.75}
- {x: -0.75, y: 0.25, z: 2.25}
- {x: -0.75, y: 0.25, z: 2.75}
- {x: -0.75, y: 0.25, z: 3.25}
- {x: -0.75, y: 0.25, z: 3.75}
- {x: -0.25, y: -0.25, z: -3.75}
- {x: -0.25, y: -0.25, z: -3.25}
- {x: -0.25, y: -0.25, z: -2.75}
- {x: -0.25, y: -0.25, z: -2.25}
- {x: -0.25, y: -0.25, z: -1.75}
- {x: -0.25, y: -0.25, z: -1.25}
- {x: -0.25, y: -0.25, z: -0.75}
- {x: -0.25, y: -0.25, z: 0.75}
- {x: -0.25, y: -0.25, z: 1.25}
- {x: -0.25, y: -0.25, z: 1.75}
- {x: -0.25, y: -0.25, z: 2.25}
- {x: -0.25, y: -0.25, z: 2.75}
- {x: -0.25, y: -0.25, z: 3.25}
- {x: -0.25, y: -0.25, z: 3.75}
- {x: -0.25, y: 0.25, z: -3.75}
- {x: -0.25, y: 0.25, z: -3.25}
- {x: -0.25, y: 0.25, z: -2.75}
- {x: -0.25, y: 0.25, z: -2.25}
- {x: -0.25, y: 0.25, z: -1.75}
- {x: -0.25, y: 0.25, z: -1.25}
- {x: -0.25, y: 0.25, z: -0.75}
- {x: -0.25, y: 0.25, z: 0.75}
- {x: -0.25, y: 0.25, z: 1.25}
- {x: -0.25, y: 0.25, z: 1.75}
- {x: -0.25, y: 0.25, z: 2.25}
- {x: -0.25, y: 0.25, z: 2.75}
- {x: -0.25, y: 0.25, z: 3.25}
- {x: -0.25, y: 0.25, z: 3.75}
- {x: 0.25, y: -0.25, z: -3.75}
- {x: 0.25, y: -0.25, z: -3.25}
- {x: 0.25, y: -0.25, z: -2.75}
- {x: 0.25, y: -0.25, z: -2.25}
- {x: 0.25, y: -0.25, z: -1.75}
- {x: 0.25, y: -0.25, z: -1.25}
- {x: 0.25, y: -0.25, z: -0.75}
- {x: 0.25, y: -0.25, z: 0.75}
- {x: 0.25, y: -0.25, z: 1.25}
- {x: 0.25, y: -0.25, z: 1.75}
- {x: 0.25, y: -0.25, z: 2.25}
- {x: 0.25, y: -0.25, z: 2.75}
- {x: 0.25, y: -0.25, z: 3.25}
- {x: 0.25, y: -0.25, z: 3.75}
- {x: 0.25, y: 0.25, z: -3.75}
- {x: 0.25, y: 0.25, z: -3.25}
- {x: 0.25, y: 0.25, z: -2.75}
- {x: 0.25, y: 0.25, z: -2.25}
- {x: 0.25, y: 0.25, z: -1.75}
- {x: 0.25, y: 0.25, z: -1.25}
- {x: 0.25, y: 0.25, z: -0.75}
- {x: 0.25, y: 0.25, z: 0.75}
- {x: 0.25, y: 0.25, z: 1.25}
- {x: 0.25, y: 0.25, z: 1.75}
- {x: 0.25, y: 0.25, z: 2.25}
- {x: 0.25, y: 0.25, z: 2.75}
- {x: 0.25, y: 0.25, z: 3.25}
- {x: 0.25, y: 0.25, z: 3.75}
- {x: 0.75, y: -0.25, z: -3.75}
- {x: 0.75, y: -0.25, z: -3.25}
- {x: 0.75, y: -0.25, z: -2.75}
- {x: 0.75, y: -0.25, z: -2.25}
- {x: 0.75, y: -0.25, z: -1.75}
- {x: 0.75, y: -0.25, z: -1.25}
- {x: 0.75, y: -0.25, z: -0.75}
- {x: 0.75, y: -0.25, z: -0.25}
- {x: 0.75, y: -0.25, z: 0.25}
- {x: 0.75, y: -0.25, z: 0.75}
- {x: 0.75, y: -0.25, z: 1.25}
- {x: 0.75, y: -0.25, z: 1.75}
- {x: 0.75, y: -0.25, z: 2.25}
- {x: 0.75, y: -0.25, z: 2.75}
- {x: 0.75, y: -0.25, z: 3.25}
- {x: 0.75, y: -0.25, z: 3.75}
- {x: 0.75, y: 0.25, z: -3.75}
- {x: 0.75, y: 0.25, z: -3.25}
- {x: 0.75, y: 0.25, z: -2.75}
- {x: 0.75, y: 0.25, z: -2.25}
- {x: 0.75, y: 0.25, z: -1.75}
- {x: 0.75, y: 0.25, z: -1.25}
- {x: 0.75, y: 0.25, z: -0.75}
- {x: 0.75, y: 0.25, z: -0.25}
- {x: 0.75, y: 0.25, z: 0.25}
- {x: 0.75, y: 0.25, z: 0.75}
- {x: 0.75, y: 0.25, z: 1.25}
- {x: 0.75, y: 0.25, z: 1.75}
- {x: 0.75, y: 0.25, z: 2.25}
- {x: 0.75, y: 0.25, z: 2.75}
- {x: 0.75, y: 0.25, z: 3.25}
- {x: 0.75, y: 0.25, z: 3.75}
- {x: 1.25, y: -0.25, z: -3.75}
- {x: 1.25, y: -0.25, z: -3.25}
- {x: 1.25, y: -0.25, z: -2.75}
- {x: 1.25, y: -0.25, z: -2.25}
- {x: 1.25, y: -0.25, z: -1.75}
- {x: 1.25, y: -0.25, z: -1.25}
- {x: 1.25, y: -0.25, z: -0.75}
- {x: 1.25, y: -0.25, z: -0.25}
- {x: 1.25, y: -0.25, z: 0.25}
- {x: 1.25, y: -0.25, z: 0.75}
- {x: 1.25, y: -0.25, z: 1.25}
- {x: 1.25, y: -0.25, z: 1.75}
- {x: 1.25, y: -0.25, z: 2.25}
- {x: 1.25, y: -0.25, z: 2.75}
- {x: 1.25, y: -0.25, z: 3.25}
- {x: 1.25, y: -0.25, z: 3.75}
- {x: 1.25, y: 0.25, z: -3.75}
- {x: 1.25, y: 0.25, z: -3.25}
- {x: 1.25, y: 0.25, z: -2.75}
- {x: 1.25, y: 0.25, z: -2.25}
- {x: 1.25, y: 0.25, z: -1.75}
- {x: 1.25, y: 0.25, z: -1.25}
- {x: 1.25, y: 0.25, z: -0.75}
- {x: 1.25, y: 0.25, z: -0.25}
- {x: 1.25, y: 0.25, z: 0.25}
- {x: 1.25, y: 0.25, z: 0.75}
- {x: 1.25, y: 0.25, z: 1.25}
- {x: 1.25, y: 0.25, z: 1.75}
- {x: 1.25, y: 0.25, z: 2.25}
- {x: 1.25, y: 0.25, z: 2.75}
- {x: 1.25, y: 0.25, z: 3.25}
- {x: 1.25, y: 0.25, z: 3.75}
- {x: 1.75, y: -0.25, z: -3.75}
- {x: 1.75, y: -0.25, z: -3.25}
- {x: 1.75, y: -0.25, z: -2.75}
- {x: 1.75, y: -0.25, z: -2.25}
- {x: 1.75, y: -0.25, z: -1.75}
- {x: 1.75, y: -0.25, z: -1.25}
- {x: 1.75, y: -0.25, z: -0.75}
- {x: 1.75, y: -0.25, z: -0.25}
- {x: 1.75, y: -0.25, z: 0.25}
- {x: 1.75, y: -0.25, z: 0.75}
- {x: 1.75, y: -0.25, z: 1.25}
- {x: 1.75, y: -0.25, z: 1.75}
- {x: 1.75, y: -0.25, z: 2.25}
- {x: 1.75, y: -0.25, z: 2.75}
- {x: 1.75, y: -0.25, z: 3.25}
- {x: 1.75, y: -0.25, z: 3.75}
- {x: 1.75, y: 0.25, z: -3.75}
- {x: 1.75, y: 0.25, z: -3.25}
- {x: 1.75, y: 0.25, z: -2.75}
- {x: 1.75, y: 0.25, z: -2.25}
- {x: 1.75, y: 0.25, z: -1.75}
- {x: 1.75, y: 0.25, z: -1.25}
- {x: 1.75, y: 0.25, z: -0.75}
- {x: 1.75, y: 0.25, z: -0.25}
- {x: 1.75, y: 0.25, z: 0.25}
- {x: 1.75, y: 0.25, z: 0.75}
- {x: 1.75, y: 0.25, z: 1.25}
- {x: 1.75, y: 0.25, z: 1.75}
- {x: 1.75, y: 0.25, z: 2.25}
- {x: 1.75, y: 0.25, z: 2.75}
- {x: 1.75, y: 0.25, z: 3.25}
- {x: 1.75, y: 0.25, z: 3.75}
- {x: 2.25, y: -0.25, z: -3.75}
- {x: 2.25, y: -0.25, z: -3.25}
- {x: 2.25, y: -0.25, z: -2.75}
- {x: 2.25, y: -0.25, z: -2.25}
- {x: 2.25, y: -0.25, z: -1.75}
- {x: 2.25, y: -0.25, z: -1.25}
- {x: 2.25, y: -0.25, z: -0.75}
- {x: 2.25, y: -0.25, z: -0.25}
- {x: 2.25, y: -0.25, z: 0.25}
- {x: 2.25, y: -0.25, z: 0.75}
- {x: 2.25, y: -0.25, z: 1.25}
- {x: 2.25, y: -0.25, z: 1.75}
- {x: 2.25, y: -0.25, z: 2.25}
- {x: 2.25, y: -0.25, z: 2.75}
- {x: 2.25, y: -0.25, z: 3.25}
- {x: 2.25, y: -0.25, z: 3.75}
- {x: 2.25, y: 0.25, z: -3.75}
- {x: 2.25, y: 0.25, z: -3.25}
- {x: 2.25, y: 0.25, z: -2.75}
- {x: 2.25, y: 0.25, z: -2.25}
- {x: 2.25, y: 0.25, z: -1.75}
- {x: 2.25, y: 0.25, z: -1.25}
- {x: 2.25, y: 0.25, z: -0.75}
- {x: 2.25, y: 0.25, z: -0.25}
- {x: 2.25, y: 0.25, z: 0.25}
- {x: 2.25, y: 0.25, z: 0.75}
- {x: 2.25, y: 0.25, z: 1.25}
- {x: 2.25, y: 0.25, z: 1.75}
- {x: 2.25, y: 0.25, z: 2.25}
- {x: 2.25, y: 0.25, z: 2.75}
- {x: 2.25, y: 0.25, z: 3.25}
- {x: 2.25, y: 0.25, z: 3.75}
- {x: 2.75, y: -0.25, z: -3.75}
- {x: 2.75, y: -0.25, z: -3.25}
- {x: 2.75, y: -0.25, z: -2.75}
- {x: 2.75, y: -0.25, z: -2.25}
- {x: 2.75, y: -0.25, z: -1.75}
- {x: 2.75, y: -0.25, z: -1.25}
- {x: 2.75, y: -0.25, z: -0.75}
- {x: 2.75, y: -0.25, z: -0.25}
- {x: 2.75, y: -0.25, z: 0.25}
- {x: 2.75, y: -0.25, z: 0.75}
- {x: 2.75, y: -0.25, z: 1.25}
- {x: 2.75, y: -0.25, z: 1.75}
- {x: 2.75, y: -0.25, z: 2.25}
- {x: 2.75, y: -0.25, z: 2.75}
- {x: 2.75, y: -0.25, z: 3.25}
- {x: 2.75, y: -0.25, z: 3.75}
- {x: 2.75, y: 0.25, z: -3.75}
- {x: 2.75, y: 0.25, z: -3.25}
- {x: 2.75, y: 0.25, z: -2.75}
- {x: 2.75, y: 0.25, z: -2.25}
- {x: 2.75, y: 0.25, z: -1.75}
- {x: 2.75, y: 0.25, z: -1.25}
- {x: 2.75, y: 0.25, z: -0.75}
- {x: 2.75, y: 0.25, z: -0.25}
- {x: 2.75, y: 0.25, z: 0.25}
- {x: 2.75, y: 0.25, z: 0.75}
- {x: 2.75, y: 0.25, z: 1.25}
- {x: 2.75, y: 0.25, z: 1.75}
- {x: 2.75, y: 0.25, z: 2.25}
- {x: 2.75, y: 0.25, z: 2.75}
- {x: 2.75, y: 0.25, z: 3.25}
- {x: 2.75, y: 0.25, z: 3.75}
- {x: 3.25, y: -0.25, z: -3.75}
- {x: 3.25, y: -0.25, z: -3.25}
- {x: 3.25, y: -0.25, z: -2.75}
- {x: 3.25, y: -0.25, z: -2.25}
- {x: 3.25, y: -0.25, z: -1.75}
- {x: 3.25, y: -0.25, z: -1.25}
- {x: 3.25, y: -0.25, z: -0.75}
- {x: 3.25, y: -0.25, z: -0.25}
- {x: 3.25, y: -0.25, z: 0.25}
- {x: 3.25, y: -0.25, z: 0.75}
- {x: 3.25, y: -0.25, z: 1.25}
- {x: 3.25, y: -0.25, z: 1.75}
- {x: 3.25, y: -0.25, z: 2.25}
- {x: 3.25, y: -0.25, z: 2.75}
- {x: 3.25, y: -0.25, z: 3.25}
- {x: 3.25, y: -0.25, z: 3.75}
- {x: 3.25, y: 0.25, z: -3.75}
- {x: 3.25, y: 0.25, z: -3.25}
- {x: 3.25, y: 0.25, z: -2.75}
- {x: 3.25, y: 0.25, z: -2.25}
- {x: 3.25, y: 0.25, z: -1.75}
- {x: 3.25, y: 0.25, z: -1.25}
- {x: 3.25, y: 0.25, z: -0.75}
- {x: 3.25, y: 0.25, z: -0.25}
- {x: 3.25, y: 0.25, z: 0.25}
- {x: 3.25, y: 0.25, z: 0.75}
- {x: 3.25, y: 0.25, z: 1.25}
- {x: 3.25, y: 0.25, z: 1.75}
- {x: 3.25, y: 0.25, z: 2.25}
- {x: 3.25, y: 0.25, z: 2.75}
- {x: 3.25, y: 0.25, z: 3.25}
- {x: 3.25, y: 0.25, z: 3.75}
- {x: 3.75, y: -0.25, z: -3.75}
- {x: 3.75, y: -0.25, z: -3.25}
- {x: 3.75, y: -0.25, z: -2.75}
- {x: 3.75, y: -0.25, z: -2.25}
- {x: 3.75, y: -0.25, z: -1.75}
- {x: 3.75, y: -0.25, z: -1.25}
- {x: 3.75, y: -0.25, z: -0.75}
- {x: 3.75, y: -0.25, z: -0.25}
- {x: 3.75, y: -0.25, z: 0.25}
- {x: 3.75, y: -0.25, z: 0.75}
- {x: 3.75, y: -0.25, z: 1.25}
- {x: 3.75, y: -0.25, z: 1.75}
- {x: 3.75, y: -0.25, z: 2.25}
- {x: 3.75, y: -0.25, z: 2.75}
- {x: 3.75, y: -0.25, z: 3.25}
- {x: 3.75, y: -0.25, z: 3.75}
- {x: 3.75, y: 0.25, z: -3.75}
- {x: 3.75, y: 0.25, z: -3.25}
- {x: 3.75, y: 0.25, z: -2.75}
- {x: 3.75, y: 0.25, z: -2.25}
- {x: 3.75, y: 0.25, z: -1.75}
- {x: 3.75, y: 0.25, z: -1.25}
- {x: 3.75, y: 0.25, z: -0.75}
- {x: 3.75, y: 0.25, z: -0.25}
- {x: 3.75, y: 0.25, z: 0.25}
- {x: 3.75, y: 0.25, z: 0.75}
- {x: 3.75, y: 0.25, z: 1.25}
- {x: 3.75, y: 0.25, z: 1.75}
- {x: 3.75, y: 0.25, z: 2.25}
- {x: 3.75, y: 0.25, z: 2.75}
- {x: 3.75, y: 0.25, z: 3.25}
- {x: 3.75, y: 0.25, z: 3.75}
colliders:
- {fileID: 180195174}
percentSubmerged: 0

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 180195171}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -103.65, y: -1.2, z: -2.92}
m_LocalPosition: {x: -103.65, y: -0.27, z: -2.92}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

m_Script: {fileID: 11500000, guid: 0e9df21423548924dba40b7e4a5a611f, type: 3}
m_Name:
m_EditorClassIdentifier:
underWaterObj: {fileID: 668949992}
underWaterMesh: {fileID: 0}
boatRB: {fileID: 0}
rhoWater: 1027
--- !u!54 &668949994
Rigidbody:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 46130a80c554a8b45b8dfc36d16c9312, type: 3}
m_Name:
m_EditorClassIdentifier:
isMoving: 0
scale: 0.1
speed: 1
waveDistance: 1
noiseStrength: 1
noiseWalk: 1
--- !u!1 &674622423
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 1501079347}
- component: {fileID: 1501079346}
- component: {fileID: 1501079345}
- component: {fileID: 1501079344}
- component: {fileID: 1501079351}
m_Layer: 0
m_Name: Cube (1)
m_TagString: Untagged

m_Name:
m_EditorClassIdentifier:
ConversionMode: 0
--- !u!114 &1501079344
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1501079342}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ccea9ea98e38942e0b0938c27ed1903e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MotionType: 0
m_Mass: 640
m_LinearDamping: 0.1
m_AngularDamping: 0.05
m_InitialLinearVelocity:
x: 0
y: 0
z: 0
m_InitialAngularVelocity:
x: 0
y: 0
z: 0
m_GravityFactor: 1
m_OverrideDefaultMassDistribution: 0
m_CenterOfMass:
x: 0
y: 0
z: 0
m_Orientation:
Value:
x: 0
y: 0
z: 0
RotationOrder: 4
m_InertiaTensor:
x: 0.4
y: 0.4
z: 0.4
--- !u!114 &1501079345
MonoBehaviour:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
_buoyancyType: 3
density: 640
density: 5000
volume: 1
voxelResolution: 0.5
centerOfMass: {x: 0, y: 0, z: 0}

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1501079342}
m_Material: {fileID: 0}
m_Material: {fileID: 13400000, guid: bd4c82ff9a8164f5c96a49347c431b99, type: 2}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1501079342}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -103.65, y: -1.2, z: -2.92}
m_LocalPosition: {x: -103.65, y: -0.26999998, z: -2.92}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1240575473}

--- !u!114 &1501079351
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1501079342}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b275e5f92732148048d7b77e264ac30e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShapeType: 0
m_PrimitiveCenter:
x: 0
y: 0
z: 0
m_PrimitiveSize:
x: 1
y: 1
z: 1
m_PrimitiveOrientation:
Value:
x: -0
y: 0
z: 0
RotationOrder: 4
m_Capsule:
Height: 1
Radius: 0.5
Axis: 2
m_Cylinder:
Height: 1
Radius: 0.5
Axis: 2
m_SphereRadius: 0.5
m_ConvexRadius: 0.05
m_CustomMesh: {fileID: 0}
m_Material:
m_SupportsTemplate: 1
m_Template: {fileID: 11400000, guid: 15aa0e33a6fa41749b19f36537af1280, type: 2}
m_IsTrigger:
m_Override: 0
m_Value: 0
m_Friction:
m_Override: 0
m_Value:
Value: 0.5
CombineMode: 0
m_Restitution:
m_Override: 0
m_Value:
Value: 0
CombineMode: 2
m_BelongsTo:
m_Override: 0
m_Value: 0101010101010101010101010101010101010101010101010101010101010101
m_CollidesWith:
m_Override: 0
m_Value: 0101010101010101010101010101010101010101010101010101010101010101
m_RaisesCollisionEvents:
m_Override: 0
m_Value: 0
m_CustomFlags:
m_Override: 0
m_Value: 0000000000000000
--- !u!1001 &1512813203
PrefabInstance:
m_ObjectHideFlags: 0

- target: {fileID: 3344001027717145451, guid: 0a308b87c1579fb4c9ea256406209ca5,
type: 3}
propertyPath: PrimaryColor.r
value: 0.5145587
value: 0.63503486
value: 0.5145587
value: 0.38134143
value: 0.5145587
value: 0.063503504
value: 0.048544146
value: 0.36496514
value: 0.48544133
value: 0.21991628
value: 0.24879085
value: 0.038192913
objectReference: {fileID: 0}
- target: {fileID: 3344550060052829039, guid: 0a308b87c1579fb4c9ea256406209ca5,
type: 3}

objectReference: {fileID: 0}
- target: {fileID: 1531988076, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
propertyPath: m_OverrideDefaultMassDistribution
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1531988076, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
propertyPath: m_GravityFactor

propertyPath: m_InitialLinearVelocity.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1531988076, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
propertyPath: m_CenterOfMass.y
value: -0.35
objectReference: {fileID: 0}
- target: {fileID: 1531988076, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
propertyPath: m_CenterOfMass.z
value: -0.8
objectReference: {fileID: 0}
- target: {fileID: 1531988078, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
propertyPath: m_Material.m_Friction.m_Value.Value
value: 0

m_RemovedComponents:
- {fileID: 3393879954692751897, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
- {fileID: 3344550060052829039, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
- {fileID: 1531988078, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
- {fileID: 1531988076, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
--- !u!1001 &6543823577887040592
PrefabInstance:

22
Assets/Unity Physics Items/Physics Settings.prefab


- component: {fileID: 4018593011617785703}
- component: {fileID: 1925807081182823211}
- component: {fileID: 6001476266129338508}
- component: {fileID: 4712718218339362870}
m_Layer: 0
m_Name: Physics Settings
m_TagString: Untagged

m_Name:
m_EditorClassIdentifier:
ConversionMode: 0
--- !u!114 &4712718218339362870
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6698997538611213016}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb54ea4f67dc17342bcd49954c53502d, type: 3}
m_Name:
m_EditorClassIdentifier:
DrawColliders: 1
DrawColliderEdges: 0
DrawColliderAabbs: 0
DrawBroadphase: 0
DrawMassProperties: 1
DrawContacts: 0
DrawCollisionEvents: 0
DrawTriggerEvents: 0
DrawJoints: 0

3
Packages/com.verasl.water-system/Scripts/BuoyantObject.cs


_debug.waterHeight = waterLevel;
_debug.force = Vector3.zero;
Vector3 force = Vector3.zero;
Vector3 totalForce = Vector3.zero;
if (wp.y - voxelResolution < waterLevel)
{

_debug.force = force; // For drawing force gizmos
Debug.Log(string.Format("Position: {0:f1} -- Force: {1:f2} -- Height: {2:f2}\nVelocty: {3:f2} -- Damp: {4:f2} -- Mass: {5:f1} -- K: {6:f2}", wp, force, waterLevel, velocity, localDampingForce, RB.mass, localArchimedesForce));
}
Debug.Log("Total Force: " + totalForce);
}
private void UpdateDrag(float submergedAmount)

21
Assets/Unity Physics Items/PhysicsConversionSystem.cs


using Unity.Entities;
using UnityEngine;
using WaterSystem;
namespace Unity.Physics.Authoring
{
// IConvertGameObjectToEntity pipeline is called before the Physics Body & Shape Conversion Systems
// This means that there would be no Physics components created when Convert was called.
// Instead Convert is called from this specific ConversionSystem for any component that may need
// to read or write the various Physics components at conversion time.
[UpdateAfter(typeof(PhysicsBodyConversionSystem))]
[UpdateAfter(typeof(LegacyRigidbodyConversionSystem))]
public class PhysicsConversionSystem : GameObjectConversionSystem
{
// Update is called once per frame
protected override void OnUpdate()
{
Entities.ForEach((BuoyantObject2 behaviour) => { behaviour.Convert(GetPrimaryEntity(behaviour), DstEntityManager, this); });
}
}
}

11
Assets/Unity Physics Items/PhysicsConversionSystem.cs.meta


fileFormatVersion: 2
guid: 4237fdf5d806beb4388f07fdbdbafe70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存