From 13e08fec68a28678e1968ccef06b7dbf543fda80 Mon Sep 17 00:00:00 2001 From: Pascal Engeler <engelerp@phys.ethz.ch> Date: Fri, 3 Sep 2021 11:03:51 +0200 Subject: [PATCH] Efficient Block documentation --- README.md | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 148 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 042ca47..b10958b 100644 --- a/README.md +++ b/README.md @@ -366,31 +366,172 @@ Todo ### EfficientBlock ([efficient_block.hpp](include/efficient_block.hpp), [efficient_block.cpp](src/efficient_block.cpp)) **Description** -Todo +Represents a rectangular block. Scaled down version of the previous `Block`, optimized for current feature set. **Usage** -Todo + - Construct object + - Call `xywh` to obtain an efficient representation of the properties, convert it to vertices and draw them + - Note: This should be batched for peak performance (see `SlimBlockchainHandler`) + - Check if a point is inside the block using `is_inside` + - Obtain the dimensions using `width` and `height` + - Move the block to a new position using `translate` + - Mark the block for removal using `request_removal` + - Check if a block has been marked for removal using `needs_removal` **Constructors and Destructors** -Todo +- `EfficientBlock()` +- `EfficientBlock(const EfficientBlock&)` +- `EfficientBlock(int w, int h, int xoffset, int yoffset)` + + Note that (`xoffset`, `yoffset`) are the coordinates of the lower left corner, with origin in the top left corner of the texture. **Public Function Members** -Todo +- `void request_removal()` + + - **Description**: + + Mark block for removal + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Block is marked for removal + + - **Notes**: + + N/A + +- `void translate(int new_x, int new_y)` + + - **Description**: + + Translate block to new (LLC) texel-coordinates. + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Block has been translated to (`new_x`, `new_y`). + + - **Notes**: + + N/A + +- `bool needs_removal() const` + + - **Description**: + + Check if block is marked for removal. + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Returns `true` if block has been marked for removal, and `false` else. + + - **Notes**: + + N/A + +- `glm::ivec4 xywh() const` + + - **Description**: + + Get coordinates and dimensions of block. + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Returns a `glm::ivec4`; `[0]`->x, `[1]`->y, `[2]`->width, `[3]`->height. + + - **Notes**: + + + +- `bool is_inside(int x, int y) const` + + - **Description**: + + Check if a point lies within the block. + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Returns `true` if point (`x`, `y`) is inside the block, `false` else. + + - **Notes**: + + N/A + +- `int width() const` + + - **Description**: + + Get the width of the block. + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Returns the width of the block in texels. + + - **Notes**: + + + +- `int height() const` + + - **Description**: + + Get the height of the block. + + - **Preconditions**: + + + + - **Postconditions**: + + Returns the height of the block in texels. + + - **Notes**: + + **Private Function Members** -Todo +N/A **Public Data Members** -Todo +N/A **Private Data Members** -Todo +- `glm::ivec4 xywh_` + + Coordinates and dimensions of block + +- `bool needs_removal_` + + Is block marked for removal? **Notes** -- GitLab