Add Chromium-only Blender WebEngine parity work

This commit is contained in:
mes123456
2026-08-12 04:47:48 -04:00
commit 9fd26010f6
18225 changed files with 11622124 additions and 0 deletions

View File

@@ -0,0 +1,220 @@
/* SPDX-FileCopyrightText: 2008-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup freestyle
*/
#include "AppCanvas.h"
#include "AppConfig.h"
#include "AppView.h"
#include "Controller.h"
#include "../image/Image.h"
#include "../stroke/StrokeRenderer.h"
#include "../stroke/StyleModule.h"
#include "../system/TimeStamp.h"
#include "../system/StringUtils.h"
namespace Freestyle {
AppCanvas::AppCanvas()
{
_pViewer = nullptr;
_MapsPath = Config::Path::getInstance()->getMapsDir().c_str();
}
AppCanvas::AppCanvas(AppView *iViewer)
{
_pViewer = iViewer;
}
AppCanvas::AppCanvas(const AppCanvas &iBrother) : Canvas(iBrother)
{
_pViewer = iBrother._pViewer;
}
AppCanvas::~AppCanvas()
{
_pViewer = nullptr;
}
void AppCanvas::setViewer(AppView *iViewer)
{
_pViewer = iViewer;
}
int AppCanvas::width() const
{
return _pViewer->width();
}
int AppCanvas::height() const
{
return _pViewer->height();
}
BBox<Vec2i> AppCanvas::border() const
{
return _pViewer->border();
}
float AppCanvas::thickness() const
{
return _pViewer->thickness();
}
BBox<Vec3r> AppCanvas::scene3DBBox() const
{
return _pViewer->scene3DBBox();
}
void AppCanvas::preDraw()
{
Canvas::preDraw();
}
void AppCanvas::init()
{
#if 0
static bool firsttime = true;
if (firsttime) {
_Renderer = new BlenderStrokeRenderer;
if (!StrokeRenderer::loadTextures()) {
cerr << "unable to load stroke textures" << endl;
return;
}
}
#endif
}
void AppCanvas::postDraw()
{
for (uint i = 0; i < _StyleModules.size(); i++) {
if (!_StyleModules[i]->getDisplayed() || !_Layers[i]) {
continue;
}
_Layers[i]->ScaleThickness(thickness());
}
Canvas::postDraw();
}
void AppCanvas::Erase()
{
Canvas::Erase();
}
// Abstract
void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) const
{
float *rgb = new float[3 * w * h];
memset(rgb, 0, sizeof(float[3]) * w * h);
int xsch = width();
int ysch = height();
if (_pass_diffuse.buf) {
int xmin = border().getMin().x();
int ymin = border().getMin().y();
int xmax = border().getMax().x();
int ymax = border().getMax().y();
int rectx = _pass_diffuse.width;
int recty = _pass_diffuse.height;
float xfac = float(rectx) / float(xmax - xmin);
float yfac = float(recty) / float(ymax - ymin);
#if 0
if (blender::G.debug & blender::G_DEBUG_FREESTYLE) {
printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n",
w,
h,
x,
y,
xsch,
ysch,
xmax - xmin,
ymax - ymin,
rectx,
recty,
int(xfac * 100.0f));
}
#endif
int ii, jj;
for (int j = 0; j < h; j++) {
jj = int((y - ymin + j) * yfac);
if (jj < 0 || jj >= recty) {
continue;
}
for (int i = 0; i < w; i++) {
ii = int((x - xmin + i) * xfac);
if (ii < 0 || ii >= rectx) {
continue;
}
memcpy(rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float[3]));
}
}
}
oImage.setArray(rgb, xsch, ysch, w, h, x, y, false);
}
void AppCanvas::readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) const
{
float *z = new float[w * h];
memset(z, 0, sizeof(float) * w * h);
int xsch = width();
int ysch = height();
if (_pass_z.buf) {
int xmin = border().getMin().x();
int ymin = border().getMin().y();
int xmax = border().getMax().x();
int ymax = border().getMax().y();
int rectx = _pass_z.width;
int recty = _pass_z.height;
float xfac = float(rectx) / float(xmax - xmin);
float yfac = float(recty) / float(ymax - ymin);
#if 0
if (blender::G.debug & blender::G_DEBUG_FREESTYLE) {
printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n",
w,
h,
x,
y,
xsch,
ysch,
xmax - xmin,
ymax - ymin,
rectx,
recty,
int(xfac * 100.0f));
}
#endif
int ii, jj;
for (int j = 0; j < h; j++) {
jj = int((y - ymin + j) * yfac);
if (jj < 0 || jj >= recty) {
continue;
}
for (int i = 0; i < w; i++) {
ii = int((x - xmin + i) * xfac);
if (ii < 0 || ii >= rectx) {
continue;
}
z[w * j + i] = _pass_z.buf[rectx * jj + ii];
}
}
}
oImage.setArray(z, xsch, ysch, w, h, x, y, false);
}
void AppCanvas::RenderStroke(Stroke *iStroke)
{
if (_basic) {
iStroke->RenderBasic(_Renderer);
}
else {
iStroke->Render(_Renderer);
}
}
void AppCanvas::update() {}
} /* namespace Freestyle */

