Files
test/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00

161 lines
4.3 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup freestyle
* \brief Class to render a WingedEdge data structure
* from a polyhedral data structure organized in nodes of a scene graph.
*/
#include "WEdge.h"
#include "../scene_graph/IndexedFaceSet.h"
#include "../scene_graph/NodeTransform.h"
#include "../scene_graph/SceneVisitor.h"
#include "../system/FreestyleConfig.h"
#include "../system/RenderMonitor.h"
namespace Freestyle {
class WingedEdgeBuilder : public SceneVisitor {
public:
inline WingedEdgeBuilder() : SceneVisitor()
{
_current_wshape = nullptr;
_current_frs_material = nullptr;
_current_matrix = nullptr;
_winged_edge = new WingedEdge; // Not deleted by the destructor
_pRenderMonitor = nullptr;
}
virtual ~WingedEdgeBuilder()
{
for (vector<Matrix44r *>::iterator it = _matrices_stack.begin(); it != _matrices_stack.end();
++it) {
delete *it;
}
_matrices_stack.clear();
}
VISIT_DECL(IndexedFaceSet);
VISIT_DECL(NodeShape);
VISIT_DECL(NodeTransform);
virtual void visitNodeTransformAfter(NodeTransform &);
//
// Accessors
//
/////////////////////////////////////////////////////////////////////////////
inline WingedEdge *getWingedEdge()
{
return _winged_edge;
}
inline WShape *getCurrentWShape()
{
return _current_wshape;
}
inline FrsMaterial *getCurrentFrsMaterial()
{
return _current_frs_material;
}
inline Matrix44r *getCurrentMatrix()
{
return _current_matrix;
}
//
// Modifiers
//
/////////////////////////////////////////////////////////////////////////////
inline void setCurrentWShape(WShape *wshape)
{
_current_wshape = wshape;
}
inline void setCurrentFrsMaterial(FrsMaterial *mat)
{
_current_frs_material = mat;
}
#if 0
inline void setCurrentMatrix(Matrix44r *matrix)
{
_current_matrix = matrix;
}
#endif
inline void setRenderMonitor(RenderMonitor *iRenderMonitor)
{
_pRenderMonitor = iRenderMonitor;
}
protected:
virtual bool buildWShape(WShape &shape, IndexedFaceSet &ifs);
virtual void buildWVertices(WShape &shape, const float *vertices, uint vsize);
RenderMonitor *_pRenderMonitor;
private:
void buildTriangleStrip(const float *vertices,
const float *normals,
vector<FrsMaterial> &iMaterials,
const float *texCoords,
const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks,
const uint *vindices,
const uint *nindices,
const uint *mindices,
const uint *tindices,
const uint nvertices);
void buildTriangleFan(const float *vertices,
const float *normals,
vector<FrsMaterial> &iMaterials,
const float *texCoords,
const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks,
const uint *vindices,
const uint *nindices,
const uint *mindices,
const uint *tindices,
const uint nvertices);
void buildTriangles(const float *vertices,
const float *normals,
vector<FrsMaterial> &iMaterials,
const float *texCoords,
const IndexedFaceSet::FaceEdgeMark *iFaceEdgeMarks,
const uint *vindices,
const uint *nindices,
const uint *mindices,
const uint *tindices,
const uint nvertices);
void transformVertices(const float *vertices,
uint vsize,
const Matrix44r &transform,
float *res);
void transformNormals(const float *normals, uint nsize, const Matrix44r &transform, float *res);
WShape *_current_wshape;
FrsMaterial *_current_frs_material;
WingedEdge *_winged_edge;
Matrix44r *_current_matrix;
vector<Matrix44r *> _matrices_stack;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:WingedEdgeBuilder")
#endif
};
} /* namespace Freestyle */