Skip to content

Commit

Permalink
cohesion calc bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
komietty committed Apr 30, 2020
1 parent 77e9eca commit b36efee
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Assets/Boids/BoidsNativeArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void Execute(int id) {
avgPos += tgtPos;
}
}
accel[id] += (avgSpr * weights.x + avgVel * weights.y + avgPos * weights.z) / n;
accel[id] += avgSpr / n * weights.x + avgVel / n * weights.y + (avgPos / n - pos) * weights.z;
}
}

Expand Down Expand Up @@ -114,8 +114,8 @@ public void Execute() {
[SerializeField] protected GameObject prefab;
[SerializeField] protected Vector3 areaSize;
[SerializeField] protected float distThreshold;
[SerializeField] Vector2 velThreshold;
[SerializeField] Vector3 simWeight;
[SerializeField] protected Vector2 velThreshold;
[SerializeField] protected Vector3 simWeight;
protected Transform[] objs;
protected NativeArray<Vector3> pos, vel, acc;
protected TransformAccessArray trs;
Expand Down
7 changes: 4 additions & 3 deletions Assets/Boids/BoidsNativeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public void Execute(int id) {
avgPos += tgtPos;
}
}
accel[id] += (avgSpr * weights.x + avgVel * weights.y + avgPos * weights.z) / n;

accel[id] += avgSpr / n * weights.x + avgVel / n * weights.y + (avgPos / n - pos) * weights.z;
}
}

Expand Down Expand Up @@ -113,8 +114,8 @@ public void Execute() {
[SerializeField] protected GameObject prefab;
[SerializeField] protected Vector3 areaSize;
[SerializeField] protected float distThreshold;
[SerializeField] Vector2 velThreshold;
[SerializeField] Vector3 simWeight;
[SerializeField] protected Vector2 velThreshold;
[SerializeField] protected Vector3 simWeight;
[SerializeField] KeyCode add = KeyCode.A;
[SerializeField] KeyCode remove = KeyCode.R;
protected NativeList<Vector3> pos, vel, acc;
Expand Down
8 changes: 4 additions & 4 deletions Assets/Boids/Demo.unity
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ MonoBehaviour:
m_EditorClassIdentifier:
initNum: 10
prefab: {fileID: 4950830921021070585, guid: 81910fc2cc865994ba8a1da7c3b6a0f6, type: 3}
areaSize: {x: 20, y: 20, z: 20}
areaSize: {x: 25, y: 25, z: 25}
distThreshold: 5
velThreshold: {x: 0, y: 4}
simWeight: {x: 8, y: 6, z: 1}
simWeight: {x: 4, y: 0.8, z: 0.3}
add: 97
remove: 114
--- !u!4 &1361161912
Expand Down Expand Up @@ -400,7 +400,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
num: 3000
prefab: {fileID: 4950830921021070585, guid: 81910fc2cc865994ba8a1da7c3b6a0f6, type: 3}
areaSize: {x: 20, y: 20, z: 20}
areaSize: {x: 25, y: 25, z: 25}
distThreshold: 5
velThreshold: {x: 0, y: 4}
simWeight: {x: 8, y: 6, z: 1}
simWeight: {x: 4, y: 0.8, z: 0.3}
10 changes: 5 additions & 5 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"dependencies": {
"com.unity.burst": "1.1.2",
"com.unity.burst": "1.3.0-preview.10",
"com.unity.collab-proxy": "1.2.16",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.0",
"com.unity.ide.vscode": "1.1.3",
"com.unity.jobs": "0.2.1-preview.3",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.1.4",
"com.unity.jobs": "0.2.9-preview.15",
"com.unity.mathematics": "1.1.0",
"com.unity.test-framework": "1.1.3",
"com.unity.test-framework": "1.1.13",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.2.6",
"com.unity.ugui": "1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2019.3.0f1
m_EditorVersionWithRevision: 2019.3.0f1 (ffacea4b84e7)
m_EditorVersion: 2019.3.11f1
m_EditorVersionWithRevision: 2019.3.11f1 (ceef2d848e70)

0 comments on commit b36efee

Please sign in to comment.