Blender V5.3
AppView.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10#include <iostream>
11
12#include "AppConfig.h"
13#include "AppView.h"
14#include "Controller.h"
15
20#include "../stroke/Canvas.h"
23#include "../view_map/ViewMap.h"
24
26
27#include "IMB_imbuf.hh"
28#include "IMB_imbuf_types.hh"
29
30#if 1 // FRS_antialiasing
31# include "BKE_global.hh"
32# include "DNA_scene_types.h"
33#endif
34
35#include "FRS_freestyle.h"
36
37namespace Freestyle {
38
80
82{
83 /*int ref =*//* UNUSED */ _RootNode.destroy();
84
86 /*ref =*//* UNUSED */ _p2DNode.destroy();
87}
88
90{
92
94 v -= 0.5 * (bbox.getMin() + bbox.getMax());
95
96 return v.norm();
97}
98
100{
102 Vec3r u = bbox.getMin();
103 Vec3r v = bbox.getMax();
104 Vec3r cameraCenter(UNPACK3(blender::g_freestyle.viewpoint));
105
106 Vec3r w1(u[0], u[1], u[2]);
107 Vec3r w2(v[0], u[1], u[2]);
108 Vec3r w3(u[0], v[1], u[2]);
109 Vec3r w4(v[0], v[1], u[2]);
110 Vec3r w5(u[0], u[1], v[2]);
111 Vec3r w6(v[0], u[1], v[2]);
112 Vec3r w7(u[0], v[1], v[2]);
113 Vec3r w8(v[0], v[1], v[2]);
114
115 real _znear = std::min({(w1 - cameraCenter).norm(),
116 (w2 - cameraCenter).norm(),
117 (w3 - cameraCenter).norm(),
118 (w4 - cameraCenter).norm(),
119 (w5 - cameraCenter).norm(),
120 (w6 - cameraCenter).norm(),
121 (w7 - cameraCenter).norm(),
122 (w8 - cameraCenter).norm()});
123
124 return std::max(_znear, 0.001);
125}
126
128{
130 Vec3r u = bbox.getMin();
131 Vec3r v = bbox.getMax();
132 Vec3r cameraCenter(UNPACK3(blender::g_freestyle.viewpoint));
133
134 Vec3r w1(u[0], u[1], u[2]);
135 Vec3r w2(v[0], u[1], u[2]);
136 Vec3r w3(u[0], v[1], u[2]);
137 Vec3r w4(v[0], v[1], u[2]);
138 Vec3r w5(u[0], u[1], v[2]);
139 Vec3r w6(v[0], u[1], v[2]);
140 Vec3r w7(u[0], v[1], v[2]);
141 Vec3r w8(v[0], v[1], v[2]);
142
143 real _zfar = std::max({(w1 - cameraCenter).norm(),
144 (w2 - cameraCenter).norm(),
145 (w3 - cameraCenter).norm(),
146 (w4 - cameraCenter).norm(),
147 (w5 - cameraCenter).norm(),
148 (w6 - cameraCenter).norm(),
149 (w7 - cameraCenter).norm(),
150 (w8 - cameraCenter).norm()});
151
152 return _zfar;
153}
154
156{
157 real Near = std::max(0.1, (real)(-2.0f * _maxAbs + distanceToSceneCenter()));
158 return Near;
159}
160
161} /* namespace Freestyle */
Configuration file.
#define DEG2RADF(_deg)
Class to define a canvas designed to draw style modules.
The spinal tap of the system.
Class to define the representation of 3D Line.
Class to represent a light node.
Class to build a shape node. It contains a Rep, which is the shape geometry.
Classes to define a silhouette structure.
String utilities.
Class to define the representation of a vertex for displaying purpose.
Classes to define a View Map (ViewVertex, ViewEdge, etc.).
#define UNPACK3(a)
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Definition btVector3.h:263
real distanceToSceneCenter()
Definition AppView.cpp:89
AppView(const char *iName=0)
Definition AppView.cpp:39
NodeGroup _Light
Definition AppView.h:241
virtual ~AppView()
Definition AppView.cpp:81
NodeDrawingStyle * _ModelRootNode
Definition AppView.h:237
NodeDrawingStyle * _DebugRootNode
Definition AppView.h:239
int rabs(int x)
Definition AppView.h:223
NodeDrawingStyle * _p2DSelectionNode
Definition AppView.h:252
NodeGroup _p2DNode
Definition AppView.h:251
NodeGroup _RootNode
Definition AppView.h:236
NodeDrawingStyle * _SilhouetteRootNode
Definition AppView.h:238
const Point & getMin() const
Definition BBox.h:67
const Point & getMax() const
Definition BBox.h:72
void setPointSize(const float iPointSize)
void setStyle(const DrawingStyle::STYLE iStyle)
void setLineWidth(const float iLineWidth)
void setLightingEnabled(const bool iEnableLighting)
virtual void AddChild(Node *iChild)
Definition NodeGroup.cpp:16
virtual int destroy()
Definition NodeGroup.cpp:26
virtual const BBox< Vec3r > & bbox() const
Definition Node.h:51
VecMat::Vec3< real > Vec3r
Definition Geom.h:30
inherits from class Rep
Definition AppCanvas.cpp:20
double real
Definition Precision.h:14
struct FreestyleGlobals g_freestyle