Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
komietty committed Dec 17, 2019
1 parent 576d0f7 commit 3fc7dd6
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 9 deletions.
14 changes: 6 additions & 8 deletions Assets/Boids/Boids.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Collections;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Jobs;
Expand Down Expand Up @@ -88,8 +86,8 @@ public void Execute(int id) {
}
}

[Unity.Burst.BurstCompile]
struct CountJob : IJob {
[BurstCompile]
struct UpdateBlck : IJob {
public NativeArray<Vector3> position;
public NativeArray<int> result;
int n => position.Length;
Expand Down Expand Up @@ -153,13 +151,13 @@ void Update() {
var jobWall = new UpdateWall { position = pos, accel = acc, scale = areaSize};
var jobSmlt = new UpdateSmlt { position = pos, velocity = vel, accel = acc, dstThreshold = distThreshold, weights = simWeight};
var jobMove = new UpdateMove { position = pos, velocity = vel, accel = acc, dt = Time.deltaTime, limit = velThreshold};
var jobCunt = new CountJob { position = pos, result = rst };
var jobBlck = new UpdateBlck { position = pos, result = rst };
var handlerWall = jobWall.Schedule(num, 0);
var handlerSmlt = jobSmlt.Schedule(num, 0, handlerWall);
var handlerMove = jobMove.Schedule(trs, handlerSmlt);
var handlerCunt = jobCunt.Schedule(handlerMove);
var handlerBlck = jobBlck.Schedule(handlerMove);

handlerCunt.Complete();
handlerBlck.Complete();
}

void OnDrawGizmos() {
Expand Down
76 changes: 75 additions & 1 deletion Assets/Boids/Demo.unity
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 896666455}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: -0.3838247, y: -2.0559778, z: -2.3785515}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
Expand Down Expand Up @@ -353,3 +353,77 @@ MonoBehaviour:
distThreshold: 5
velThreshold: {x: 0, y: 4}
simWeight: {x: 8, y: 6, z: 1}
--- !u!1 &1706854649
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1706854650}
m_Layer: 0
m_Name: Tests
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &1706854650
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1706854649}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2109220694}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2109220693
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2109220694}
- component: {fileID: 2109220695}
m_Layer: 0
m_Name: RemoveAtSwapBackTest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2109220694
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2109220693}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1706854650}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2109220695
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2109220693}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 49299c47bf9bcf54d9e7228aee3587fd, type: 3}
m_Name:
m_EditorClassIdentifier:
8 changes: 8 additions & 0 deletions Assets/Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Assets/Tests/RemoveAtSwapBackTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RemoveAtSwapBackTest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

}
}
11 changes: 11 additions & 0 deletions Assets/Tests/RemoveAtSwapBackTest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"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.mathematics": "1.1.0",
"com.unity.test-framework": "1.1.3",
"com.unity.textmeshpro": "2.0.1",
Expand Down

0 comments on commit 3fc7dd6

Please sign in to comment.