-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Water simulation finally integrated in the data structure
- Loading branch information
Showing
21 changed files
with
1,231 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,73 @@ | ||
using UnityEngine; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
// using UnityEngine; | ||
// using System; | ||
// using System.Collections; | ||
// using System.Collections.Generic; | ||
|
||
namespace SimDataStructure.Data | ||
{ | ||
public class BufferGridData : AbstractGridData | ||
{ | ||
private int width; | ||
private int height; | ||
// namespace SimDataStructure.Data | ||
// { | ||
// public class BufferGridData : AbstractGridData | ||
// { | ||
// private int width; | ||
// private int height; | ||
|
||
private int contentSize; | ||
// private int contentSize; | ||
|
||
private ComputeBuffer computeBuffer; | ||
// private ComputeBuffer computeBuffer; | ||
|
||
public BufferGridData(int width, int height, int contentSize = sizeof(float) * 4) | ||
{ | ||
this.width = width; | ||
this.height = height; | ||
this.contentSize = contentSize; | ||
// public BufferGridData(int width, int height, int contentSize = sizeof(float) * 4) | ||
// { | ||
// this.width = width; | ||
// this.height = height; | ||
// this.contentSize = contentSize; | ||
|
||
this.computeBuffer = new ComputeBuffer(width * height, contentSize, ComputeBufferType.Default, ComputeBufferMode.Immutable); | ||
} | ||
// this.computeBuffer = new ComputeBuffer(width * height, contentSize, ComputeBufferType.Default, ComputeBufferMode.Immutable); | ||
// } | ||
|
||
// Return a copy of the buffer | ||
public ComputeBuffer GetData() | ||
{ | ||
ComputeBuffer copy = new ComputeBuffer(width * height, contentSize, ComputeBufferType.Default, ComputeBufferMode.Immutable); | ||
// // Return a copy of the buffer | ||
// public ComputeBuffer GetData() | ||
// { | ||
// ComputeBuffer copy = new ComputeBuffer(width * height, contentSize, ComputeBufferType.Default, ComputeBufferMode.Immutable); | ||
|
||
ComputeBuffer.CopyCount(this.computeBuffer, copy, 0); | ||
// ComputeBuffer.(this.computeBuffer, copy, 0); | ||
|
||
return copy; | ||
} | ||
// return copy; | ||
// } | ||
|
||
public void SetData(ComputeBuffer toSet) | ||
{ | ||
this.computeBuffer = toSet; | ||
} | ||
// // public void SetData(ComputeBuffer toSet) | ||
// // { | ||
// // this.computeBuffer = toSet; | ||
// // } | ||
|
||
public override void Release() | ||
{ | ||
if (this.computeBuffer != null) | ||
{ | ||
this.computeBuffer.Release(); | ||
this.computeBuffer = null; | ||
} | ||
} | ||
|
||
public int GetWidth() | ||
{ | ||
return this.width; | ||
} | ||
// public override AbstractGridData Clone() | ||
// { | ||
// BufferGridData clone = new BufferGridData(this.width, this.height, this.contentSize); | ||
|
||
// return new BufferGridData(this.width, this.height, this.contentSize); | ||
// } | ||
|
||
// public override void Release() | ||
// { | ||
// if (this.computeBuffer != null) | ||
// { | ||
// this.computeBuffer.Release(); | ||
// this.computeBuffer = null; | ||
// } | ||
// } | ||
|
||
// public int GetWidth() | ||
// { | ||
// return this.width; | ||
// } | ||
|
||
public int GetHeight() | ||
{ | ||
return this.height; | ||
} | ||
// public int GetHeight() | ||
// { | ||
// return this.height; | ||
// } | ||
|
||
public int GetContentSize() | ||
{ | ||
return this.contentSize; | ||
} | ||
} | ||
} | ||
// public int GetContentSize() | ||
// { | ||
// return this.contentSize; | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using SimDataStructure.Data; | ||
|
||
namespace SimDataStructure.Interfaces | ||
{ | ||
/** | ||
<summary> | ||
Initialize the data structure with data. | ||
This is called by the data structure when it is initialized. | ||
The implementing class should return a dictionary of data name to AbstractGridData objects. | ||
An implementing class should initialize only the data that it or its corresponding system will use. | ||
</summary> | ||
*/ | ||
public interface ISetupDataStructure | ||
{ | ||
/** | ||
<summary> | ||
Pass new data to the data structure for it to store. | ||
This is called by the data structure only once when it is initialized. | ||
The implementing class should return a dictionary of data name to AbstractGridData objects. | ||
An implementing class should initialize only the data that it or its corresponding system will use. | ||
</summary> | ||
*/ | ||
Dictionary<Tuple<string, int>, AbstractGridData> initializeData(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/DataStructure/Interfaces/ISetupDataStructure.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.