2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
|
2023-06-14 23:30:43 +10:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
* \brief Class to fill in a grid from a SceneGraph (uses only the WingedEdge structures)
|
2013-01-02 01:55:30 +00:00
|
|
|
*/
|
2008-04-30 15:41:54 +00:00
|
|
|
|
|
|
|
|
#include "WSFillGrid.h"
|
2020-04-21 12:39:12 +02:00
|
|
|
#include "WEdge.h"
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2013-01-02 01:55:30 +00:00
|
|
|
void WSFillGrid::fillGrid()
|
|
|
|
|
{
|
2019-05-31 22:51:19 +10:00
|
|
|
if (!_winged_edge || !_grid) {
|
2013-01-02 01:55:30 +00:00
|
|
|
return;
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-02 01:55:30 +00:00
|
|
|
vector<WShape *> wshapes = _winged_edge->getWShapes();
|
|
|
|
|
vector<WVertex *> fvertices;
|
|
|
|
|
vector<Vec3r> vectors;
|
|
|
|
|
vector<WFace *> faces;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-02 01:55:30 +00:00
|
|
|
for (vector<WShape *>::const_iterator it = wshapes.begin(); it != wshapes.end(); ++it) {
|
|
|
|
|
faces = (*it)->GetFaceList();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-02 01:55:30 +00:00
|
|
|
for (vector<WFace *>::const_iterator f = faces.begin(); f != faces.end(); ++f) {
|
|
|
|
|
(*f)->RetrieveVertexList(fvertices);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-31 22:51:19 +10:00
|
|
|
for (vector<WVertex *>::const_iterator wv = fvertices.begin(); wv != fvertices.end(); ++wv) {
|
2020-11-06 14:06:52 +01:00
|
|
|
vectors.emplace_back((*wv)->GetVertex());
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-02 01:55:30 +00:00
|
|
|
// occluder will be deleted by the grid
|
|
|
|
|
Polygon3r *occluder = new Polygon3r(vectors, (*f)->GetNormal());
|
|
|
|
|
occluder->setId(_polygon_id++);
|
|
|
|
|
occluder->userdata = (void *)(*f);
|
|
|
|
|
_grid->insertOccluder(occluder);
|
|
|
|
|
vectors.clear();
|
|
|
|
|
fvertices.clear();
|
|
|
|
|
}
|
|
|
|
|
faces.clear();
|
|
|
|
|
}
|
2013-04-09 00:46:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} /* namespace Freestyle */
|