MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetRandomScale

Method GetRandomScale

Source/Engine/Foliage/FoliageType.cpp:86–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86Float3 FoliageType::GetRandomScale() const
87{
88 Float3 result;
89 float tmp;
90 switch (PaintScaling)
91 {
92 case FoliageScalingModes::Uniform:
93 result.X = Math::Lerp(PaintScaleMin.X, PaintScaleMax.X, Random::Rand());
94 result.Y = result.X;
95 result.Z = result.X;
96 break;
97 case FoliageScalingModes::Free:
98 result.X = Math::Lerp(PaintScaleMin.X, PaintScaleMax.X, Random::Rand());
99 result.Y = Math::Lerp(PaintScaleMin.Y, PaintScaleMax.Y, Random::Rand());
100 result.Z = Math::Lerp(PaintScaleMin.Z, PaintScaleMax.Z, Random::Rand());
101 break;
102 case FoliageScalingModes::LockXY:
103 tmp = Random::Rand();
104 result.X = Math::Lerp(PaintScaleMin.X, PaintScaleMax.X, tmp);
105 result.Y = Math::Lerp(PaintScaleMin.Y, PaintScaleMax.Y, tmp);
106 result.Z = Math::Lerp(PaintScaleMin.Z, PaintScaleMax.Z, Random::Rand());
107 break;
108 case FoliageScalingModes::LockXZ:
109 tmp = Random::Rand();
110 result.X = Math::Lerp(PaintScaleMin.X, PaintScaleMax.X, tmp);
111 result.Y = Math::Lerp(PaintScaleMin.Y, PaintScaleMax.Y, Random::Rand());
112 result.Z = Math::Lerp(PaintScaleMin.Z, PaintScaleMax.Z, tmp);
113 break;
114 case FoliageScalingModes::LockYZ:
115 tmp = Random::Rand();
116 result.X = Math::Lerp(PaintScaleMin.X, PaintScaleMax.X, Random::Rand());
117 result.Y = Math::Lerp(PaintScaleMin.Y, PaintScaleMax.Y, tmp);
118 result.Z = Math::Lerp(PaintScaleMin.Z, PaintScaleMax.Z, tmp);
119 break;
120 }
121 return result;
122}
123
124void FoliageType::OnModelChanged()
125{

Callers 1

PaintMethod · 0.80

Calls 2

LerpFunction · 0.50
RandFunction · 0.50

Tested by

no test coverage detected