View File

@@ -0,0 +1,82 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup freestyle
*/
#include "../stroke/Canvas.h"
#include "AppView.h"
namespace Freestyle {
class AppCanvas : public Canvas {
public:
AppCanvas();
AppCanvas(AppView *iViewer);
AppCanvas(const AppCanvas &iBrother);
virtual ~AppCanvas();
/** operations that need to be done before a draw */
virtual void preDraw();
/** operations that need to be done after a draw */
virtual void postDraw();
/** Erases the layers and clears the canvas */
virtual void Erase();
/* init the canvas */
virtual void init();
/** Reads a pixel area from the canvas */
virtual void readColorPixels(int x, int y, int w, int h, RGBImage &oImage) const;
/** Reads a depth pixel area from the canvas */
virtual void readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) const;
virtual BBox<Vec3r> scene3DBBox() const;
/* abstract */
virtual void RenderStroke(Stroke *);
virtual void update();
/** accessors */
virtual int width() const;
virtual int height() const;
virtual BBox<Vec2i> border() const;
virtual float thickness() const;
AppView *_pViewer;
inline const AppView *viewer() const
{
return _pViewer;
}
/** modifiers */
void setViewer(AppView *iViewer);
/* soc */
void setPassDiffuse(float *buf, int width, int height)
{
_pass_diffuse.buf = buf;
_pass_diffuse.width = width;
_pass_diffuse.height = height;
}
void setPassZ(float *buf, int width, int height)
{
_pass_z.buf = buf;
_pass_z.width = width;
_pass_z.height = height;
}
private:
struct {
float *buf;
int width, height;
} _pass_diffuse, _pass_z;
};
} /* namespace Freestyle */

View File

@@ -0,0 +1,76 @@
/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup freestyle
*/
#include "AppConfig.h"
#include <iostream>
#include "../system/FreestyleConfig.h"
#include "../system/StringUtils.h"
using namespace std;
#include "BKE_appdir.hh"
namespace Freestyle::Config {
Path *Path::_pInstance = nullptr;
Path::Path()
{
// get the root directory
// soc
const std::optional<std::string> path = BKE_appdir_folder_id(blender::BLENDER_SYSTEM_SCRIPTS,
nullptr);
setRootDir(path.value_or(blender::BKE_appdir_program_dir()));
_pInstance = this;
}
void Path::setRootDir(const string &iRootDir)
{
_ProjectDir = iRootDir + string(DIR_SEP) + "freestyle";
_ModelsPath = "";
_PatternsPath = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "textures" +
string(DIR_SEP) + "variation_patterns" + string(DIR_SEP);
_BrushesPath = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "textures" +
string(DIR_SEP) + "brushes" + string(DIR_SEP);
_EnvMapDir = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "env_map" +
string(DIR_SEP);
_MapsDir = _ProjectDir + string(DIR_SEP) + "data" + string(DIR_SEP) + "maps" + string(DIR_SEP);
}
void Path::setHomeDir(const string &iHomeDir)
{
_HomeDir = iHomeDir;
}
Path::~Path()
{
_pInstance = nullptr;
}
Path *Path::getInstance()
{
return _pInstance;
}
string Path::getEnvVar(const string &iEnvVarName)
{
string value;
if (!getenv(iEnvVarName.c_str())) {
cerr << "Warning: You may want to set the $" << iEnvVarName
<< " environment variable to use Freestyle." << endl
<< " Otherwise, the current directory will be used instead." << endl;
value = ".";
}
else {
value = getenv(iEnvVarName.c_str());
}
return value;
}
} // namespace Freestyle::Config

