Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix demo for Unity 2019.3+ #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Demo/KnnVisualizationDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Experimental.ParticleSystemJobs;
using UnityEngine.ParticleSystemJobs;

// Ideally you really would use something like ECS to visualize the point cloud
// And query from a job component system
Expand Down Expand Up @@ -58,14 +58,14 @@ void OnDestroy() {
}

// [BurstCompile(CompileSynchronously = true)]
struct ParticleJob : IParticleSystemJob {
struct ParticleJob : IJobParticleSystem {
[ReadOnly] public NativeArray<int> KnnResults;
public NativeArray<float3> Points;

public NativeArray<Color32> Colors;
public int K;

public void ProcessParticleSystem(ParticleSystemJobData jobData) {
public void Execute(ParticleSystemJobData jobData) {
var colors = jobData.startColors;
var positions = jobData.positions;

Expand All @@ -85,13 +85,13 @@ public void ProcessParticleSystem(ParticleSystemJobData jobData) {
}
}

struct ParticleRangeJob : IParticleSystemJob {
struct ParticleRangeJob : IJobParticleSystem {
[ReadOnly] public NativeArray<RangeQueryResult> KnnResults;

public NativeArray<float3> Points;
public NativeArray<Color32> Colors;

public void ProcessParticleSystem(ParticleSystemJobData jobData) {
public void Execute(ParticleSystemJobData jobData) {
var partColors = jobData.startColors;
var partPos = jobData.positions;

Expand Down Expand Up @@ -119,20 +119,20 @@ public void ProcessParticleSystem(ParticleSystemJobData jobData) {
void Update() {
if (Mode == QueryMode.KNearest) {
// Update particles job to do the colors
m_system.SetJob(new ParticleJob {
new ParticleJob {
KnnResults = m_results,
Points = m_points,
K = QueryK,
Colors = m_queryColors
});
}.Schedule(m_system);
}
else {
// Update particles job to do the colors
m_system.SetJob(new ParticleRangeJob {
new ParticleRangeJob {
KnnResults = m_rangeResults,
Points = m_points,
Colors = m_queryColors
});
}.Schedule(m_system);
}
}

Expand Down