浏览代码

-Added floating for non-physical objects

/dots-physics
Mike Geig 5 年前
当前提交
0a7b6ed5
共有 10 个文件被更改,包括 699 次插入48 次删除
  1. 33
      Assets/Unity Physics Items/BuoyantObject_DOTS.cs
  2. 11
      Assets/Unity Physics Items/Components/BoatDataComponents.cs
  3. 86
      Assets/Unity Physics Items/Junk.unity
  4. 267
      Assets/Unity Physics Items/Physics Scene.unity
  5. 47
      Assets/Unity Physics Items/Systems/ApplyBuoyancyForceSystem.cs
  6. 7
      Assets/Unity Physics Items/Systems/GertsnerSystem.cs
  7. 13
      Assets/Scripts/Utility/PlatformFramerateLock.cs
  8. 11
      Assets/Scripts/Utility/PlatformFramerateLock.cs.meta
  9. 265
      Assets/Unity Physics Items/Prefabs/DOTS Buoy.prefab
  10. 7
      Assets/Unity Physics Items/Prefabs/DOTS Buoy.prefab.meta

33
Assets/Unity Physics Items/BuoyantObject_DOTS.cs


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

// Calculate all initial values
Init();
//Add data needed for buoyancy
BuoyantData data = new BuoyantData();
data.type = _buoyancyType;
data.voxelResolution = voxelResolution;
data.localArchimedesForce = localArchimedesForce;
data.baseDrag = baseDrag;
data.baseAngularDrag = baseAngularDrag;
dstManager.AddComponentData(entity, data);
dstManager.AddComponentData(entity, new BuoyancyNormal { Value = float3.zero });
//Add center of mass. This is why we had to use a custom conversion system since we needed the physics stuff to be converted before this step
var mass = dstManager.GetComponentData<Unity.Physics.PhysicsMass>(entity);
mass.CenterOfMass = centerOfMass;
dstManager.SetComponentData(entity, mass);
if (_buoyancyType == BuoyancyType.PhysicalVoxel)
{
//Add data needed for buoyancy
BuoyantData data = new BuoyantData();
data.voxelResolution = voxelResolution;
data.localArchimedesForce = localArchimedesForce;
data.baseDrag = baseDrag;
data.baseAngularDrag = baseAngularDrag;
dstManager.AddComponentData(entity, data);
//Add center of mass. This is why we had to use a custom conversion system since we needed the physics stuff to be converted before this step
var mass = dstManager.GetComponentData<Unity.Physics.PhysicsMass>(entity);
mass.CenterOfMass = centerOfMass;
dstManager.SetComponentData(entity, mass);
}
else if (_buoyancyType == BuoyancyType.NonPhysical)
{
dstManager.AddComponent(entity, typeof(SimpleBuoyantTag));
}
dstManager.AddBuffer<VoxelOffset>(entity);
dstManager.AddBuffer<VoxelHeight>(entity);

11
Assets/Unity Physics Items/Components/BoatDataComponents.cs


using Unity.Entities;
using Unity.Mathematics;
using static WaterSystem.BuoyantObject_DOTS;
public BuoyancyType type;
public float voxelResolution;
public float3 normal;
public float3 localArchimedesForce;

public bool isHuman;
public float throttle;
public float steering;
}
}
public struct BuoyancyNormal : IComponentData
{
public float3 Value;
}
public struct SimpleBuoyantTag : IComponentData { }

86
Assets/Unity Physics Items/Junk.unity


m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &280541644
PrefabInstance:

- target: {fileID: 4534517681006197974, guid: bd1a31d6e589d4df7bf401593b7f735a,
type: 3}
propertyPath: m_RootOrder
value: 1
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4534517681006197974, guid: bd1a31d6e589d4df7bf401593b7f735a,
type: 3}

objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 074aa8ca109924e18baf19f3e26665b6, type: 3}
propertyPath: m_LocalPosition.x
value: -100
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 074aa8ca109924e18baf19f3e26665b6, type: 3}
propertyPath: m_LocalPosition.y

settingsData: {fileID: 11400000, guid: a4cacf74654e54b35b9eaea74fd20b4e, type: 2}
surfaceData: {fileID: 11400000, guid: 846f3dc3b5341447a86687211f741bc7, type: 2}
resources: {fileID: 11400000, guid: 40615c805d6e84ce7800418367985fe1, type: 2}
--- !u!1001 &899018702
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2710428803363308588, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_Name
value: DOTS Buoy
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalPosition.x
value: -107.68
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.25
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalPosition.z
value: -4.81
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 487c4de658279d44e8cfff92b4324a0c, type: 3}
--- !u!1 &1017609894
GameObject:
m_ObjectHideFlags: 0

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 14.175001, y: -109.632, z: 3.23}
--- !u!114 &1017609902
MonoBehaviour:

m_Children:
- {fileID: 1240575473}
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1512813203
PrefabInstance:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2099110228309645296
MonoBehaviour:

vel: {x: 0, y: 0, z: 0}
engineSound: {fileID: 0}
waterSound: {fileID: 0}
torque: 5
steeringTorque: 5
upwardTorque: 5
horsePower: 18
enginePosition: {x: 0, y: 0.05, z: -3.31}
--- !u!114 &4646665471474128063

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &8034832314272628942
MeshFilter:

267
Assets/Unity Physics Items/Physics Scene.unity


m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &198446338
GameObject:

- target: {fileID: 4534517681006197974, guid: bd1a31d6e589d4df7bf401593b7f735a,
type: 3}
propertyPath: m_RootOrder
value: 6
value: 7
objectReference: {fileID: 0}
- target: {fileID: 4534517681006197974, guid: bd1a31d6e589d4df7bf401593b7f735a,
type: 3}

m_LocalScale: {x: 8, y: 0.73, z: 8}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &668949999
MonoBehaviour:

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1017609894}
m_LocalRotation: {x: 0.09853761, y: -0.0000000030377252, z: -0.000000012128565,
w: 0.9951334}
m_LocalRotation: {x: 0.09853762, y: 0.0000000055235976, z: -0.000000012976303, w: 0.9951334}
m_LocalPosition: {x: -104.12, y: 1.6110001, z: -8.78}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []

m_Children:
- {fileID: 1240575473}
m_Father: {fileID: 0}
m_RootOrder: 10
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1512813203
PrefabInstance:

objectReference: {fileID: 0}
- target: {fileID: 4534809148113994, guid: fc3ffb83d6eafb1489a5b23bc82d25b6, type: 3}
propertyPath: m_RootOrder
value: 12
value: 13
objectReference: {fileID: 0}
- target: {fileID: 4534809148113994, guid: fc3ffb83d6eafb1489a5b23bc82d25b6, type: 3}
propertyPath: m_LocalEulerAnglesHint.x

m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1723776892 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 6590196160529741170, guid: e70416e3bc35d4004a9981d0ac102ba5,
type: 3}
m_PrefabInstance: {fileID: 6589000189408555943}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1723776894
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1723776892}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0fe52c158d195e64a99e4eaa38bb3df7, type: 3}
m_Name:
m_EditorClassIdentifier:
_buoyancyType: 0
density: 0
volume: 0
voxelResolution: 0.51
centerOfMass: {x: 0, y: 0, z: 0}
voxels:
- {x: 0, y: 0, z: 0}
colliders: []
percentSubmerged: 0
--- !u!114 &1723776895
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1723776892}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea7d7495833204790ba1d3a8755397f8, type: 3}
m_Name:
m_EditorClassIdentifier:
ConversionMode: 0
--- !u!114 &1723776897
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1723776892}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b275e5f92732148048d7b77e264ac30e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShapeType: 1
m_PrimitiveCenter:
x: -0.000000059604645
y: -0.525918
z: 0.030020773
m_PrimitiveSize:
x: 1.2003503
y: 1.2003503
z: 1.7400162
m_PrimitiveOrientation:
Value:
x: 270
y: 270
z: 0
RotationOrder: 4
m_Capsule:
Height: 1.7400162
Radius: 0.60017514
Axis: 2
m_Cylinder:
Height: 1.7400162
Radius: 0.60017514
Axis: 2
m_SphereRadius: 0.8700081
m_ConvexRadius: 0.05
m_CustomMesh: {fileID: 0}
m_Material:
m_SupportsTemplate: 1
m_Template: {fileID: 0}
m_IsTrigger:
m_Override: 0
m_Value: 0
m_Friction:
m_Override: 0
m_Value:
Value: 0
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_CustomTags:
m_Override: 0
m_Value: 0000000000000000
--- !u!33 &1723776898
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1723776892}
m_Mesh: {fileID: 4300016, guid: 92a669df93f0d4f99bd8fa27767e8c9e, type: 3}
--- !u!23 &1723776899
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1723776892}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 3
m_RayTracingMode: 2
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: b1aaf92c06be94931a4e515a4812f42e, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!1 &1762887464
GameObject:
m_ObjectHideFlags: 3

- target: {fileID: 1790745783105967003, guid: baaa45186293644edb4da9d1f4b1fa80,
type: 3}
propertyPath: m_RootOrder
value: 5
value: 6
objectReference: {fileID: 0}
- target: {fileID: 1790745783105967003, guid: baaa45186293644edb4da9d1f4b1fa80,
type: 3}

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1819032313
MonoBehaviour:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1923446570 stripped
Transform:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2061336191
GameObject:

