Beispiel #1
0
int ZBlockGrid::getHashIndex(const ZIntPoint &blockIndex) const
{
  int index = -1;

  if (IS_IN_OPEN_RANGE(blockIndex.getX(), -1, m_size.getX()) &&
      IS_IN_OPEN_RANGE(blockIndex.getY(), -1, m_size.getY()) &&
      IS_IN_OPEN_RANGE(blockIndex.getZ(), -1, m_size.getZ())) {
    //ZIntPoint adjustedBlockIndex = blockIndex - m_grid.getFirstCorner();
    int area = m_size.getX() * m_size.getY();
    int width = m_size.getX();
    index = area * blockIndex.getZ() + width * blockIndex.getY() +
        blockIndex.getX();
  }

  return index;
}
Beispiel #2
0
void Stack_Draw_Object_C(Stack *stack, Object_3d *obj, uint8 r, uint8 g,
			 uint8 b)
{
  ASSERT(stack->kind == COLOR, "color canvas only");
  
  int offset;

  int i;
  int area = stack->width * stack->height;
  color_t *array = (color_t *) stack->array;

  for (i = 0; i < obj->size; i++) {
    if (IS_IN_OPEN_RANGE(obj->voxels[i][0], -1, Stack_Width(stack)) &&
	IS_IN_OPEN_RANGE(obj->voxels[i][1], -1, Stack_Height(stack)) &&
	IS_IN_OPEN_RANGE(obj->voxels[i][0], -1, Stack_Width(stack))) {
      offset = STACK_UTIL_OFFSET(obj->voxels[i][0], obj->voxels[i][1],
	  obj->voxels[i][2], stack->width, area);
      array[offset][0] = r;
      array[offset][1] = g;
      array[offset][2] = b;
    }
  }
}