Verified Commit 9a4ed4d7 authored by Sebastian Höffner's avatar Sebastian Höffner
Browse files

Hacking our way around boundsMin issue. Why do we need this...? Needs further...

Hacking our way around boundsMin issue. Why do we need this...? Needs further investagation, but works for now.
parent 5c95c090
......@@ -5,12 +5,23 @@ using System.Linq;
namespace dlu
{
/**
* In WebGL, boundsMin and boundsMax were not initialized despite their initializations
* at their declaration site and despite an initialization in Awake.
* Thus, we simply declare and initialize them during GenerateOccupancyGrid now...
**/
public class OccupancyGrid : MonoBehaviour
{
public Vector3 boundsMin = new Vector3(-1.55f, -0.05f, -1.55f);
public Vector3 boundsMax = new Vector3(1.55f, 1.35f, 1.55f);
//public Vector3 boundsMin = new Vector3(-1.55f, -0.05f, -1.55f);
//public Vector3 boundsMax = new Vector3(1.55f, 1.35f, 1.55f);
public Vector3 resolution = new Vector3(0.05f, 0.05f, 0.05f);
void Awake() {
//boundsMin = new Vector3(-1.55f, -0.05f, -1.55f);
//boundsMax = new Vector3(1.55f, 1.35f, 1.55f);
resolution = new Vector3(0.05f, 0.05f, 0.05f);
}
private List<string>[,,] occupancy;
public List<string>[,,] GenerateOccupancyGrid() {
......@@ -19,9 +30,16 @@ public class OccupancyGrid : MonoBehaviour
public List<string>[,,] GenerateOccupancyGrid(HashSet<string> excluded)
{
// If all you have is a hammer...
Vector3 boundsMin = new Vector3(-1.55f, -0.05f, -1.55f); // NOTE HERE WE SET boundsMin !
Vector3 boundsMax = new Vector3(1.55f, 1.35f, 1.55f);
Debug.Log("[OccupancyGrid] GenerateOccupancyGrid");
Vector3 halfResolution = resolution * 0.5f;
Vector3 inverseResolution = new Vector3(1 / resolution.x, 1 / resolution.y, 1 / resolution.z);
Vector3 inverseResolution = new Vector3(1.0f / resolution.x, 1.0f / resolution.y, 1.0f / resolution.z);
Vector3 gridSizef = Vector3.Scale(boundsMax - boundsMin, inverseResolution);
Debug.Log($"[OccupancyGrid] bounds min {boundsMin} max {boundsMax}");
Debug.Log($"[OccupancyGrid] half resolution {halfResolution.x}");
Debug.Log($"[OccupancyGrid] gridsize float {gridSizef.x} x {gridSizef.y} x {gridSizef.z}");
Vector3Int gridSize = new Vector3Int((int) gridSizef.x, (int) gridSizef.y, (int) gridSizef.z);
List<GameObject> ignored = GameObject.FindObjectsOfType<InstanceIdentifier>()
......@@ -60,12 +78,18 @@ public class OccupancyGrid : MonoBehaviour
// Reset layers
ignored.ForEach(go => go.SetActive(true));
Debug.Log($"[OccupancyGrid] GenerateOccupancyGrid should: {gridSize.x}x{gridSize.y}x{gridSize.z}");
long mx = occupancy.GetLongLength(0);
long my = occupancy.GetLongLength(1);
long mz = occupancy.GetLongLength(2);
Debug.Log($"[OccupancyGrid] GenerateOccupancyGrid is: {mx}x{my}x{mz}");
return occupancy;
}
private Vector3 idx2coord(long ix, long iy, long iz, Vector3 resolution)
{
Vector3 boundsMin = new Vector3(-1.55f, -0.05f, -1.55f); // NOTE HERE WE SET boundsMin !
return boundsMin + new Vector3(ix * resolution.x, iy * resolution.y, iz * resolution.z) + resolution * 0.5f;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment