forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeshBBRenderSystem.cs
More file actions
35 lines (31 loc) · 1.88 KB
/
Copy pathMeshBBRenderSystem.cs
File metadata and controls
35 lines (31 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
[ExecuteAlways]
[UpdateInGroup(typeof(PresentationSystemGroup))]
public class MeshBBRenderSystem : ComponentSystem
{
protected override void OnUpdate()
{
Entities.ForEach((Entity e, ref MeshBBComponent dmc, ref Translation t) =>
{
var min = dmc.BlobData.Value.MinBoundingBox;
var max = dmc.BlobData.Value.MaxBoundingBox;
// Draw a bounding box
Debug.DrawLine(t.Value + new float3(min.x, min.y, min.z), t.Value + new float3(max.x, min.y, min.z));
Debug.DrawLine(t.Value + new float3(min.x, max.y, min.z), t.Value + new float3(max.x, max.y, min.z));
Debug.DrawLine(t.Value + new float3(min.x, min.y, min.z), t.Value + new float3(min.x, max.y, min.z));
Debug.DrawLine(t.Value + new float3(max.x, min.y, min.z), t.Value + new float3(max.x, max.y, min.z));
Debug.DrawLine(t.Value + new float3(min.x, min.y, max.z), t.Value + new float3(max.x, min.y, max.z));
Debug.DrawLine(t.Value + new float3(min.x, max.y, max.z), t.Value + new float3(max.x, max.y, max.z));
Debug.DrawLine(t.Value + new float3(min.x, min.y, max.z), t.Value + new float3(min.x, max.y, max.z));
Debug.DrawLine(t.Value + new float3(max.x, min.y, max.z), t.Value + new float3(max.x, max.y, max.z));
Debug.DrawLine(t.Value + new float3(min.x, min.y, min.z), t.Value + new float3(min.x, min.y, max.z));
Debug.DrawLine(t.Value + new float3(max.x, min.y, min.z), t.Value + new float3(max.x, min.y, max.z));
Debug.DrawLine(t.Value + new float3(min.x, max.y, min.z), t.Value + new float3(min.x, max.y, max.z));
Debug.DrawLine(t.Value + new float3(max.x, max.y, min.z), t.Value + new float3(max.x, max.y, max.z));
});
}
}