View File

@@ -0,0 +1,104 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup freestyle
* \brief Configuration file
*/
#include <algorithm>
#include <string>
#include "../system/Precision.h"
#include "MEM_guardedalloc.h"
using namespace std;
namespace Freestyle {
namespace Config {
class Path {
protected:
static Path *_pInstance;
string _ProjectDir;
string _ModelsPath;
string _PatternsPath;
string _BrushesPath;
string _EnvMapDir;
string _MapsDir;
string _HomeDir;
public:
Path();
virtual ~Path();
static Path *getInstance();
void setRootDir(const string &iRootDir);
void setHomeDir(const string &iHomeDir);
const string &getProjectDir() const
{
return _ProjectDir;
}
const string &getModelsPath() const
{
return _ModelsPath;
}
const string &getPatternsPath() const
{
return _PatternsPath;
}
const string &getBrushesPath() const
{
return _BrushesPath;
}
const string &getEnvMapDir() const
{
return _EnvMapDir;
}
const string &getMapsDir() const
{
return _MapsDir;
}
const string &getHomeDir() const
{
return _HomeDir;
}
static string getEnvVar(const string &iEnvVarName);
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Config:Path")
};
//
// Configuration, default values
//
//////////////////////////////////////////////////////////////
// Application
static const string APPLICATION_NAME("APPNAME");
static const string APPLICATION_VERSION("APPVERSION");
// ViewMap
static const string VIEWMAP_EXTENSION("vm");
static const string VIEWMAP_MAGIC("ViewMap File");
static const string VIEWMAP_VERSION("1.9");
// Style modules
static const string STYLE_MODULE_EXTENSION("py");
static const string STYLE_MODULES_LIST_EXTENSION("sml");
// Options
static const string OPTIONS_DIR("." + APPLICATION_NAME);
static const string OPTIONS_FILE("options.xml");
static const string OPTIONS_CURRENT_DIRS_FILE("current_dirs.xml");
static const string OPTIONS_QGLVIEWER_FILE("qglviewer.xml");
} // namespace Config
} /* namespace Freestyle */

View File