m_Name:
m_EditorClassIdentifier:
nearDistanceSquared: 8
--- !u!1001 &3824473870233525929
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2710428803363308588, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_Name
value: DOTS Buoy
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalPosition.x
value: -99.4
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.686
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalPosition.z
value: 1.6
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2708360549199760384, guid: 487c4de658279d44e8cfff92b4324a0c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 487c4de658279d44e8cfff92b4324a0c, type: 3}
--- !u!1001 &4646665472427269332
PrefabInstance:
m_ObjectHideFlags: 0

- target: {fileID: 3457973740146875417, guid: 0a308b87c1579fb4c9ea256406209ca5,
type: 3}
propertyPath: m_RootOrder
value: 13
value: 14
objectReference: {fileID: 0}
- target: {fileID: 3457973740146875417, guid: 0a308b87c1579fb4c9ea256406209ca5,
type: 3}

- target: {fileID: 558137786967539335, guid: 0a308b87c1579fb4c9ea256406209ca5,
type: 3}
propertyPath: m_LocalRotation.x
value: 0.09853761
value: 0.09853762
value: -0.0000000030377252
value: 0.0000000055235976
value: -0.000000012128565
value: -0.000000012976303
objectReference: {fileID: 0}
- target: {fileID: 3456711171255019043, guid: 0a308b87c1579fb4c9ea256406209ca5,
type: 3}

m_RemovedComponents: []
m_RemovedComponents:
- {fileID: 1507960575, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 0a308b87c1579fb4c9ea256406209ca5, type: 3}
--- !u!1001 &6543823577887040592
PrefabInstance:

- target: {fileID: 4018593011617785703, guid: ebb958ca9e119be438b62f3cce1981fc,
type: 3}
propertyPath: m_RootOrder
value: 8
value: 9
objectReference: {fileID: 0}
- target: {fileID: 4018593011617785703, guid: ebb958ca9e119be438b62f3cce1981fc,
type: 3}

type: 3}
propertyPath: ConversionMode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4712718218339362870, guid: ebb958ca9e119be438b62f3cce1981fc,
type: 3}
propertyPath: DrawColliders
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ebb958ca9e119be438b62f3cce1981fc, type: 3}

propertyPath: m_LocalRotation.w
value: 0.68427867
objectReference: {fileID: 0}
- target: {fileID: 6590196160529741170, guid: e70416e3bc35d4004a9981d0ac102ba5,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- {fileID: 6550393896821515750, guid: e70416e3bc35d4004a9981d0ac102ba5, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: e70416e3bc35d4004a9981d0ac102ba5, type: 3}

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


protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var job = new ForceJob()
var offsets = GetBufferFromEntity<VoxelOffset>(false);
var heights = GetBufferFromEntity<VoxelHeight>(false);
var forceJob = new ForceJob()
offsetBuffer = GetBufferFromEntity<VoxelOffset>(false),
heightBuffer = GetBufferFromEntity<VoxelHeight>(false)
offsetBuffer = offsets,
heightBuffer = heights
return job.Schedule(this, inputDeps);
var forceJobHandle = forceJob.Schedule(this, inputDeps);
var simpleJob = new SimpleForceJob()
{
dt = Time.fixedDeltaTime,
heightBuffer = heights
};
return simpleJob.Schedule(this, forceJobHandle);
}
//[BurstCompile]

//data.percentSubmerged = Mathf.Lerp(data.percentSubmerged, submergedAmount, 0.25f);
//damping.Linear = data.baseDrag + (data.baseDrag * (data.percentSubmerged * 10f));
//damping.Angular = data.baseAngularDrag + (data.percentSubmerged * 0.5f);
}
}
[BurstCompile]
[RequireComponentTag(typeof(SimpleBuoyantTag))]
public struct SimpleForceJob : IJobForEachWithEntity<Translation, Rotation, BuoyancyNormal>
{
public float dt;
[ReadOnly]
public BufferFromEntity<VoxelHeight> heightBuffer;
public void Execute(Entity entity, int index, [ReadOnly] ref Translation pos, [ReadOnly] ref Rotation rot, [ReadOnly] ref BuoyancyNormal normal)
{
DynamicBuffer<VoxelHeight> heights = heightBuffer[entity];
var entityTransform = new RigidTransform(rot.Value, pos.Value);
pos.Value.y = heights[0].Value.y;
//var position = pos.Value;
//position.y = heights[0].Value.y;
//pos.Value = position;
rot.Value = quaternion.LookRotation(math.forward(rot.Value), normal.Value);
//transform.up = Vector3.Slerp(transform.up, normals[0], Time.deltaTime);
}
}
}

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


}
[BurstCompile]
public struct HeightJob : IJobForEachWithEntity<Translation, Rotation, BuoyantData>
public struct HeightJob : IJobForEachWithEntity<Translation, Rotation, BuoyancyNormal>
{
[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 Rotation rot, ref BuoyantData data)
public void Execute(Entity entity, int i, [ReadOnly] ref Translation translation, ref Rotation rot, ref BuoyancyNormal normal)
{
DynamicBuffer<VoxelOffset> offsets = offsetBuffer[entity];
DynamicBuffer<VoxelHeight> heights = heightBuffer[entity];

}
heights[vi] = new VoxelHeight{Value = wavePos};
data.normal = math.normalize(waveNorm.xzy);
normal.Value = math.normalize(waveNorm.xzy);
}
}
}

