diff --git a/Assets/DataStructure/Data/AbstractGridData.cs b/Assets/DataStructure/Data/AbstractGridData.cs
index 5086005..55807e0 100644
--- a/Assets/DataStructure/Data/AbstractGridData.cs
+++ b/Assets/DataStructure/Data/AbstractGridData.cs
@@ -31,7 +31,7 @@ Copies the data from the given object to this AbstractGridData.
/**
- Dispose this data. (Dispose any buffers, textures, etc from memory)
+ Dispose this data. (Dispose of any buffers, textures, etc from memory)
This should ALWAYS be called before this object is destroyed or discarded. (Although, this should not be commonly used because you want to keep the same data object at runtime)
**/
diff --git a/Assets/TreeGrowth/Scripts/Generation/Node.cs b/Assets/TreeGrowth/Scripts/Generation/Node.cs
index a66b835..f8fb157 100644
--- a/Assets/TreeGrowth/Scripts/Generation/Node.cs
+++ b/Assets/TreeGrowth/Scripts/Generation/Node.cs
@@ -113,11 +113,11 @@ public IEnumerable GetTree()
}
/**
- Try to branch off of this branch. Only for if this branch already has any children.
+ Try to branch off of this branch. Only for if this branch already has children.
**/
public Node Branch()
{
- if (this.Children.Count() == 0) // If this branch already has any children
+ if (this.Children.Count() == 0) // If this branch doesn't already has any children then don't branch off of it
return null;
// The math for the falloff is as follows: (branch length falloff param ^ depth of this branch in the tree)
@@ -212,7 +212,7 @@ private Vector3 getGrowthDirection(Func vectorGenerator, float minDista
if (System.Single.IsPositiveInfinity(range)) // There is no obstacle in the way, so just return the growth direction
{
- Debug.DrawRay(this.Tree.transform.position + this.Position + growthDirection.normalized * 0.01f, growthDirection, Color.green, 10);
+ Debug.DrawRay(this.Tree.transform.position + this.Position + growthDirection * 0.01f, growthDirection, Color.green, 10);
return growthDirection;
}
@@ -222,11 +222,11 @@ private Vector3 getGrowthDirection(Func vectorGenerator, float minDista
result = growthDirection;
longestDistance = range;
- Debug.DrawRay(this.Tree.transform.position + this.Position + growthDirection.normalized * 0.01f, growthDirection, Color.yellow, 10);
+ Debug.DrawRay(this.Tree.transform.position + this.Position + growthDirection * 0.01f, growthDirection, Color.yellow, 10);
}
else
{
- Debug.DrawRay(this.Tree.transform.position + this.Position + growthDirection.normalized * 0.01f, growthDirection, Color.red, 10);
+ Debug.DrawRay(this.Tree.transform.position + this.Position + growthDirection * 0.01f, growthDirection, Color.red, 10);
}
}
@@ -248,6 +248,8 @@ public void RecalculateEnergy()
Cast a ray from a given position in a given direction
Returns the distance to the first object hit by the ray
+
+ ASSUMES THAT THE GIVEN DIRECTION IS ALREADY NORMALIZED
**/
private float raycast(Vector3 position, Vector3 direction, Color color, float skip = 0f, bool debug = false)
{
@@ -255,7 +257,7 @@ private float raycast(Vector3 position, Vector3 direction, Color color, float sk
// Create a ray from the calculated position(tree root position + the given position + the normalized given direction * the skip distance) with the given direction
// Skip is used to offset the origin a tiny bit, so that it doesn't hit this branch
- Ray ray = new Ray(this.Tree.transform.position + position + direction.normalized * skip, direction);
+ Ray ray = new Ray(this.Tree.transform.position + position + direction * skip, direction);
if (debug)
Debug.DrawRay(ray.origin, ray.direction, color, 10);
diff --git a/Assets/TreeGrowth/Scripts/Generation/TreeGenerator.cs b/Assets/TreeGrowth/Scripts/Generation/TreeGenerator.cs
index d31814c..e9b96e8 100644
--- a/Assets/TreeGrowth/Scripts/Generation/TreeGenerator.cs
+++ b/Assets/TreeGrowth/Scripts/Generation/TreeGenerator.cs
@@ -465,7 +465,7 @@ private List chooseRandomLeafNodes(int num)
public float CalculateWaterUseThisTick()
{
- recalculateEnergy();
+ // recalculateEnergy();
float waterUse = 0;
foreach (Node node in this.Root.GetTree())
@@ -491,18 +491,8 @@ private float nodeWaterUse(Node node)
public float CalculateWaterAbsorptionThisTick()
{
- float waterAbsorption = 0;
- foreach (Node node in this.Root.GetTree())
- {
- // If this is a stem node
- if (Mathf.Pow(map(1, this.Root.SubtreeSize, 1, 0, node.SubtreeSize), this.parameters.SizeFalloff) == 0)
- {
- float stemAbsorptionMult = 0.3f;
- waterAbsorption += stemAbsorptionMult * (getBranchRadius(node) + node.GetLength());
- }
- }
-
- return waterAbsorption;
+ float stemAbsorptionMult = 0.3f;
+ return stemAbsorptionMult * (getBranchRadius(this.Root) + this.Root.GetLength());
}
#endregion
diff --git a/Assets/WaterSimulation/Shaders/CompShader_Water.compute b/Assets/WaterSimulation/Shaders/CompShader_Water.compute
index a10aae1..93123e7 100644
--- a/Assets/WaterSimulation/Shaders/CompShader_Water.compute
+++ b/Assets/WaterSimulation/Shaders/CompShader_Water.compute
@@ -112,7 +112,9 @@ float gauss(float x, float radius)
// Surface evaporation
if (evaporationConstant > 0) {
- newSurfaceWater = max(newSurfaceWater - evaporationConstant, 0.0);
+ // Less water evaporates the more water there is
+ float evaporation = min(0.0, -2.4389 * pow(newSurfaceWater - 0.689655, 3))
+ newSurfaceWater = min(0.0, newSurfaceWater - evaporation * evaporationConstant);
}
@@ -134,10 +136,10 @@ float gauss(float x, float radius)
// Scale pos to external texture size
int2 externalPos = int2(pos * externalSize);
- float externalUnit = (size / externalSize); // basically how many soil cells there are in a single external cell
+ float externalUnit = pow(size / externalSize, 2); // basically how many soil cells there are in a single external cell
// Get how much water is being used in this cell
- float use = (soilUseMap[externalPos] * externalUnit) * soilUseMultiplier; // TODO: * (1 - soilData);
+ float use = (soilUseMap[externalPos] / externalUnit) * soilUseMultiplier; // TODO: * (1 - soilData);
// Make sure we don't use more water than there is in this cell
use = min(use, newSoilSaturation);