Class BasicHashNoise
java.lang.Object
com.github.yellowstonegames.grid.BasicHashNoise
- All Implemented Interfaces:
com.github.yellowstonegames.core.ISerializersNeeded, INoise, Externalizable, Serializable
public class BasicHashNoise
extends Object
implements INoise, com.github.yellowstonegames.core.ISerializersNeeded
Makes 2D through 6D value noise that simply preserves the behavior of an
IPointHash, including intentional
(or unintentional) artifacts that the point hash produces. This is more useful with intentionally-flawed point hashes
from FlawedPointHash, such as FlawedPointHash.FlowerHash. Note that
because this uses an arbitrary IPointHash (and that interface doesn't define any way to serialize itself), you can't
serialize or deserialize a BasicHashNoise to or from a String. Binary serialization (such as using Kryo) still works.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface INoise
INoise.Serializer -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a copy of this BasicHashNoise, which is a shallow copy here and assumespointHashhas no mutable state that could need a deep copy.booleanintGets the maximum dimension supported by this generator, which is 6.intGets the minimum dimension supported by this generator, which is 2.floatgetNoise(float x, float y) Gets 2D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z) Gets 3D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z, float w) Gets 4D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z, float w, float u) Gets 5D noise with a default or pre-set seed.floatgetNoise(float x, float y, float z, float w, float u, float v) Gets 6D noise with a default or pre-set seed.floatgetNoiseWithSeed(float x, float y, float z, float w, float u, float v, long seed) Gets 6D noise with a specific seed.floatgetNoiseWithSeed(float x, float y, float z, float w, float u, long seed) Gets 5D noise with a specific seed.floatgetNoiseWithSeed(float x, float y, float z, float w, long seed) Gets 4D noise with a specific seed.floatgetNoiseWithSeed(float x, float y, float z, long seed) Gets 3D noise with a specific seed.floatgetNoiseWithSeed(float x, float y, long seed) Gets 2D noise with a specific seed.longgetSeed()Gets the current seed of the generator, as a long.getTag()Returns the constant String"BaHN"that identifies this in serialized Strings.booleanReturns true because this generator can be seeded withsetSeed(long)and retrieved withgetSeed().inthashCode()voidsetSeed(long seed) Sets the seed to the given long, if long seeds are supported, or(int)seedif only int seeds are supported.stringDeserialize(String data) Because this needs to read anIPointHash, but that interface can't be deserialized, this throws anUnsupportedOperationExceptiononly.Because this needs to write anIPointHash, but that interface can't be serialized, this throws anUnsupportedOperationExceptiononly.toString()Methods inherited from interface INoise
getNoise, getNoiseWithSeed, readExternal, writeExternal
-
Field Details
-
instance
-
seed
public int seed -
pointHash
-
-
Constructor Details
-
BasicHashNoise
public BasicHashNoise() -
BasicHashNoise
public BasicHashNoise(int seed) -
BasicHashNoise
-
-
Method Details
-
getMinDimension
public int getMinDimension()Gets the minimum dimension supported by this generator, which is 2.- Specified by:
getMinDimensionin interfaceINoise- Returns:
- the minimum supported dimension, 2
-
getMaxDimension
public int getMaxDimension()Gets the maximum dimension supported by this generator, which is 6.- Specified by:
getMaxDimensionin interfaceINoise- Returns:
- the maximum supported dimension, 6
-
hasEfficientSetSeed
public boolean hasEfficientSetSeed()Returns true because this generator can be seeded withsetSeed(long)and retrieved withgetSeed().- Specified by:
hasEfficientSetSeedin interfaceINoise- Returns:
- true
-
setSeed
public void setSeed(long seed) Sets the seed to the given long, if long seeds are supported, or(int)seedif only int seeds are supported. IfhasEfficientSetSeed()returns true, this must be implemented and must set the seed given a long input. If this generator cannot be seeded, this is permitted to either do nothing or throw anUnsupportedOperationException. If this operation allocates or is time-intensive, then that performance cost will be passed along togetNoiseWithSeed(float, float, long), since that calls this twice unless overridden. In the case where seeding is expensive to perform, setSeed() can still be implemented whilehasEfficientSetSeed()returns false. This makes thegetNoiseWithSeed(float, float, long)methods avoid reseeding, and instead move their inputs around in space. -
getSeed
-
getTag
-
stringSerialize
Because this needs to write anIPointHash, but that interface can't be serialized, this throws anUnsupportedOperationExceptiononly.- Specified by:
stringSerializein interfaceINoise- Returns:
- never returns normally
-
stringDeserialize
Because this needs to read anIPointHash, but that interface can't be deserialized, this throws anUnsupportedOperationExceptiononly.- Specified by:
stringDeserializein interfaceINoise- Parameters:
data- a serialized String, typically produced bystringSerialize()- Returns:
- never returns normally
-
copy
Creates a copy of this BasicHashNoise, which is a shallow copy here and assumespointHashhas no mutable state that could need a deep copy. -
getNoise
public float getNoise(float x, float y) Description copied from interface:INoiseGets 2D noise with a default or pre-set seed. -
getNoiseWithSeed
public float getNoiseWithSeed(float x, float y, long seed) Description copied from interface:INoiseGets 2D noise with a specific seed. If the seed cannot be retrieved or changed per-call, then this falls back to changing the position instead of the seed; you can check if this will happen withINoise.hasEfficientSetSeed().- Specified by:
getNoiseWithSeedin interfaceINoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatseed- can be any long- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoise
public float getNoise(float x, float y, float z) Description copied from interface:INoiseGets 3D noise with a default or pre-set seed. -
getNoiseWithSeed
public float getNoiseWithSeed(float x, float y, float z, long seed) Description copied from interface:INoiseGets 3D noise with a specific seed. If the seed cannot be retrieved or changed per-call, then this falls back to changing the position instead of the seed; you can check if this will happen withINoise.hasEfficientSetSeed().- Specified by:
getNoiseWithSeedin interfaceINoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatseed- can be any long- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoise
public float getNoise(float x, float y, float z, float w) Description copied from interface:INoiseGets 4D noise with a default or pre-set seed. -
getNoiseWithSeed
public float getNoiseWithSeed(float x, float y, float z, float w, long seed) Description copied from interface:INoiseGets 4D noise with a specific seed. If the seed cannot be retrieved or changed per-call, then this falls back to changing the position instead of the seed; you can check if this will happen withINoise.hasEfficientSetSeed().- Specified by:
getNoiseWithSeedin interfaceINoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatw- w position; can be any finite floatseed- can be any long- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoise
public float getNoise(float x, float y, float z, float w, float u) Description copied from interface:INoiseGets 5D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatw- w position; can be any finite floatu- u position; can be any finite float- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoiseWithSeed
public float getNoiseWithSeed(float x, float y, float z, float w, float u, long seed) Description copied from interface:INoiseGets 5D noise with a specific seed. If the seed cannot be retrieved or changed per-call, then this falls back to changing the position instead of the seed; you can check if this will happen withINoise.hasEfficientSetSeed().- Specified by:
getNoiseWithSeedin interfaceINoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatw- w position; can be any finite floatu- u position; can be any finite floatseed- can be any long- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoise
public float getNoise(float x, float y, float z, float w, float u, float v) Description copied from interface:INoiseGets 6D noise with a default or pre-set seed.- Specified by:
getNoisein interfaceINoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatw- w position; can be any finite floatu- u position; can be any finite floatv- v position; can be any finite float- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
getNoiseWithSeed
public float getNoiseWithSeed(float x, float y, float z, float w, float u, float v, long seed) Description copied from interface:INoiseGets 6D noise with a specific seed. If the seed cannot be retrieved or changed per-call, then this falls back to changing the position instead of the seed; you can check if this will happen withINoise.hasEfficientSetSeed().- Specified by:
getNoiseWithSeedin interfaceINoise- Parameters:
x- x position; can be any finite floaty- y position; can be any finite floatz- z position; can be any finite floatw- w position; can be any finite floatu- u position; can be any finite floatv- v position; can be any finite floatseed- can be any long- Returns:
- a noise value between -1.0f and 1.0f, both inclusive
-
toString
-
equals
-
hashCode
-
getSerializersNeeded
-