13
Assets/Scripts/Utility/PlatformFramerateLock.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlatformFramerateLock : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
//Basic for now. Replace with the platform logic
Application.targetFrameRate = (int)(1f / Time.fixedDeltaTime);
}
}

11
Assets/Scripts/Utility/PlatformFramerateLock.cs.meta


fileFormatVersion: 2
guid: 5ae29956cf8054547aefea0657115f31
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

265
Assets/Unity Physics Items/Prefabs/DOTS Buoy.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2710428803363308588
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2708360549199760384}
- component: {fileID: 2710428803363308577}
- component: {fileID: 2710428803363308590}
- component: {fileID: 2710428803363308591}
- component: {fileID: 2710428803363308576}
m_Layer: 0
m_Name: DOTS Buoy
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2708360549199760384
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2710428803363308588}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -99.4, y: 0.686, z: 1.6}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 3824473869457911851}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2710428803363308577
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2710428803363308588}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0fe52c158d195e64a99e4eaa38bb3df7, type: 3}
m_Name:
m_EditorClassIdentifier:
_buoyancyType: 0
density: 0
volume: 0
voxelResolution: 0.51
centerOfMass: {x: 0, y: 0, z: 0}
voxels:
- {x: 0, y: 0, z: 0}
colliders: []
percentSubmerged: 0
--- !u!114 &2710428803363308590
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2710428803363308588}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea7d7495833204790ba1d3a8755397f8, type: 3}
m_Name:
m_EditorClassIdentifier:
ConversionMode: 0
--- !u!114 &2710428803363308591
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2710428803363308588}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b275e5f92732148048d7b77e264ac30e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShapeType: 1
m_PrimitiveCenter:
x: -0.000000059604645
y: -0.525918
z: 0.030020773
m_PrimitiveSize:
x: 1.2003503
y: 1.2003503
z: 1.7400162
m_PrimitiveOrientation:
Value:
x: 270
y: 270
z: 0
RotationOrder: 4
m_Capsule:
Height: 1.7400162
Radius: 0.60017514
Axis: 2
m_Cylinder:
Height: 1.7400162
Radius: 0.60017514
Axis: 2
m_SphereRadius: 0.8700081
m_ConvexRadius: 0.05
m_CustomMesh: {fileID: 0}
m_Material:
m_SupportsTemplate: 1
m_Template: {fileID: 0}
m_IsTrigger:
m_Override: 0
m_Value: 0
m_Friction:
m_Override: 0
m_Value:
Value: 0
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_CustomTags:
m_Override: 0
m_Value: 0000000000000000
--- !u!114 &2710428803363308576
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2710428803363308588}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ccea9ea98e38942e0b0938c27ed1903e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MotionType: 1
m_Mass: 1
m_LinearDamping: 0.01
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
m_CustomTags:
Tag00: 0
Tag01: 0
Tag02: 0
Tag03: 0
Tag04: 0
Tag05: 0
Tag06: 0
Tag07: 0
--- !u!1 &3824473869457911848
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3824473869457911851}
- component: {fileID: 3824473869457911853}
- component: {fileID: 3824473869457911850}
m_Layer: 0
m_Name: BuoyMesh
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3824473869457911851
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3824473869457911848}
m_LocalRotation: {x: 1, y: 0, z: 0, w: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2708360549199760384}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 180, y: 0, z: 0}
--- !u!33 &3824473869457911853
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3824473869457911848}
m_Mesh: {fileID: 4300016, guid: 92a669df93f0d4f99bd8fa27767e8c9e, type: 3}
--- !u!23 &3824473869457911850
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3824473869457911848}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: b1aaf92c06be94931a4e515a4812f42e, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0

7
Assets/Unity Physics Items/Prefabs/DOTS Buoy.prefab.meta


fileFormatVersion: 2
guid: 487c4de658279d44e8cfff92b4324a0c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存