OpenClonk
C4TextureShapeActivationMap Class Reference

Public Member Functions

 C4TextureShapeActivationMap (int32_t block_x0, int32_t block_y0, int32_t n_blocks_x, int32_t n_blocks_y, int32_t num_shapes)
 
int32_t Get (int32_t block_x, int32_t block_y, int32_t shape_idx, int32_t xpart, int32_t ypart, uint8_t *bg_pix) const
 
void Add (int32_t block_x, int32_t block_y, int32_t shape_idx, int32_t xpart, int32_t ypart, uint8_t back_pix)
 

Detailed Description

Definition at line 123 of file C4TextureShape.cpp.

Constructor & Destructor Documentation

◆ C4TextureShapeActivationMap()

C4TextureShapeActivationMap::C4TextureShapeActivationMap ( int32_t  block_x0,
int32_t  block_y0,
int32_t  n_blocks_x,
int32_t  n_blocks_y,
int32_t  num_shapes 
)
inline

Definition at line 136 of file C4TextureShape.cpp.

136  : block_x0(block_x0), block_y0(block_y0), n_blocks_x(n_blocks_x), n_blocks_y(n_blocks_y), num_shapes(num_shapes)
137  {
138  activation.resize(n_blocks_x * n_blocks_y * num_shapes * 4, 0);
139  back_pix.resize(n_blocks_x * n_blocks_y * num_shapes * 4, 0u);
140  }

Member Function Documentation

◆ Add()

void C4TextureShapeActivationMap::Add ( int32_t  block_x,
int32_t  block_y,
int32_t  shape_idx,
int32_t  xpart,
int32_t  ypart,
uint8_t  back_pix 
)

Definition at line 164 of file C4TextureShape.cpp.

165 {
166  // activation map access
167  int32_t idx = Idx(block_x, block_y, shape_idx, xpart, ypart);
168  if (idx < 0)
169  {
170  // This can happen for maps in which the shape is too large or simply at landscape borders. So ignore.
171  return;
172  }
173  ++activation[idx];
174  back_pix[idx] = bg_pix;
175 }

Referenced by C4TextureShape::Draw().

Here is the caller graph for this function:

◆ Get()

int32_t C4TextureShapeActivationMap::Get ( int32_t  block_x,
int32_t  block_y,
int32_t  shape_idx,
int32_t  xpart,
int32_t  ypart,
uint8_t *  bg_pix 
) const

Definition at line 154 of file C4TextureShape.cpp.

155 {
156  // activation map access
157  int32_t idx = Idx(block_x, block_y, shape_idx, xpart, ypart);
158  assert(idx >= 0);
159  if (idx < 0) return 0;
160  *bg_pix = back_pix[idx];
161  return activation[idx];
162 }

Referenced by C4TextureShape::Draw().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: