2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-12-22 18:25:01 +00:00
|
|
|
|
|
|
|
|
#pragma once
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
* \brief Class to define a cell grid surrounding the bounding box of the scene
|
2012-12-22 18:25:01 +00:00
|
|
|
*/
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
#include "Grid.h"
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Class to define a regular grid used for ray casting computations
|
2022-08-19 13:49:13 +10:00
|
|
|
* We don't use a hash-table here. The grid is explicitly stored for faster computations.
|
2019-04-30 17:50:57 +10:00
|
|
|
* However, this might result in significant increase in memory usage
|
|
|
|
|
* (compared to the regular grid).
|
2008-04-30 15:41:54 +00:00
|
|
|
*/
|
2014-04-17 14:19:10 +09:00
|
|
|
class FastGrid : public Grid {
|
2012-12-22 18:25:01 +00:00
|
|
|
public:
|
|
|
|
|
FastGrid() : Grid()
|
|
|
|
|
{
|
2023-08-01 21:15:52 +10:00
|
|
|
_cells = nullptr;
|
2012-12-22 18:25:01 +00:00
|
|
|
_cells_size = 0;
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-22 18:25:01 +00:00
|
|
|
virtual ~FastGrid()
|
|
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/**
|
2019-04-30 17:50:57 +10:00
|
|
|
* clears the grid
|
2022-08-19 13:49:13 +10:00
|
|
|
* Deletes all the cells, clears the hash-table, resets size, size of cell, number of cells.
|
2012-12-22 18:25:01 +00:00
|
|
|
*/
|
|
|
|
|
virtual void clear();
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Sets the different parameters of the grid
|
2012-12-22 18:25:01 +00:00
|
|
|
* orig
|
|
|
|
|
* The grid origin
|
|
|
|
|
* size
|
|
|
|
|
* The grid's dimensions
|
|
|
|
|
* nb
|
|
|
|
|
* The number of cells of the grid
|
|
|
|
|
*/
|
2023-07-25 12:51:50 +10:00
|
|
|
virtual void configure(const Vec3r &orig, const Vec3r &size, uint nb);
|
2012-12-22 18:25:01 +00:00
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** returns the cell whose coordinates are passed as argument */
|
2013-03-07 23:17:23 +00:00
|
|
|
Cell *getCell(const Vec3u &p);
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2021-06-24 15:57:33 +10:00
|
|
|
/** Fills the case p with the cell iCell */
|
2012-12-22 18:25:01 +00:00
|
|
|
virtual void fillCell(const Vec3u &p, Cell &cell);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
Cell **_cells;
|
2023-07-25 12:51:50 +10:00
|
|
|
uint _cells_size;
|
2013-08-04 18:50:00 +00:00
|
|
|
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:FastGrid")
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
} /* namespace Freestyle */
|