forked from bartvdbraak/blender
New options for specifying unit line thickness.
The Post Processing tab in the Render buttons has new Line Thickness options for defining unit line thickness in two different modes as follows: 1. Absolute mode: The unit line thickness is given by a user-specified number in units of pixels. The default value is 1. 2. Relative mode: The unit line thickness is scaled by the proportion of the present vertical image resolution to 480 pixels. For instance, the unit line thickness is 1 with the image height set to 480, 1.5 with 720, and 2 with 960.
This commit is contained in:
parent
826a09300a
commit
5f02b167d1
@ -946,8 +946,17 @@ class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
|
||||
layout.separator()
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.prop(rd, "use_freestyle", text="Freestyle")
|
||||
sub = col.column()
|
||||
sub.label(text="Line Thickness:")
|
||||
sub.active = rd.use_freestyle
|
||||
sub.row().prop(rd, "line_thickness_mode", expand=True)
|
||||
subrow = sub.row()
|
||||
subrow.active = (rd.line_thickness_mode == "ABSOLUTE")
|
||||
subrow.prop(rd, "unit_line_thickness")
|
||||
|
||||
|
||||
class RENDER_PT_stamp(RenderButtonsPanel, Panel):
|
||||
bl_label = "Stamp"
|
||||
|
@ -13558,6 +13558,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
FreestyleLineStyle *linestyle;
|
||||
|
||||
for(sce = main->scene.first; sce; sce = sce->id.next) {
|
||||
if (sce->r.line_thickness_mode == 0) {
|
||||
sce->r.line_thickness_mode= R_LINE_THICKNESS_ABSOLUTE;
|
||||
sce->r.unit_line_thickness= 1.f;
|
||||
}
|
||||
for(srl= sce->r.layers.first; srl; srl= srl->next) {
|
||||
if (srl->freestyleConfig.mode == 0)
|
||||
srl->freestyleConfig.mode= FREESTYLE_CONTROL_EDITOR_MODE;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "../stroke/StrokeRenderer.h"
|
||||
#include "AppCanvas.h"
|
||||
#include "AppConfig.h"
|
||||
#include "../stroke/StyleModule.h"
|
||||
|
||||
#include "../system/StringUtils.h"
|
||||
|
||||
@ -73,6 +74,11 @@ BBox<Vec2i> AppCanvas::border() const
|
||||
return _pViewer->border();
|
||||
}
|
||||
|
||||
float AppCanvas::thickness() const
|
||||
{
|
||||
return _pViewer->thickness();
|
||||
}
|
||||
|
||||
BBox<Vec3r> AppCanvas::scene3DBBox() const
|
||||
{
|
||||
return _pViewer->scene3DBBox();
|
||||
@ -100,7 +106,12 @@ void AppCanvas::init()
|
||||
|
||||
void AppCanvas::postDraw()
|
||||
{
|
||||
Canvas::postDraw();
|
||||
for (unsigned i = 0; i < _StyleModules.size(); i++) {
|
||||
if(!_StyleModules[i]->getDisplayed() || !_Layers[i])
|
||||
continue;
|
||||
_Layers[i]->ScaleThickness(thickness());
|
||||
}
|
||||
Canvas::postDraw();
|
||||
}
|
||||
|
||||
void AppCanvas::Erase()
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
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;}
|
||||
|
@ -30,15 +30,18 @@ public:
|
||||
inline unsigned int width() { return _width; }
|
||||
inline unsigned int height() { return _height; }
|
||||
inline BBox<Vec2i> border() { return _border; }
|
||||
inline float thickness() { return _thickness; }
|
||||
inline void setWidth( unsigned int width ) { _width = width; }
|
||||
inline void setHeight( unsigned int 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:
|
||||
unsigned int _width, _height;
|
||||
BBox<Vec2i> _border;
|
||||
float _thickness;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -107,6 +107,16 @@ extern "C" {
|
||||
int xmax = re->disprect.xmax;
|
||||
int ymax = re->disprect.ymax;
|
||||
|
||||
float thickness = 1.f;
|
||||
switch (re->r.line_thickness_mode) {
|
||||
case R_LINE_THICKNESS_ABSOLUTE:
|
||||
thickness = re->r.unit_line_thickness * (re->r.size / 100.f);
|
||||
break;
|
||||
case R_LINE_THICKNESS_RELATIVE:
|
||||
thickness = height / 480.f;
|
||||
break;
|
||||
}
|
||||
|
||||
freestyle_viewport[0] = freestyle_viewport[1] = 0;
|
||||
freestyle_viewport[2] = width;
|
||||
freestyle_viewport[3] = height;
|
||||
@ -114,12 +124,14 @@ extern "C" {
|
||||
view->setWidth( width );
|
||||
view->setHeight( height );
|
||||
view->setBorder( xmin, ymin, xmax, ymax );
|
||||
view->setThickness( thickness );
|
||||
|
||||
cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl;
|
||||
cout << "Width : " << width << endl;
|
||||
cout << "Height : " << height << endl;
|
||||
if (re->r.mode & R_BORDER)
|
||||
cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")" << endl;
|
||||
cout << "Unit line thickness : " << thickness << " pixel(s)" << endl;
|
||||
}
|
||||
|
||||
static void init_camera(Render* re){
|
||||
|
@ -746,6 +746,17 @@ Interface0DIterator Stroke::pointsEnd(float t) {
|
||||
return verticesEnd();
|
||||
}
|
||||
|
||||
void Stroke::ScaleThickness(float iFactor)
|
||||
{
|
||||
for(vertex_container::iterator it=_Vertices.begin(), itend=_Vertices.end();
|
||||
it!=itend;
|
||||
++it)
|
||||
{
|
||||
StrokeAttribute& attr = (*it)->attribute();
|
||||
attr.setThickness(iFactor * attr.getThicknessR(), iFactor * attr.getThicknessL());
|
||||
}
|
||||
}
|
||||
|
||||
void Stroke::Render(const StrokeRenderer *iRenderer)
|
||||
{
|
||||
if(!_rep)
|
||||
|
@ -470,6 +470,7 @@ public:
|
||||
void UpdateLength();
|
||||
|
||||
/* Render method */
|
||||
void ScaleThickness(float iFactor);
|
||||
void Render(const StrokeRenderer *iRenderer );
|
||||
void RenderBasic(const StrokeRenderer *iRenderer );
|
||||
|
||||
|
@ -28,6 +28,15 @@ StrokeLayer::~StrokeLayer()
|
||||
clear();
|
||||
}
|
||||
|
||||
void StrokeLayer::ScaleThickness(float iFactor)
|
||||
{
|
||||
for(StrokeLayer::stroke_container::iterator s=_strokes.begin(), send=_strokes.end();
|
||||
s!=send;
|
||||
++s){
|
||||
(*s)->ScaleThickness(iFactor);
|
||||
}
|
||||
}
|
||||
|
||||
void StrokeLayer::Render(const StrokeRenderer *iRenderer )
|
||||
{
|
||||
for(StrokeLayer::stroke_container::iterator s=_strokes.begin(), send=_strokes.end();
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
virtual ~StrokeLayer() ;
|
||||
|
||||
/*! Render method */
|
||||
void ScaleThickness(float iFactor);
|
||||
void Render(const StrokeRenderer *iRenderer );
|
||||
void RenderBasic(const StrokeRenderer *iRenderer );
|
||||
|
||||
|
@ -526,6 +526,10 @@ typedef struct RenderData {
|
||||
float pad2;
|
||||
struct Text *dometext DNA_DEPRECATED; // XXX deprecated since 2.5
|
||||
|
||||
/* Freestyle line thickness options */
|
||||
int line_thickness_mode;
|
||||
float unit_line_thickness; /* in pixels */
|
||||
|
||||
/* render engine */
|
||||
char engine[32];
|
||||
} RenderData;
|
||||
@ -1278,6 +1282,10 @@ typedef struct Scene {
|
||||
/* simplify_flag */
|
||||
#define R_SIMPLE_NO_TRIANGULATE 1
|
||||
|
||||
/* line_thickness_mode */
|
||||
#define R_LINE_THICKNESS_ABSOLUTE 1
|
||||
#define R_LINE_THICKNESS_RELATIVE 2
|
||||
|
||||
/* sequencer seq_prev_type seq_rend_type */
|
||||
|
||||
|
||||
|
@ -3648,6 +3648,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
|
||||
{0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static EnumPropertyItem freestyle_thickness_items[] = {
|
||||
{R_LINE_THICKNESS_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Specify unit line thickness in pixels"},
|
||||
{R_LINE_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative", "Unit line thickness is scaled by the proportion of the present vertical image resolution to 480 pixels"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
rna_def_scene_ffmpeg_settings(brna);
|
||||
#ifdef WITH_QUICKTIME
|
||||
rna_def_scene_quicktime_settings(brna);
|
||||
@ -4319,6 +4324,17 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE);
|
||||
RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated");
|
||||
|
||||
/* Freestyle line thickness options */
|
||||
prop = RNA_def_property(srna, "line_thickness_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "line_thickness_mode");
|
||||
RNA_def_property_enum_items(prop, freestyle_thickness_items);
|
||||
RNA_def_property_ui_text(prop, "Line Thickness Mode", "Line thickness mode for Freestyle line drawing");
|
||||
|
||||
prop = RNA_def_property(srna, "unit_line_thickness", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "unit_line_thickness");
|
||||
RNA_def_property_range(prop, 0.f, 10000.f);
|
||||
RNA_def_property_ui_text(prop, "Unit Line Thickness", "Unit line thickness in pixels");
|
||||
|
||||
/* Scene API */
|
||||
RNA_api_scene_render(srna);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user