Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
blend2d.c
Go to the documentation of this file.
1//----------------------------------------------------------------------------------------
2/*
3 Allows weighted blending of values defined by their 2D position in space.
4*/
5class Blend2D<Class T>
6{
8 private ref array<T> m_Values;
10
11 //----------------------------------------------------------------------------------------
15 void Blend2D()
16 {
17 m_Positions = {};
18 m_Weights = {};
19 m_Values = {};
20 }
21
22 //----------------------------------------------------------------------------------------
26 void Insert(float posX, float posY, T value)
27 {
28 m_Positions.Insert(Vector(posX, posY, 0));
29 m_Values.Insert(value);
30 m_Weights.Insert(0);
31 }
32
33 //----------------------------------------------------------------------------------------
37 void Clear()
38 {
39 m_Positions.Clear();
40 m_Values.Clear();
41 m_Weights.Clear();
42 }
43
44 //----------------------------------------------------------------------------------------
45 /*
46 Evaluate and return the result of the blend sampled at coordinate [posX, posY].
47 */
48 T Blend(float posX, float posY)
49 {
50 vector samplePosition = Vector(posX, posY, 0);
52
53 T result;
54 int numValues = m_Values.Count();
55 for (int v = 0; v < numValues; ++v)
56 {
57 result += (m_Values[v] * m_Weights[v]);
58 }
59
60 return result;
61 }
62
63}
64
65//----------------------------------------------------------------------------------------
66typedef Blend2D<vector> Blend2DVector;
class Blend2D< Class T > Blend2DVector
ref array< float > m_Weights
Definition blend2d.c:9
void Insert(float posX, float posY, T value)
Insert new value at coordinate [posX, posY].
Definition blend2d.c:26
ref array< T > m_Values
Definition blend2d.c:8
void Clear()
Empty the blend structure.
Definition blend2d.c:37
T Blend(float posX, float posY)
Definition blend2d.c:48
ref array< vector > m_Positions
Definition blend2d.c:7
void Blend2D()
Create new blend structure.
Definition blend2d.c:15
Super root of all classes in Enforce script.
Definition enscript.c:11
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto void BlendCartesian(vector samplePosition, notnull array< vector > inPositions, notnull array< float > outWeights)
Output 2D blend space weights for inPositions when sampled at samplePosition.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.