com.warwlock.mtree 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm.yml +19 -0
- package/CHANGELOG.md +17 -0
- package/CHANGELOG.md.meta +7 -0
- package/Documentation~/Documentation.md +3 -0
- package/Editor/BranchEditor.cs +545 -0
- package/Editor/BranchEditor.cs.meta +16 -0
- package/Editor/EditorCallbacks.cs +69 -0
- package/Editor/EditorCallbacks.cs.meta +11 -0
- package/Editor/MTree.Editor.asmdef +18 -0
- package/Editor/MTree.Editor.asmdef.meta +7 -0
- package/Editor/MenuItem.cs +31 -0
- package/Editor/MenuItem.cs.meta +11 -0
- package/Editor/MtreeBezierInspector.cs +161 -0
- package/Editor/MtreeBezierInspector.cs.meta +11 -0
- package/Editor/MtreeEditor.cs +434 -0
- package/Editor/MtreeEditor.cs.meta +11 -0
- package/Editor/TemplateInspector.cs +66 -0
- package/Editor/TemplateInspector.cs.meta +12 -0
- package/Editor/ValuesEditor.cs +18 -0
- package/Editor/ValuesEditor.cs.meta +11 -0
- package/Editor/VertexColorAdjustmentEditor.cs +169 -0
- package/Editor/VertexColorAdjustmentEditor.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE +21 -0
- package/LICENSE.meta +7 -0
- package/README.md +68 -0
- package/README.md.meta +7 -0
- package/Resources/Mtree/MtreeBillboardCamera.prefab +204 -0
- package/Resources/Mtree/MtreeBillboardCamera.prefab.meta +8 -0
- package/Resources/Mtree/Sprites/DeleteCrossSprite.png +0 -0
- package/Resources/Mtree/Sprites/DeleteCrossSprite.png.meta +116 -0
- package/Resources/Mtree/Sprites/TreeFunctionSprite.png +0 -0
- package/Resources/Mtree/Sprites/TreeFunctionSprite.png.meta +116 -0
- package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd +0 -0
- package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd.meta +116 -0
- package/Resources/Mtree/Sprites.meta +8 -0
- package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab +104 -0
- package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab.meta +7 -0
- package/Resources/Mtree/Vertex Color Editor.meta +8 -0
- package/Resources/Mtree/branches.fbx +0 -0
- package/Resources/Mtree/branches.fbx.meta +137 -0
- package/Resources/Mtree.meta +8 -0
- package/Resources.meta +8 -0
- package/Runtime/AO/DensityAO.cs +203 -0
- package/Runtime/AO/DensityAO.cs.meta +11 -0
- package/Runtime/AO/KDTree.cs +169 -0
- package/Runtime/AO/KDTree.cs.meta +11 -0
- package/Runtime/AO/WeightedRandom.cs +74 -0
- package/Runtime/AO/WeightedRandom.cs.meta +11 -0
- package/Runtime/AO.meta +8 -0
- package/Runtime/Bezier/Bezier.cs +69 -0
- package/Runtime/Bezier/Bezier.cs.meta +11 -0
- package/Runtime/Bezier/MtreeBezier.cs +185 -0
- package/Runtime/Bezier/MtreeBezier.cs.meta +11 -0
- package/Runtime/Bezier.meta +8 -0
- package/Runtime/ExampleSceneManager.cs +165 -0
- package/Runtime/ExampleSceneManager.cs.meta +11 -0
- package/Runtime/LODValues.cs +44 -0
- package/Runtime/LODValues.cs.meta +11 -0
- package/Runtime/LeafPoint.cs +135 -0
- package/Runtime/LeafPoint.cs.meta +11 -0
- package/Runtime/MTree.Runtime.asmdef +3 -0
- package/Runtime/MTree.Runtime.asmdef.meta +7 -0
- package/Runtime/MTree.cs +569 -0
- package/Runtime/MTree.cs.meta +11 -0
- package/Runtime/MtreeComponent.cs +482 -0
- package/Runtime/MtreeComponent.cs.meta +11 -0
- package/Runtime/MtreeVariables.cs +11 -0
- package/Runtime/MtreeVariables.cs.meta +11 -0
- package/Runtime/MtreeWind.cs +94 -0
- package/Runtime/MtreeWind.cs.meta +11 -0
- package/Runtime/Node.cs +331 -0
- package/Runtime/Node.cs.meta +11 -0
- package/Runtime/SimplexNoise.cs +166 -0
- package/Runtime/SimplexNoise.cs.meta +11 -0
- package/Runtime/Splines.cs +379 -0
- package/Runtime/Splines.cs.meta +11 -0
- package/Runtime/TreeBilboard.cs +290 -0
- package/Runtime/TreeBilboard.cs.meta +11 -0
- package/Runtime/TreeFunctions/BranchFunction.cs +92 -0
- package/Runtime/TreeFunctions/BranchFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/GrowFunction.cs +81 -0
- package/Runtime/TreeFunctions/GrowFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/LeafFunction.cs +111 -0
- package/Runtime/TreeFunctions/LeafFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/RootsFunction.cs +77 -0
- package/Runtime/TreeFunctions/RootsFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/SplitFunction.cs +50 -0
- package/Runtime/TreeFunctions/SplitFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/TreeFunctionAsset.cs +105 -0
- package/Runtime/TreeFunctions/TreeFunctionAsset.cs.meta +11 -0
- package/Runtime/TreeFunctions/TrunkFunction.cs +88 -0
- package/Runtime/TreeFunctions/TrunkFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions.meta +8 -0
- package/Runtime/TreePoint.cs +27 -0
- package/Runtime/TreePoint.cs.meta +11 -0
- package/Runtime/TreeTemplate.cs +50 -0
- package/Runtime/TreeTemplate.cs.meta +12 -0
- package/Runtime/Utils.cs +268 -0
- package/Runtime/Utils.cs.meta +11 -0
- package/Runtime/VSProIntegration.cs +132 -0
- package/Runtime/VSProIntegration.cs.meta +11 -0
- package/Runtime.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Birch.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Birch.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Bush.asset +385 -0
- package/Samples~/ExampleTemplates/Examples/Bush.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset +482 -0
- package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/FantasyTree.asset +406 -0
- package/Samples~/ExampleTemplates/Examples/FantasyTree.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Fern.asset +291 -0
- package/Samples~/ExampleTemplates/Examples/Fern.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/High Poly.asset +300 -0
- package/Samples~/ExampleTemplates/Examples/High Poly.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/LightingData.asset +0 -0
- package/Samples~/ExampleTemplates/Examples/LightingData.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat +196 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat +196 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat +181 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat +201 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat +208 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat +180 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat +206 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat +206 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat +172 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat +392 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat +202 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat +265 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat +267 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat +232 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat +250 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat +247 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat +223 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat +262 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat +281 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat +267 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat +236 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Oak.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Oak.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Old Oak.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Old Oak.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Palm.asset +500 -0
- package/Samples~/ExampleTemplates/Examples/Palm.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Pine 2.asset +387 -0
- package/Samples~/ExampleTemplates/Examples/Pine 2.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Pine.asset +405 -0
- package/Samples~/ExampleTemplates/Examples/Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset +478 -0
- package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Poplar.asset +309 -0
- package/Samples~/ExampleTemplates/Examples/Poplar.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr +0 -0
- package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr.meta +117 -0
- package/Samples~/ExampleTemplates/Examples/Small Pine.asset +273 -0
- package/Samples~/ExampleTemplates/Examples/Small Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Small Tree.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Small Tree.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd.meta +76 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png.meta +76 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Willow.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Willow.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples.meta +8 -0
- package/Samples~/ExampleTemplates/Examples.unity +12660 -0
- package/Samples~/ExampleTemplates/Examples.unity.meta +7 -0
- package/Samples~/ExampleTemplates.meta +8 -0
- package/Shaders/BarkShader.shadergraph +17215 -0
- package/Shaders/BarkShader.shadergraph.meta +10 -0
- package/Shaders/Editor/BarkEditor.cs +100 -0
- package/Shaders/Editor/BarkEditor.cs.meta +11 -0
- package/Shaders/Editor/LeafEditor.cs +173 -0
- package/Shaders/Editor/LeafEditor.cs.meta +11 -0
- package/Shaders/Editor.meta +8 -0
- package/Shaders/LeafShader.shadergraph +34803 -0
- package/Shaders/LeafShader.shadergraph.meta +10 -0
- package/Shaders/MTree.Shaders.asmdef +3 -0
- package/Shaders/MTree.Shaders.asmdef.meta +7 -0
- package/Shaders/leafFunctions.hlsl +201 -0
- package/Shaders/leafFunctions.hlsl.meta +7 -0
- package/Shaders/vertexFunc.hlsl +55 -0
- package/Shaders/vertexFunc.hlsl.meta +7 -0
- package/Shaders.meta +8 -0
- package/package.json +36 -0
- package/package.json.meta +7 -0
package/Runtime/Node.cs
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Mtree
|
|
6
|
+
{
|
|
7
|
+
|
|
8
|
+
public class Node
|
|
9
|
+
{
|
|
10
|
+
public List<Node> children;
|
|
11
|
+
public Vector3 position;
|
|
12
|
+
public Vector3 direction;
|
|
13
|
+
public float radius;
|
|
14
|
+
public int creator;
|
|
15
|
+
public float distanceFromOrigin; // total branch distance from the root to the Node
|
|
16
|
+
public NodeType type; // Used to displace the tree after Growth
|
|
17
|
+
public GrowthInformation growth;
|
|
18
|
+
public float positionInBranch; // relative position (0 to 1) of node in branch.
|
|
19
|
+
public float branchVariation;
|
|
20
|
+
|
|
21
|
+
public Node(Vector3 pos, float rad, Vector3 dir, int crea, NodeType type = NodeType.Branch, float distancToOrigin=0, float positionInBranch=0)
|
|
22
|
+
{
|
|
23
|
+
position = pos;
|
|
24
|
+
radius = rad;
|
|
25
|
+
direction = dir;
|
|
26
|
+
children = new List<Node>();
|
|
27
|
+
creator = crea;
|
|
28
|
+
growth = new GrowthInformation(0, 0, 1);
|
|
29
|
+
this.type = type;
|
|
30
|
+
this.distanceFromOrigin = distancToOrigin;
|
|
31
|
+
this.positionInBranch = positionInBranch;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public Queue<Node> Grow(float length, float splitProba, int maxNumber, float rad, float secondaryBranchRadius, float angle
|
|
35
|
+
, int creator, float randomness, float upAttraction, Transform treeTransform, float gravityStrength, float flatten, bool obstacleAvoidance = false, Queue<System.Func<Vector3, Node, Vector3>> modifiers = null)
|
|
36
|
+
{
|
|
37
|
+
int number = (int) (splitProba / Random.value) + 1; // The number of branches that will be generated
|
|
38
|
+
if (number > maxNumber)
|
|
39
|
+
number = maxNumber;
|
|
40
|
+
if (!growth.canBeSplit)
|
|
41
|
+
number = 1;
|
|
42
|
+
|
|
43
|
+
Queue<Node> extremities = new Queue<Node>();
|
|
44
|
+
bool outOfLength = growth.remainingGrowth < length; // Is the growth ending
|
|
45
|
+
if (outOfLength)
|
|
46
|
+
length = growth.remainingGrowth;
|
|
47
|
+
|
|
48
|
+
Vector3 mainBranchTangent = Vector3.zero; // when there are only two splits, the two splits repulse each other
|
|
49
|
+
|
|
50
|
+
for (int i=0; i<number; i++)
|
|
51
|
+
{
|
|
52
|
+
Vector3 randomVect = Random.onUnitSphere;
|
|
53
|
+
if (flatten >= 0 && number > 1)
|
|
54
|
+
randomVect = Vector3.Lerp(randomVect, Vector3.up * (Random.Range(-1, 1)), flatten);
|
|
55
|
+
Vector3 tangent = Vector3.Cross(randomVect, direction);
|
|
56
|
+
if (number == 2)
|
|
57
|
+
{
|
|
58
|
+
if (i == 0)
|
|
59
|
+
mainBranchTangent = tangent;
|
|
60
|
+
if (i == 1)
|
|
61
|
+
tangent = -mainBranchTangent;
|
|
62
|
+
|
|
63
|
+
randomness = secondaryBranchRadius * angle;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (tangent.y < 0)
|
|
67
|
+
{
|
|
68
|
+
tangent.y -= tangent.y * upAttraction;
|
|
69
|
+
}
|
|
70
|
+
Vector3 gravityForce = Vector3.down * gravityStrength * .1f * length;
|
|
71
|
+
if (i == 0)
|
|
72
|
+
{
|
|
73
|
+
Vector3 dir = Vector3.Lerp(direction, tangent, randomness).normalized;
|
|
74
|
+
if (obstacleAvoidance && ObstacleAvoidance(ref dir, position, treeTransform, 10))
|
|
75
|
+
continue;
|
|
76
|
+
dir += gravityForce;
|
|
77
|
+
|
|
78
|
+
if (modifiers != null)
|
|
79
|
+
{
|
|
80
|
+
foreach (var modifier in modifiers)
|
|
81
|
+
{
|
|
82
|
+
dir = modifier(dir, this);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (gravityStrength != 0 || modifiers != null)
|
|
87
|
+
dir.Normalize();
|
|
88
|
+
Vector3 pos = position + dir * length;
|
|
89
|
+
Node child = new Node(pos, rad, dir, creator, distancToOrigin: distanceFromOrigin+(length/(.1f + radius)));
|
|
90
|
+
child.growth = new GrowthInformation(growth.growthGoal, growth.remainingGrowth - length, growth.initialRadius);
|
|
91
|
+
if(!outOfLength)
|
|
92
|
+
extremities.Enqueue(child);
|
|
93
|
+
children.Add(child);
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
{
|
|
97
|
+
Vector3 dir = (direction * (1 - angle) + tangent * (angle)).normalized;
|
|
98
|
+
if (ObstacleAvoidance(ref dir, position, treeTransform, 10))
|
|
99
|
+
continue;
|
|
100
|
+
dir += gravityForce;
|
|
101
|
+
if (modifiers != null)
|
|
102
|
+
{
|
|
103
|
+
foreach (var modifier in modifiers)
|
|
104
|
+
{
|
|
105
|
+
dir = modifier(dir, this);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (gravityStrength != 0 || modifiers!=null)
|
|
109
|
+
dir.Normalize();
|
|
110
|
+
Vector3 pos = position + dir * length;
|
|
111
|
+
Node child0 = new Node(position, rad*.9f, dir, creator, distancToOrigin: distanceFromOrigin);
|
|
112
|
+
|
|
113
|
+
child0.growth.canBeSplit = false; // Make sure The start of the new branch can't be split.
|
|
114
|
+
Node child1 = new Node(pos, rad*secondaryBranchRadius, dir, creator, distancToOrigin: distanceFromOrigin + length);
|
|
115
|
+
child0.children.Add(child1);
|
|
116
|
+
children.Add(child0);
|
|
117
|
+
child1.growth = new GrowthInformation(growth.growthGoal, growth.remainingGrowth - length, growth.initialRadius * secondaryBranchRadius);
|
|
118
|
+
if (!outOfLength)
|
|
119
|
+
extremities.Enqueue(child1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
return extremities;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
public Stack<Queue<TreePoint>> ToSplines()
|
|
128
|
+
{
|
|
129
|
+
Stack<Queue<TreePoint>> points = new Stack<Queue<TreePoint>>();
|
|
130
|
+
points.Push(new Queue<TreePoint>());
|
|
131
|
+
this.ToSplinesRec(points, Vector3.up);
|
|
132
|
+
return points;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private void ToSplinesRec(Stack<Queue<TreePoint>> points, Vector3 parentDirection, float parentRadius=0)
|
|
136
|
+
{
|
|
137
|
+
int n = children.Count;
|
|
138
|
+
float rad = radius;
|
|
139
|
+
if (type == NodeType.Trunk && n > 0)
|
|
140
|
+
{
|
|
141
|
+
rad = children[0].radius;
|
|
142
|
+
direction = (children[0].position - position).normalized;
|
|
143
|
+
}
|
|
144
|
+
points.Peek().Enqueue(new TreePoint(position, direction, radius, type, parentDirection, distanceFromOrigin, parentRadius));
|
|
145
|
+
if (n > 0)
|
|
146
|
+
children[0].ToSplinesRec(points, direction);
|
|
147
|
+
for (int i=1; i<n; i++)
|
|
148
|
+
{
|
|
149
|
+
points.Push(new Queue<TreePoint>());
|
|
150
|
+
children[i].ToSplinesRec(points, direction, rad);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public void GetSelection(Queue<Node> selected, int selection, bool extremitiesOnly, ref float maxHeight)
|
|
155
|
+
{
|
|
156
|
+
if (selection == creator && !(extremitiesOnly && children.Count > 0))
|
|
157
|
+
{
|
|
158
|
+
selected.Enqueue(this);
|
|
159
|
+
if (position.y > maxHeight)
|
|
160
|
+
maxHeight = position.y;
|
|
161
|
+
}
|
|
162
|
+
foreach (Node child in children)
|
|
163
|
+
{
|
|
164
|
+
child.GetSelection(selected, selection, extremitiesOnly, ref maxHeight);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public void GetSplitCandidates(Queue<Node> selected, int selection, float start, float remainingLength)
|
|
169
|
+
{
|
|
170
|
+
if (start <= positionInBranch && selection == creator && children.Count == 1)
|
|
171
|
+
{
|
|
172
|
+
positionInBranch = (positionInBranch - start) * (1 - start);
|
|
173
|
+
selected.Enqueue(this);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
for(int i=0; i<children.Count; i++)
|
|
177
|
+
{
|
|
178
|
+
if (i == 0)
|
|
179
|
+
{
|
|
180
|
+
float dist = (children[i].position - position).magnitude;
|
|
181
|
+
children[i].GetSplitCandidates(selected, selection, start, remainingLength - dist);
|
|
182
|
+
}
|
|
183
|
+
else
|
|
184
|
+
{
|
|
185
|
+
children[i].GetSplitCandidates(selected, selection, start, start);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public void DebugPosRec(List<Vector3> positions)
|
|
191
|
+
{
|
|
192
|
+
positions.Add(position);
|
|
193
|
+
foreach(Node child in children)
|
|
194
|
+
{
|
|
195
|
+
child.DebugPosRec(positions);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public void AddGrowth(float growthLength)
|
|
200
|
+
{
|
|
201
|
+
growth.remainingGrowth = growthLength;
|
|
202
|
+
growth.growthGoal = growthLength;
|
|
203
|
+
growth.initialRadius = radius;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private bool ObstacleAvoidance(ref Vector3 dir, Vector3 position, Transform transform, float distance)
|
|
207
|
+
{
|
|
208
|
+
RaycastHit hit;
|
|
209
|
+
if (Physics.Raycast(transform.TransformPoint(position), transform.TransformDirection(dir), out hit, distance))
|
|
210
|
+
{
|
|
211
|
+
Vector3 disp = transform.InverseTransformDirection(hit.normal) * Mathf.Exp(-hit.distance * .3f) * 1;
|
|
212
|
+
dir += disp;
|
|
213
|
+
dir.Normalize();
|
|
214
|
+
return disp.magnitude > .5f;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
public void GetLeafCandidates(Queue<LeafCandidate> candidates, float maxBranchRadius, ref float totalLength, int selection)
|
|
220
|
+
{
|
|
221
|
+
if (radius < maxBranchRadius && creator == selection)
|
|
222
|
+
{
|
|
223
|
+
float branchLength = 0f;
|
|
224
|
+
if (children.Count > 0)
|
|
225
|
+
{
|
|
226
|
+
branchLength = (children[0].position - position).magnitude;
|
|
227
|
+
}
|
|
228
|
+
totalLength += branchLength;
|
|
229
|
+
candidates.Enqueue(new LeafCandidate(position, direction, Mathf.Pow(radius, .2f), branchLength, distanceFromOrigin, children.Count > 0));
|
|
230
|
+
}
|
|
231
|
+
foreach (Node child in children)
|
|
232
|
+
{
|
|
233
|
+
child.GetLeafCandidates(candidates, maxBranchRadius, ref totalLength, selection);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public void Simplify(Node parent, float angleThreshold, float radiusThreshold)
|
|
238
|
+
{
|
|
239
|
+
if (radius < radiusThreshold)
|
|
240
|
+
{
|
|
241
|
+
children = new List<Node>();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
Node nextParent = this;
|
|
246
|
+
int n;
|
|
247
|
+
if (children.Count > 0 && parent != null && parent.radius / children[0].radius < 2)
|
|
248
|
+
{
|
|
249
|
+
Vector3 v1 = position - parent.position;
|
|
250
|
+
Vector3 v2 = children[0].position - position;
|
|
251
|
+
if ((Vector3.Angle(v1, v2) < angleThreshold) && type != NodeType.Flare) // if true current Node must be removed
|
|
252
|
+
{
|
|
253
|
+
List<Node> parentChildren = new List<Node>() {children[0]}; // new childern for parent, with first child being self first child
|
|
254
|
+
n = parent.children.Count;
|
|
255
|
+
for (int i = 1; i < n; i++) // adding original parent children
|
|
256
|
+
{
|
|
257
|
+
parentChildren.Add(parent.children[i]);
|
|
258
|
+
}
|
|
259
|
+
n = children.Count;
|
|
260
|
+
for(int i=1; i<n; i++)
|
|
261
|
+
{
|
|
262
|
+
parentChildren.Add(children[i]); // adding self children except firt one whih is already in list
|
|
263
|
+
}
|
|
264
|
+
parent.children = parentChildren;
|
|
265
|
+
nextParent = parent;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
n = 0;
|
|
269
|
+
foreach (Node child in children)
|
|
270
|
+
{
|
|
271
|
+
if (n == 0)
|
|
272
|
+
{
|
|
273
|
+
child.Simplify(nextParent, angleThreshold, radiusThreshold);
|
|
274
|
+
}
|
|
275
|
+
else
|
|
276
|
+
{
|
|
277
|
+
child.Simplify(null, angleThreshold, radiusThreshold);
|
|
278
|
+
}
|
|
279
|
+
n++;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
public float UpdatePositionInBranch(float distanceFromBranchOrigin=0, Node parent = null)
|
|
284
|
+
{
|
|
285
|
+
float dist = parent == null ? 0 : Vector3.Distance(parent.position, position);
|
|
286
|
+
dist += distanceFromBranchOrigin;
|
|
287
|
+
float totalDistance;
|
|
288
|
+
if (children.Count == 0)
|
|
289
|
+
{
|
|
290
|
+
positionInBranch = 1f;
|
|
291
|
+
totalDistance = dist;
|
|
292
|
+
}
|
|
293
|
+
else
|
|
294
|
+
{
|
|
295
|
+
totalDistance = children[0].UpdatePositionInBranch(dist, this);
|
|
296
|
+
positionInBranch = dist / totalDistance;
|
|
297
|
+
for (int i=1; i<children.Count; i++)
|
|
298
|
+
{
|
|
299
|
+
children[i].UpdatePositionInBranch(0);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return totalDistance;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
public enum NodeType {Flare, Trunk, Branch, FromTrunk}
|
|
308
|
+
|
|
309
|
+
public struct GrowthInformation
|
|
310
|
+
{
|
|
311
|
+
public float remainingGrowth;
|
|
312
|
+
public float growthGoal;
|
|
313
|
+
public float initialRadius;
|
|
314
|
+
public bool canBeSplit;
|
|
315
|
+
|
|
316
|
+
public GrowthInformation(float goal = 0f, float remaining = 0f, float radius = 1f)
|
|
317
|
+
{
|
|
318
|
+
remainingGrowth = remaining;
|
|
319
|
+
growthGoal = goal;
|
|
320
|
+
initialRadius = radius;
|
|
321
|
+
canBeSplit = true;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
public float GrowthPercentage(float additionalLength = 0f)
|
|
325
|
+
{
|
|
326
|
+
if (growthGoal == 0)
|
|
327
|
+
return 0;
|
|
328
|
+
return 1 - (remainingGrowth - additionalLength) / growthGoal;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Mtree
|
|
6
|
+
{
|
|
7
|
+
public class SimplexNoiseGenerator
|
|
8
|
+
{
|
|
9
|
+
private int[] A = new int[3];
|
|
10
|
+
private float s, u, v, w;
|
|
11
|
+
private int i, j, k;
|
|
12
|
+
private float onethird = 0.333333333f;
|
|
13
|
+
private float onesixth = 0.166666667f;
|
|
14
|
+
private int[] T;
|
|
15
|
+
|
|
16
|
+
public SimplexNoiseGenerator()
|
|
17
|
+
{
|
|
18
|
+
if (T == null)
|
|
19
|
+
{
|
|
20
|
+
System.Random rand = new System.Random();
|
|
21
|
+
T = new int[8];
|
|
22
|
+
for (int q = 0; q < 8; q++)
|
|
23
|
+
T[q] = rand.Next();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public SimplexNoiseGenerator(string seed)
|
|
28
|
+
{
|
|
29
|
+
T = new int[8];
|
|
30
|
+
string[] seed_parts = seed.Split(new char[] { ' ' });
|
|
31
|
+
|
|
32
|
+
for (int q = 0; q < 8; q++)
|
|
33
|
+
{
|
|
34
|
+
int b;
|
|
35
|
+
try
|
|
36
|
+
{
|
|
37
|
+
b = int.Parse(seed_parts[q]);
|
|
38
|
+
}
|
|
39
|
+
catch
|
|
40
|
+
{
|
|
41
|
+
b = 0x0;
|
|
42
|
+
}
|
|
43
|
+
T[q] = b;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public SimplexNoiseGenerator(int[] seed)
|
|
48
|
+
{ // {0x16, 0x38, 0x32, 0x2c, 0x0d, 0x13, 0x07, 0x2a}
|
|
49
|
+
T = seed;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public string GetSeed()
|
|
53
|
+
{
|
|
54
|
+
string seed = "";
|
|
55
|
+
|
|
56
|
+
for (int q = 0; q < 8; q++)
|
|
57
|
+
{
|
|
58
|
+
seed += T[q].ToString();
|
|
59
|
+
if (q < 7)
|
|
60
|
+
seed += " ";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return seed;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public float coherentNoise(float x, float y, float z, int octaves = 1, int multiplier = 25, float amplitude = 0.5f, float lacunarity = 2, float persistence = 0.9f)
|
|
67
|
+
{
|
|
68
|
+
Vector3 v3 = new Vector3(x, y, z) / multiplier;
|
|
69
|
+
float val = 0;
|
|
70
|
+
for (int n = 0; n < octaves; n++)
|
|
71
|
+
{
|
|
72
|
+
val += noise(v3.x, v3.y, v3.z) * amplitude;
|
|
73
|
+
v3 *= lacunarity;
|
|
74
|
+
amplitude *= persistence;
|
|
75
|
+
}
|
|
76
|
+
return val;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public int getDensity(Vector3 loc)
|
|
80
|
+
{
|
|
81
|
+
float val = coherentNoise(loc.x, loc.y, loc.z);
|
|
82
|
+
return (int)Mathf.Lerp(0, 255, val);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public float noise(Vector3 v)
|
|
86
|
+
{
|
|
87
|
+
return noise(v.x, v.y, v.z);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public Vector3 noiseGradient(Vector3 v, bool flat)
|
|
91
|
+
{
|
|
92
|
+
float origin = noise(v);
|
|
93
|
+
float x = (noise(v + Vector3.right / 10) - origin) * 10;
|
|
94
|
+
float y = flat ? 0 : (noise(v + Vector3.up / 10) - origin) * 10;
|
|
95
|
+
float z = (noise(v + Vector3.forward / 10) - origin) * 10;
|
|
96
|
+
return new Vector3(x, y, z);
|
|
97
|
+
}
|
|
98
|
+
// Simplex Noise Generator
|
|
99
|
+
public float noise(float x, float y, float z)
|
|
100
|
+
{
|
|
101
|
+
s = (x + y + z) * onethird;
|
|
102
|
+
i = fastfloor(x + s);
|
|
103
|
+
j = fastfloor(y + s);
|
|
104
|
+
k = fastfloor(z + s);
|
|
105
|
+
|
|
106
|
+
s = (i + j + k) * onesixth;
|
|
107
|
+
u = x - i + s;
|
|
108
|
+
v = y - j + s;
|
|
109
|
+
w = z - k + s;
|
|
110
|
+
|
|
111
|
+
A[0] = 0; A[1] = 0; A[2] = 0;
|
|
112
|
+
|
|
113
|
+
int hi = u >= w ? u >= v ? 0 : 1 : v >= w ? 1 : 2;
|
|
114
|
+
int lo = u < w ? u < v ? 0 : 1 : v < w ? 1 : 2;
|
|
115
|
+
|
|
116
|
+
return kay(hi) + kay(3 - hi - lo) + kay(lo) + kay(0);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
float kay(int a)
|
|
120
|
+
{
|
|
121
|
+
s = (A[0] + A[1] + A[2]) * onesixth;
|
|
122
|
+
float x = u - A[0] + s;
|
|
123
|
+
float y = v - A[1] + s;
|
|
124
|
+
float z = w - A[2] + s;
|
|
125
|
+
float t = 0.6f - x * x - y * y - z * z;
|
|
126
|
+
int h = shuffle(i + A[0], j + A[1], k + A[2]);
|
|
127
|
+
A[a]++;
|
|
128
|
+
if (t < 0) return 0;
|
|
129
|
+
int b5 = h >> 5 & 1;
|
|
130
|
+
int b4 = h >> 4 & 1;
|
|
131
|
+
int b3 = h >> 3 & 1;
|
|
132
|
+
int b2 = h >> 2 & 1;
|
|
133
|
+
int b1 = h & 3;
|
|
134
|
+
|
|
135
|
+
float p = b1 == 1 ? x : b1 == 2 ? y : z;
|
|
136
|
+
float q = b1 == 1 ? y : b1 == 2 ? z : x;
|
|
137
|
+
float r = b1 == 1 ? z : b1 == 2 ? x : y;
|
|
138
|
+
|
|
139
|
+
p = b5 == b3 ? -p : p;
|
|
140
|
+
q = b5 == b4 ? -q : q;
|
|
141
|
+
r = b5 != (b4 ^ b3) ? -r : r;
|
|
142
|
+
t *= t;
|
|
143
|
+
return 8 * t * t * (p + (b1 == 0 ? q + r : b2 == 0 ? q : r));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
int shuffle(int i, int j, int k)
|
|
147
|
+
{
|
|
148
|
+
return b(i, j, k, 0) + b(j, k, i, 1) + b(k, i, j, 2) + b(i, j, k, 3) + b(j, k, i, 4) + b(k, i, j, 5) + b(i, j, k, 6) + b(j, k, i, 7);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
int b(int i, int j, int k, int B)
|
|
152
|
+
{
|
|
153
|
+
return T[b(i, B) << 2 | b(j, B) << 1 | b(k, B)];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
int b(int N, int B)
|
|
157
|
+
{
|
|
158
|
+
return N >> B & 1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
int fastfloor(float n)
|
|
162
|
+
{
|
|
163
|
+
return n > 0 ? (int)n : (int)n - 1;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|