@@ -0,0 +1,162 @@
/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup freestyle
*/
#include <iostream>
#include "AppConfig.h"
#include "AppView.h"
#include "Controller.h"
#include "../scene_graph/LineRep.h"
#include "../scene_graph/NodeLight.h"
#include "../scene_graph/NodeShape.h"
#include "../scene_graph/VertexRep.h"
#include "../stroke/Canvas.h"
#include "../system/StringUtils.h"
#include "../view_map/Silhouette.h"
#include "../view_map/ViewMap.h"
#include "BLI_math_rotation.h"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#if 1 // FRS_antialiasing
# include "BKE_global.hh"
# include "DNA_scene_types.h"
#endif
#include "FRS_freestyle.h"
namespace Freestyle {
AppView::AppView(const char * /*iName*/)
{
_Fovy = DEG2RADF(30.0f);
_ModelRootNode = new NodeDrawingStyle;
_SilhouetteRootNode = new NodeDrawingStyle;
_DebugRootNode = new NodeDrawingStyle;
_RootNode.AddChild(_ModelRootNode);
_SilhouetteRootNode->setStyle(DrawingStyle::LINES);
_SilhouetteRootNode->setLightingEnabled(false);
_SilhouetteRootNode->setLineWidth(2.0f);
_SilhouetteRootNode->setPointSize(3.0f);
_RootNode.AddChild(_SilhouetteRootNode);
_DebugRootNode->setStyle(DrawingStyle::LINES);
_DebugRootNode->setLightingEnabled(false);
_DebugRootNode->setLineWidth(1.0f);
_RootNode.AddChild(_DebugRootNode);
_minBBox = std::min(
std::min(_ModelRootNode->bbox().getMin()[0], _ModelRootNode->bbox().getMin()[1]),
_ModelRootNode->bbox().getMin()[2]);
_maxBBox = std::max(
std::max(_ModelRootNode->bbox().getMax()[0], _ModelRootNode->bbox().getMax()[1]),
_ModelRootNode->bbox().getMax()[2]);
_maxAbs = std::max(rabs(_minBBox), rabs(_maxBBox));
_minAbs = std::min(rabs(_minBBox), rabs(_maxBBox));
_p2DSelectionNode = new NodeDrawingStyle;
_p2DSelectionNode->setLightingEnabled(false);
_p2DSelectionNode->setStyle(DrawingStyle::LINES);
_p2DSelectionNode->setLineWidth(5.0f);
_p2DNode.AddChild(_p2DSelectionNode);
NodeLight *light = new NodeLight;
_Light.AddChild(light);
}
AppView::~AppView()
{
/*int ref =*//* UNUSED */ _RootNode.destroy();
_Light.destroy();
/*ref =*//* UNUSED */ _p2DNode.destroy();
}
real AppView::distanceToSceneCenter()
{
BBox<Vec3r> bbox = _ModelRootNode->bbox();
Vec3r v(UNPACK3(blender::g_freestyle.viewpoint));
v -= 0.5 * (bbox.getMin() + bbox.getMax());
return v.norm();
}
real AppView::znear()
{
BBox<Vec3r> bbox = _ModelRootNode->bbox();
Vec3r u = bbox.getMin();
Vec3r v = bbox.getMax();
Vec3r cameraCenter(UNPACK3(blender::g_freestyle.viewpoint));
Vec3r w1(u[0], u[1], u[2]);
Vec3r w2(v[0], u[1], u[2]);
Vec3r w3(u[0], v[1], u[2]);
Vec3r w4(v[0], v[1], u[2]);
Vec3r w5(u[0], u[1], v[2]);
Vec3r w6(v[0], u[1], v[2]);
Vec3r w7(u[0], v[1], v[2]);
Vec3r w8(v[0], v[1], v[2]);
real _znear = std::min(
(w1 - cameraCenter).norm(),
std::min((w2 - cameraCenter).norm(),
std::min((w3 - cameraCenter).norm(),
std::min((w4 - cameraCenter).norm(),
std::min((w5 - cameraCenter).norm(),
std::min((w6 - cameraCenter).norm(),
std::min((w7 - cameraCenter).norm(),
(w8 - cameraCenter).norm())))))));
return std::max(_znear, 0.001);
}
real AppView::zfar()
{
BBox<Vec3r> bbox = _ModelRootNode->bbox();
Vec3r u = bbox.getMin();
Vec3r v = bbox.getMax();
Vec3r cameraCenter(UNPACK3(blender::g_freestyle.viewpoint));
Vec3r w1(u[0], u[1], u[2]);
Vec3r w2(v[0], u[1], u[2]);
Vec3r w3(u[0], v[1], u[2]);
Vec3r w4(v[0], v[1], u[2]);
Vec3r w5(u[0], u[1], v[2]);
Vec3r w6(v[0], u[1], v[2]);
Vec3r w7(u[0], v[1], v[2]);
Vec3r w8(v[0], v[1], v[2]);
real _zfar = std::max(
(w1 - cameraCenter).norm(),
std::max((w2 - cameraCenter).norm(),
std::max((w3 - cameraCenter).norm(),
std::max((w4 - cameraCenter).norm(),
std::max((w5 - cameraCenter).norm(),
std::max((w6 - cameraCenter).norm(),
std::max((w7 - cameraCenter).norm(),
(w8 - cameraCenter).norm())))))));
return _zfar;
}
real AppView::GetFocalLength()
{
real Near = std::max(0.1, (real)(-2.0f * _maxAbs + distanceToSceneCenter()));
return Near;
}
} /* namespace Freestyle */

View File

@@ -0,0 +1,257 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup freestyle
*/
#include "AppConfig.h"
#include "../geometry/BBox.h"
#include "../geometry/Geom.h"
#include "../scene_graph/NodeDrawingStyle.h"
#include "../system/Precision.h"
#include "BLI_math_base.h"
#include "MEM_guardedalloc.h"
namespace Freestyle {
using namespace Geometry;
class AppView {
public:
AppView(const char *iName = 0);
virtual ~AppView();
public:
// inherited
inline uint width()
{
return _width;
}
inline uint height()
{
return _height;
}
inline BBox<Vec2i> border()
{
return _border;
}
inline float thickness()
{
return _thickness;
}
inline void setWidth(uint width)
{
_width = width;
}
inline void setHeight(uint height)
{
_height = height;
}
inline void setBorder(int xmin, int ymin, int xmax, int ymax)
{
_border = BBox<Vec2i>(Vec2i(xmin, ymin), Vec2i(xmax, ymax));
}
inline void setThickness(float thickness)
{
_thickness = thickness;
}
protected:
uint _width, _height;
BBox<Vec2i> _border;
float _thickness;
public:
/** Sets the model to draw in the viewer
* iModel
* The Root Node of the model
*/
inline void setModel(NodeGroup *iModel)
{
if (0 != _ModelRootNode->numberOfChildren()) {
_ModelRootNode->DetachChildren();
_ModelRootNode->clearBBox();
}
AddModel(iModel);
}
/** Adds a model for displaying in the viewer */
inline void AddModel(NodeGroup *iModel)
{
_ModelRootNode->AddChild(iModel);
_ModelRootNode->UpdateBBox();
_minBBox = std::min(
std::min(_ModelRootNode->bbox().getMin()[0], _ModelRootNode->bbox().getMin()[1]),
_ModelRootNode->bbox().getMin()[2]);
_maxBBox = std::max(
std::max(_ModelRootNode->bbox().getMax()[0], _ModelRootNode->bbox().getMax()[1]),
_ModelRootNode->bbox().getMax()[2]);
_maxAbs = std::max(rabs(_minBBox), rabs(_maxBBox));
_minAbs = std::min(rabs(_minBBox), rabs(_maxBBox));
}
inline void AddSilhouette(NodeGroup *iSilhouette)
{
_SilhouetteRootNode->AddChild(iSilhouette);
}
inline void Add2DSilhouette(NodeGroup * /*iSilhouette*/)
{
//_pFENode->AddChild(iSilhouette);
}
inline void Add2DVisibleSilhouette(NodeGroup * /*iVSilhouette*/)
{
//_pVisibleSilhouetteNode->AddChild(iVSilhouette);
}
inline void setDebug(NodeGroup *iDebug)
{
if (0 != _DebugRootNode->numberOfChildren()) {
_DebugRootNode->DetachChildren();
_DebugRootNode->clearBBox();
}
AddDebug(iDebug);
}
inline void AddDebug(NodeGroup *iDebug)
{
_DebugRootNode->AddChild(iDebug);
}
inline void DetachModel(Node *iModel)
{
_ModelRootNode->DetachChild(iModel);
_ModelRootNode->UpdateBBox();
_minBBox = std::min(
std::min(_ModelRootNode->bbox().getMin()[0], _ModelRootNode->bbox().getMin()[1]),
_ModelRootNode->bbox().getMin()[2]);
_maxBBox = std::max(
std::max(_ModelRootNode->bbox().getMax()[0], _ModelRootNode->bbox().getMax()[1]),
_ModelRootNode->bbox().getMax()[2]);
_maxAbs = std::max(rabs(_minBBox), rabs(_maxBBox));
_minAbs = std::min(rabs(_minBBox), rabs(_maxBBox));
}
inline void DetachModel()
{
_ModelRootNode->DetachChildren();
_ModelRootNode->clearBBox();
#if 0
// 2D Scene
_p2DNode.DetachChildren();
_pFENode->DetachChildren();
_pVisibleSilhouetteNode->DetachChildren();
#endif
}
inline void DetachSilhouette()
{
_SilhouetteRootNode->DetachChildren();
#if 0
_pFENode->DetachChildren();
_pVisibleSilhouetteNode->DetachChildren();
#endif
_p2DSelectionNode->destroy();
}
inline void DetachVisibleSilhouette()
{
//_pVisibleSilhouetteNode->DetachChildren();
_p2DSelectionNode->destroy();
}
inline void DetachDebug()
{
_DebugRootNode->DetachChildren();
}
real distanceToSceneCenter();
real GetFocalLength();
inline real GetAspect() const
{
return ((real)_width / (real)_height);
}
void setHorizontalFov(float hfov)
{
_Fovy = 2.0 * atan(tan(hfov / 2.0) / GetAspect());
}
inline real GetFovyRadian() const
{
return _Fovy;
}
inline real GetFovyDegrees() const
{
return _Fovy * 180.0 / M_PI; /* TODO: Use RAD2DEG here too? */
}
BBox<Vec3r> scene3DBBox() const
{
return _ModelRootNode->bbox();
}
real znear();
real zfar();
public:
/** Core scene drawing */
void DrawScene(SceneVisitor *iRenderer);
/** 2D Scene Drawing */
void Draw2DScene(SceneVisitor *iRenderer);
protected:
/** fabs or abs */
inline int rabs(int x)
{
return abs(x);
}
inline real rabs(real x)
{
return fabs(x);
}
protected:
float _Fovy;
// The root node container
NodeGroup _RootNode;
NodeDrawingStyle *_ModelRootNode;
NodeDrawingStyle *_SilhouetteRootNode;
NodeDrawingStyle *_DebugRootNode;
NodeGroup _Light;
real _minBBox;
real _maxBBox;
real _maxAbs;
real _minAbs;
// 2D Scene
bool _Draw2DScene;
bool _Draw3DScene;
NodeGroup _p2DNode;
NodeDrawingStyle *_p2DSelectionNode;
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:AppView")
};
} /* namespace Freestyle */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,269 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup freestyle
* \brief The spinal tap of the system.
*/
#include <string>
#include "../geometry/FastGrid.h"
#include "../scene_graph/SceneHash.h"
#include "../system/Precision.h"
#include "../system/TimeUtils.h"
#include "../view_map/FEdgeXDetector.h"
#include "../view_map/ViewMapBuilder.h"
#include "MEM_guardedalloc.h"
namespace blender {
struct Depsgraph;
struct Render;
struct ViewLayer;
} // namespace blender
namespace Freestyle {
class AppCanvas;
class AppView;
class Interpreter;
class NodeGroup;
class ProgressBar;
class RenderMonitor;
class SShape;
class ViewEdge;
class ViewMap;
class Controller {
public:
Controller();
~Controller();
void setView(AppView *iView);
void setRenderMonitor(RenderMonitor *iRenderMonitor);
void setPassDiffuse(float *buf, int width, int height);
void setPassZ(float *buf, int width, int height);
void setContext(blender::bContext *C);
// soc
void init_options();
int LoadMesh(blender::Render *re, blender::ViewLayer *view_layer, blender::Depsgraph *depsgraph);
int Load3DSFile(const char *iFileName);
void CloseFile();
void ComputeViewMap();
void ComputeSteerableViewMap();
void saveSteerableViewMapImages();
void toggleEdgeTesselationNature(Nature::EdgeNature iNature);
int DrawStrokes();
void ResetRenderCount();
blender::Render *RenderStrokes(blender::Render *re, bool render);
void SwapStyleModules(uint i1, uint i2);
void InsertStyleModule(uint index, const char *iFileName);
void InsertStyleModule(uint index, const char *iName, const char *iBuffer);
void InsertStyleModule(uint index, const char *iName, struct blender::Text *iText);
void AddStyleModule(const char *iFileName);
void RemoveStyleModule(uint index);
void ReloadStyleModule(uint index, const char *iFileName);
void Clear();
void ClearRootNode();
void DeleteWingedEdge();
void DeleteViewMap(bool freeCache = false);
void toggleLayer(uint index, bool iDisplay);
void setModified(uint index, bool iMod);
void resetModified(bool iMod = false);
void updateCausalStyleModules(uint index);
void displayDensityCurves(int x, int y);
ViewEdge *SelectViewEdge(real x, real y);
FEdge *SelectFEdge(real x, real y);
NodeGroup *BuildRep(vector<ViewEdge *>::iterator vedges_begin,
vector<ViewEdge *>::iterator vedges_end);
#if 0
NodeGroup *debugNode()
{
return _DebugNode;
}
AppView *view()
{
return _pView;
}
NodeGroup *debugScene()
{
return _DebugNode;
}
Grid &grid()
{
return _Grid;
}
#endif
void toggleVisibilityAlgo();
void setVisibilityAlgo(int algo);
int getVisibilityAlgo();
void setViewMapCache(bool iBool);
bool getViewMapCache() const;
void setQuantitativeInvisibility(bool iBool); // if true, we compute quantitativeInvisibility
bool getQuantitativeInvisibility() const;
void setFaceSmoothness(bool iBool);
bool getFaceSmoothness() const;
void setComputeRidgesAndValleysFlag(bool b);
bool getComputeRidgesAndValleysFlag() const;
void setComputeSuggestiveContoursFlag(bool b);
bool getComputeSuggestiveContoursFlag() const;
void setComputeMaterialBoundariesFlag(bool b);
bool getComputeMaterialBoundariesFlag() const;
void setComputeSteerableViewMapFlag(bool iBool);
bool getComputeSteerableViewMapFlag() const;
void setCreaseAngle(float angle)
{
_creaseAngle = angle;
}
float getCreaseAngle() const
{
return _creaseAngle;
}
void setSphereRadius(float s)
{
_sphereRadius = s;
}
float getSphereRadius() const
{
return _sphereRadius;
}
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
{
_suggestiveContourKrDerivativeEpsilon = dkr;
}
float getSuggestiveContourKrDerivativeEpsilon() const
{
return _suggestiveContourKrDerivativeEpsilon;
}
void setModelsDir(const string &dir);
string getModelsDir() const;
void setModulesDir(const string &dir);
string getModulesDir() const;
bool hitViewMapCache();
void resetInterpreter();
public:
// Viewmap data structure
ViewMap *_ViewMap;
// Canvas
AppCanvas *_Canvas;
private:
// Main Window:
// AppMainWindow *_pMainWindow;
// List of models currently loaded
vector<string> _ListOfModels;
// Current directories
// ConfigIO* _current_dirs;
// View
// 3D
AppView *_pView;
// 2D
#if 0
Viewer2DWindow *_pView2DWindow;
Viewer2D *_pView2D;
#endif
RenderMonitor *_pRenderMonitor;
// Model
// Drawing Structure
NodeGroup *_RootNode;
// Winged-Edge structure
WingedEdge *_winged_edge;
#if 0
// Silhouette structure:
std::vector<SShape *> _SShapes;
NodeGroup *_SRoot;
// Silhouette
NodeGroup *_SilhouetteNode;
NodeGroup *_ProjectedSilhouette;
NodeGroup *_VisibleProjectedSilhouette;
// more Debug info
NodeGroup *_DebugNode;
#endif
// debug
// NodeUser<ViewMap> *_ViewMapNode; // FIXME
// Chronometer:
Chronometer _Chrono;
// Progress Bar
ProgressBar *_ProgressBar;
// edges tesselation nature
int _edgeTesselationNature;
FastGrid _Grid;
// HashGrid _Grid;
BBox<Vec3r> _Scene3dBBox;
uint _SceneNumFaces;
#if 0
real _minEdgeSize;
#endif
real _EPSILON;
real _bboxDiag;
int _render_count;
// AppStyleWindow *_pStyleWindow;
// AppOptionsWindow *_pOptionsWindow;
// AppDensityCurvesWindow *_pDensityCurvesWindow;
ViewMapBuilder::visibility_algo _VisibilityAlgo;
// Script Interpreter
Interpreter *_inter;
string _help_index;
string _browser_cmd;
bool _EnableViewMapCache;
bool _EnableQI;
bool _EnableFaceSmoothness;
bool _ComputeRidges;
bool _ComputeSuggestive;
bool _ComputeMaterialBoundaries;
float _creaseAngle;
float _sphereRadius;
float _suggestiveContourKrDerivativeEpsilon;
bool _ComputeSteerableViewMap;
FEdgeXDetector edgeDetector;
SceneHash sceneHashFunc;
real prevSceneHash;
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Controller")
};
extern Controller *g_pController;
} /* namespace Freestyle */