Skip to content

Commit

Permalink
started making the fluid Sim work more fluidly with the data structur…
Browse files Browse the repository at this point in the history
…e (pun not intended)
  • Loading branch information
AIP21 committed Apr 10, 2023
1 parent 80e7fc8 commit c6b0ad7
Show file tree
Hide file tree
Showing 58 changed files with 831 additions and 645 deletions.
8 changes: 8 additions & 0 deletions Assets/DataStructure/Data.meta

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

73 changes: 73 additions & 0 deletions Assets/DataStructure/Data/AbstractCellData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using UnityEngine;
using System;
using System.Collections.Generic;

namespace SimDataStructure
{
// Data for each cell (only inside cells)
[Serializable]
public abstract class AbstractCellData
{
public CellDataType type;

public AbstractCellData()
{
}

public CellDataType DataType()
{
return type;
}

public string DataTypeName()
{
return type.ToString();
}
}

// [CreateAssetMenu(menuName = "Data Structure/Cell Data")]
public class CellData<T> : AbstractCellData
{
public T data;

public CellData(T data) : base()
{
this.data = data;

if (typeof(T) == typeof(float))
{
type = CellDataType.Float;
}
else if (typeof(T) == typeof(int))
{
type = CellDataType.Int;
}
else if (typeof(T) == typeof(bool))
{
type = CellDataType.Bool;
}
else if (typeof(T) == typeof(Vector2))
{
type = CellDataType.Vector2;
}
else
{
type = CellDataType.Object;
}
}

public override string ToString()
{
return data.ToString();
}
}

public enum CellDataType
{
Float,
Int,
Bool,
Vector2,
Object
}
}
11 changes: 11 additions & 0 deletions Assets/DataStructure/Data/AbstractCellData.cs.meta

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

49 changes: 49 additions & 0 deletions Assets/DataStructure/Data/AbstractGridData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using UnityEngine;
using System;
using System.Collections.Generic;

namespace SimDataStructure
{
// Data for whole grid (one instance per grid)
// This class will contain a reference to a compute shader that will be a grid shader that computes some data for each cell
// This class will contain a method to update the shader
// This class will contain a method to access the data of the shader
// This class will contain a method to supply input data to the shader
[Serializable]
public abstract class AbstractGridData
{
public ComputeShader computeShader;

public GenericDictionary<string, ComputeBuffer> computeBuffers = new GenericDictionary<string, ComputeBuffer>();
public GenericDictionary<string, RenderTexture> renderTextures = new GenericDictionary<string, RenderTexture>();

// This class will contain a reference to a compute shader that will be a grid shader that computes some data for each cell
// This class will contain a method to update the shader
// This class will contain a method to access the data of the shader
// This class will contain a method to supply input data to the shader
public AbstractGridData()
{
}

public override void Init()
{
this.InitComputeShader();
this.CreateComputeBuffers();
this.CreateRenderTextures();
}

public override void Update()
{
this.UpdateShader();

}

public abstract void InitComputeShader();

public abstract void CreateRenderTextures();

public abstract void CreateComputeBuffers();

public abstract void UpdateShader(float deltaTime);
}
}
11 changes: 11 additions & 0 deletions Assets/DataStructure/Data/AbstractGridData.cs.meta

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

3 changes: 3 additions & 0 deletions Assets/DataStructure/Data/DataStructure.Data.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "DataStructure.Data"
}
7 changes: 7 additions & 0 deletions Assets/DataStructure/Data/DataStructure.Data.asmdef.meta

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

2 changes: 1 addition & 1 deletion Assets/DataStructure/Scripts.meta

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

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "DataStructure",
"rootNamespace": "",
"references": [
"GUID:eb87f480cb0892e49901d6dc0cd1bc61",
"GUID:06864d3e2acbf694e95993a7374ac1ec"
],
"includePlatforms": [],
Expand Down

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

Loading

0 comments on commit c6b0ad7

Please sign in to comment.