Update with Current OpenToonz changes as of 8-12-20 (#119)

* add multi arc mockup

* implement mutli arc

* add join and smooth option

* reset multiarc and arc when deactivated

* create self loop if the last point is the same as the first

* make join option in multiarc consistent with tape tool

* fix a bug where thickness don't affect mutliarc in vector level

* remove join option in geometric tool

* stop mutliarc after closing shape

* double click can also end multi arc

* fix a bug where multiArc will produce buggy stroke

* fix a bug where geometric tools is not deactivated

* add multiArc shortcut

* rewrite multiArc

* revert changes to tvectorimage

* add undo data for multiArc

* Paste as Copy Command for XSheet

* Remove unneeded code

* Bug fix

* prevent guide lines from jumping around in MultiArc

* make stroke color consistent in MultiArc

* remove color in MultiArc's undo data

* make color consistent in MultiArc with previous version

* Fix single image raster levels

* fix compilation error

* fix a bug where multiArc might generate bugged stroke

* Remove ICONV dep (#3304)

* fix crash on saving studio palette

* Move to Paste Special Menu

* Don't Set Fixed Width if Docking a Floating Panel

* Update how_to_build_win.md

New draft of pr for requested changes to windows build instructions.

* fix geometric tool multiarc smooth option

* fix level saving failure

* fix wrong warning after saving palette

* fix a bug where moving a control point while holding alt has unintended result

* fix travis-install (#3389)

* Fix assert debug crash in flipconsole.cpp

Fix crash when using the viewer controls in the console (debug)

* Redraw Audio Waveform

Fills the waveform rather than outlines it.

* fix undo data when drawing arc and mutliarc

* fix overwriting raster drawing palette (#3387)

* mode sensitive fx settings

* Create New Style Command Button (#3394)

* Create New Style Command Button

This PR creates a new button in the pallette editor that creates a new style.  Button is large and easy access for a faster and easier workflow.  Original code developed by Turtletooth for Tahoma.  Given permission to develop within Openoonz.

Co-Authored-By: Jeremy Bullock <turtletooth@users.noreply.github.com>

* Update paletteviewergui.cpp

Made changes to the PR per request by Shun.

* Fixed a space within the code that wasn't suppose to be there.

Co-authored-by: Jeremy Bullock <turtletooth@users.noreply.github.com>

* tahoma license (#3396)

* new style button optional

* fix loading pegbars (removing updateKeyframes)

* periodic random expression

* add fx in linear color space
this commit is based on source for the ComposeAdd plugin fx by DWANGO Co., Ltd.
in dwango_opentoonz_plugins and opentoonz_plugin_utility repositories.

* fractal noise iwa fx

* skip unnecessary icon invalidation

* fix frame range fill with tablet

* stop function editor to open by dbl clicking key

* Expanding the radius of the rotation handle.

This just changes when the cursor transforms into the rotation tool.

(cherry picked from commit 7722ae989bbdc6aa5cb48df7a4c08bae1fe6ea39)

Co-authored-by: pojienie <pojienie@gmail.com>
Co-authored-by: rim <11380091+rozhuk-im@users.noreply.github.com>
Co-authored-by: shun-iwasawa <shun.iwasawa@ghibli.jp>
Co-authored-by: Rodney <rodney.baker@gmail.com>
Co-authored-by: DoctorRyan <65507211+DoctorRyan@users.noreply.github.com>
Co-authored-by: shun-iwasawa <shun-iwasawa@users.noreply.github.com>
Co-authored-by: Kite <konero@users.noreply.github.com>
Co-authored-by: Jeremy Bullock <turtletooth@users.noreply.github.com>
Co-authored-by: DoctorRyan <doctorryan1969.gmail.com>
This commit is contained in:
Jeremy Bullock 2020-08-17 13:38:24 -06:00 committed by GitHub
parent cf4cd69494
commit dd1976c5d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 781 additions and 102 deletions

View file

@ -1319,6 +1319,28 @@
<item>"STD_iwa_GlareFx.noise_evolution" "Noise Evolution" </item> <item>"STD_iwa_GlareFx.noise_evolution" "Noise Evolution" </item>
<item>"STD_iwa_GlareFx.noise_offset" "Noise Offset" </item> <item>"STD_iwa_GlareFx.noise_offset" "Noise Offset" </item>
<item>"STD_iwa_FractalNoiseFx" "Fractal Noise Iwa" </item>
<item>"STD_iwa_FractalNoiseFx.fractalType" "Fractal Type" </item>
<item>"STD_iwa_FractalNoiseFx.noiseType" "Noise Type" </item>
<item>"STD_iwa_FractalNoiseFx.invert" "Invert" </item>
<item>"STD_iwa_FractalNoiseFx.rotation" "Rotation" </item>
<item>"STD_iwa_FractalNoiseFx.uniformScaling" "Uniform Scaling" </item>
<item>"STD_iwa_FractalNoiseFx.scale" "Scale" </item>
<item>"STD_iwa_FractalNoiseFx.scaleW" "Scale W" </item>
<item>"STD_iwa_FractalNoiseFx.scaleH" "Scale H" </item>
<item>"STD_iwa_FractalNoiseFx.offsetTurbulence" "Offset Turbulence" </item>
<item>"STD_iwa_FractalNoiseFx.perspectiveOffset" "Perspective Offset" </item>
<item>"STD_iwa_FractalNoiseFx.complexity" "Complexity" </item>
<item>"STD_iwa_FractalNoiseFx.subInfluence" "Sub Influence" </item>
<item>"STD_iwa_FractalNoiseFx.subScaling" "Sub Scaling" </item>
<item>"STD_iwa_FractalNoiseFx.subRotation" "Sub Rotation" </item>
<item>"STD_iwa_FractalNoiseFx.subOffset" "Sub Offset" </item>
<item>"STD_iwa_FractalNoiseFx.evolution" "Evolution" </item>
<item>"STD_iwa_FractalNoiseFx.cycleEvolution" "Cycle Evolution" </item>
<item>"STD_iwa_FractalNoiseFx.cycleEvolutionRange" "Cycle (in Evolution)" </item>
<item>"STD_iwa_FractalNoiseFx.dynamicIntensity" "Dynamic Intensity" </item>
<item>"STD_iwa_FractalNoiseFx.alphaRendering" "Alpha Rendering" </item>
<!------------------------------ Tiled Particles Iwa -------------------------------------------> <!------------------------------ Tiled Particles Iwa ------------------------------------------->
<item>STD_iwa_TiledParticlesFx "Tiled Particles Iwa" </item> <item>STD_iwa_TiledParticlesFx "Tiled Particles Iwa" </item>

View file

@ -0,0 +1,38 @@
<fxlayout>
<page name="Fractal Noise Iwa">
<control>fractalType</control>
<control>noiseType</control>
<control>invert</control>
<separator label="Transform"/>
<control>rotation</control>
<control>uniformScaling</control>
<vbox modeSensitive="uniformScaling" mode="1">
<control>scale</control>
</vbox>
<vbox modeSensitive="uniformScaling" mode="0">
<control>scaleW</control>
<control>scaleH</control>
</vbox>
<control>offsetTurbulence</control>
<control>perspectiveOffset</control>
<separator/>
<control>complexity</control>
<separator label="Sub Settings"/>
<control>subInfluence</control>
<control>subScaling</control>
<control>subRotation</control>
<control>subOffset</control>
<control>centerSubscale</control>
<separator label="Evolution Options"/>
<control>evolution</control>
<control>cycleEvolution</control>
<vbox modeSensitive="cycleEvolution" mode="1">
<control>cycleEvolutionRange</control>
</vbox>
<separator/>
<vbox modeSensitive="fractalType" mode="4,5">
<control>dynamicIntensity</control>
</vbox>
<control>alphaRendering</control>
</page>
</fxlayout>

View file

@ -143,6 +143,7 @@
STD_noiseFx STD_noiseFx
STD_iwa_PNPerspectiveFx STD_iwa_PNPerspectiveFx
STD_saltpepperNoiseFx STD_saltpepperNoiseFx
STD_iwa_FractalNoiseFx
</Noise> </Noise>
<Render> <Render>
STD_cloudsFx STD_cloudsFx

View file

@ -327,10 +327,10 @@ public:
} }
double compute(double vars[3]) const override { double compute(double vars[3]) const override {
double s = (m_seed.get() != 0) ? m_seed->compute(vars) : 0; double s = (m_seed.get() != 0) ? m_seed->compute(vars) : 0;
double period = m_period->compute(vars); double period = m_period->compute(vars);
if (period == 0) period = 1; if (period == 0) period = 1;
double f = m_arg->compute(vars); double f = m_arg->compute(vars);
double f0 = period * std::floor(f / period); double f0 = period * std::floor(f / period);
double f1 = period * (std::floor(f / period) + 1); double f1 = period * (std::floor(f / period) + 1);
@ -736,11 +736,11 @@ public:
while (k > 0) nodes[--k] = popNode(stack); while (k > 0) nodes[--k] = popNode(stack);
} else { } else {
while (k > 1) nodes[--k] = popNode(stack); while (k > 1) nodes[--k] = popNode(stack);
nodes[0] = new VariableNode(calc, CalculatorNode::FRAME); nodes[0] = new VariableNode(calc, CalculatorNode::FRAME);
} }
// add default values // add default values
for (int i = 0; i < m; i++) for (int i = 0; i < m; i++)
nodes[n - m + i] = new NumberNode(calc, m_optionalArgDefaults[i]); nodes[n - m + i] = new NumberNode(calc, m_optionalArgDefaults[i]);
} }
}; };
@ -1159,7 +1159,7 @@ public:
double operator()(double x, double length, double height) const { double operator()(double x, double length, double height) const {
if (length <= 0.0) return 0.0; if (length <= 0.0) return 0.0;
if (height <= 0.0) height = length; if (height <= 0.0) height = length;
double q = x / length; double q = x / length;
return height * (q - floor(q)); return height * (q - floor(q));
} }
}; };

View file

@ -80,6 +80,7 @@ set(HEADERS
iwa_spingradientfx.h iwa_spingradientfx.h
iwa_lineargradientfx.h iwa_lineargradientfx.h
iwa_glarefx.h iwa_glarefx.h
iwa_fractalnoisefx.h
) )
set(SOURCES set(SOURCES
@ -266,6 +267,7 @@ set(SOURCES
iwa_spingradientfx.cpp iwa_spingradientfx.cpp
iwa_lineargradientfx.cpp iwa_lineargradientfx.cpp
iwa_glarefx.cpp iwa_glarefx.cpp
iwa_fractalnoisefx.cpp
) )
set(OBJCSOURCES set(OBJCSOURCES

View file

@ -125,7 +125,7 @@ public:
/* /*
upComputesWholeTile Screen, Min, Blendでtrueにして使用している upComputesWholeTile Screen, Min, Blendでtrueにして使用している
*/ */
); );
}; };
FX_PLUGIN_IDENTIFIER(ino_blend_add, "inoAddFx"); FX_PLUGIN_IDENTIFIER(ino_blend_add, "inoAddFx");
//------------------------------------------------------------ //------------------------------------------------------------
@ -157,7 +157,7 @@ fxをreplaceすると、
m_refernce --> m_down(=port1) m_refernce --> m_down(=port1)
*/ */
const bool up_is = (this->m_up.isConnected() && const bool up_is = (this->m_up.isConnected() &&
this->m_up.getFx()->getTimeRegion().contains(frame)); this->m_up.getFx()->getTimeRegion().contains(frame));
const bool down_is = (this->m_down.isConnected() && const bool down_is = (this->m_down.isConnected() &&
this->m_down.getFx()->getTimeRegion().contains(frame)); this->m_down.getFx()->getTimeRegion().contains(frame));
@ -201,7 +201,7 @@ fxをreplaceすると、
tround(upBBox.getLx()) // getLx() = "x1>=x0?x1-x0:0" tround(upBBox.getLx()) // getLx() = "x1>=x0?x1-x0:0"
, ,
tround(upBBox.getLy()) // getLy() = "y1>=y0?y1-y0:0" tround(upBBox.getLy()) // getLy() = "y1>=y0?y1-y0:0"
); );
if ((upSize.lx <= 0) || (upSize.ly <= 0)) { if ((upSize.lx <= 0) || (upSize.ly <= 0)) {
return; return;
} }
@ -230,7 +230,7 @@ fxをreplaceすると、
void ino_blend_add::dryComputeUpAndDown(TRectD &rect, double frame, void ino_blend_add::dryComputeUpAndDown(TRectD &rect, double frame,
const TRenderSettings &rs, const TRenderSettings &rs,
bool upComputesWholeTile) { bool upComputesWholeTile) {
const bool up_is = (this->m_up.isConnected() && const bool up_is = (this->m_up.isConnected() &&
this->m_up.getFx()->getTimeRegion().contains(frame)); this->m_up.getFx()->getTimeRegion().contains(frame));
const bool down_is = (this->m_down.isConnected() && const bool down_is = (this->m_down.isConnected() &&
this->m_down.getFx()->getTimeRegion().contains(frame)); this->m_down.getFx()->getTimeRegion().contains(frame));

View file

@ -0,0 +1,474 @@
#include "iwa_fractalnoisefx.h"
#include "iwa_noise1234.h"
#include "tparamuiconcept.h"
namespace {
// convert sRGB color space to power space
template <typename T = double>
inline T to_linear_color_space(T nonlinear_color, T exposure, T gamma) {
// return -std::log(T(1) - std::pow(nonlinear_color, gamma)) / exposure;
return std::pow(nonlinear_color, gamma) / exposure;
}
// convert power space to sRGB color space
template <typename T = double>
inline T to_nonlinear_color_space(T linear_color, T exposure, T gamma) {
// return std::pow(T(1) - std::exp(-exposure * linear_color), T(1) / gamma);
return std::pow(exposure * linear_color, T(1) / gamma);
}
inline double hardlight(const double *dn, const double *up) {
if ((*up) < 0.5)
return (*up) * (*dn) * 2.0;
else
return 1.0 - 2.0 * (1.0 - (*up)) * (1.0 - (*dn));
}
template <class T = double>
inline const T &clamp(const T &v, const T &lo, const T &hi) {
assert(!(hi < lo));
return (v < lo) ? lo : (hi < v) ? hi : v;
}
const double turbulentGamma = 2.2;
// magic number to offset evolution between generations
const double evolutionOffsetStep = 19.82;
} // namespace
//------------------------------------------------------------------
Iwa_FractalNoiseFx::Iwa_FractalNoiseFx()
: m_fractalType(new TIntEnumParam(Basic, "Basic"))
, m_noiseType(new TIntEnumParam(Block, "Block"))
, m_invert(false)
, m_rotation(0.0)
, m_uniformScaling(true)
, m_scale(100.0)
, m_scaleW(100.0)
, m_scaleH(100.0)
, m_offsetTurbulence(TPointD(0.0, 0.0))
, m_perspectiveOffset(false)
, m_complexity(6.0)
, m_subInfluence(70.0)
, m_subScaling(56.0)
, m_subRotation(0.0)
, m_subOffset(TPointD(0.0, 0.0))
///, m_centerSubscale(false)
, m_evolution(0.0)
, m_cycleEvolution(false)
, m_cycleEvolutionRange(1.0)
///, m_randomSeed(0)
, m_dynamicIntensity(1.0)
, m_alphaRendering(false) {
m_fractalType->addItem(TurbulentSmooth, "Turbulent Smooth");
m_fractalType->addItem(TurbulentBasic, "Turbulent Basic");
m_fractalType->addItem(TurbulentSharp, "Turbulent Sharp");
m_fractalType->addItem(Dynamic, "Dynamic");
m_fractalType->addItem(DynamicTwist, "Dynamic Twist");
m_fractalType->addItem(Max, "Max");
m_fractalType->addItem(Rocky, "Rocky");
m_noiseType->addItem(Smooth, "Smooth");
m_noiseType->setValue(Smooth);
m_rotation->setMeasureName("angle");
m_rotation->setValueRange(-360.0, 360.0);
m_scale->setMeasureName("fxLength");
m_scale->setValueRange(20.0, 600.0);
m_scaleW->setMeasureName("fxLength");
m_scaleW->setValueRange(20.0, 600.0);
m_scaleH->setMeasureName("fxLength");
m_scaleH->setValueRange(20.0, 600.0);
m_offsetTurbulence->getX()->setMeasureName("fxLength");
m_offsetTurbulence->getY()->setMeasureName("fxLength");
m_complexity->setValueRange(1.0, 10.0);
m_subInfluence->setValueRange(25.0, 100.0);
m_subScaling->setValueRange(25.0, 100.0);
m_subRotation->setMeasureName("angle");
m_subRotation->setValueRange(-360.0, 360.0);
m_subOffset->getX()->setMeasureName("fxLength");
m_subOffset->getY()->setMeasureName("fxLength");
m_evolution->setValueRange(-100.0, 100.0);
m_cycleEvolutionRange->setValueRange(0.1, 30.0);
m_dynamicIntensity->setValueRange(-10.0, 10.0);
bindParam(this, "fractalType", m_fractalType);
bindParam(this, "noiseType", m_noiseType);
bindParam(this, "invert", m_invert);
bindParam(this, "rotation", m_rotation);
bindParam(this, "uniformScaling", m_uniformScaling);
bindParam(this, "scale", m_scale);
bindParam(this, "scaleW", m_scaleW);
bindParam(this, "scaleH", m_scaleH);
bindParam(this, "offsetTurbulence", m_offsetTurbulence);
bindParam(this, "perspectiveOffset", m_perspectiveOffset);
bindParam(this, "complexity", m_complexity);
bindParam(this, "subInfluence", m_subInfluence);
bindParam(this, "subScaling", m_subScaling);
bindParam(this, "subRotation", m_subRotation);
bindParam(this, "subOffset", m_subOffset);
/// bindParam(this, "centerSubscale", m_centerSubscale);
bindParam(this, "evolution", m_evolution);
bindParam(this, "cycleEvolution", m_cycleEvolution);
bindParam(this, "cycleEvolutionRange", m_cycleEvolutionRange);
/// bindParam(this, "randomSeed", m_randomSeed);
bindParam(this, "dynamicIntensity", m_dynamicIntensity);
bindParam(this, "alphaRendering", m_alphaRendering);
}
//------------------------------------------------------------------
bool Iwa_FractalNoiseFx::doGetBBox(double frame, TRectD &bBox,
const TRenderSettings &ri) {
bBox = TConsts::infiniteRectD;
return true;
}
//------------------------------------------------------------------
void Iwa_FractalNoiseFx::doCompute(TTile &tile, double frame,
const TRenderSettings &ri) {
// obtain current parameters
FNParam param;
obtainParams(param, frame, ri.m_affine);
Noise1234 pn;
TDimension outDim = tile.getRaster()->getSize();
// allocate buffer for accumulating the noise patterns
TRasterGR8P out_buf_ras = TRasterGR8P(outDim.lx * sizeof(double), outDim.ly);
out_buf_ras->clear();
out_buf_ras->lock();
double *out_buf = (double *)out_buf_ras->getRawData();
// allocate buffer for storing the noise pattern of each generation
TRasterGR8P work_buf_ras = TRasterGR8P(outDim.lx * sizeof(double), outDim.ly);
work_buf_ras->lock();
double *work_buf = (double *)work_buf_ras->getRawData();
// affine transformations
TAffine globalAff = TTranslation(-tile.m_pos) * ri.m_affine;
TAffine parentOffsetAff = TTranslation(param.offsetTurbulence);
TAffine parentAff =
TScale(param.scale.lx, param.scale.ly) * TRotation(-param.rotation);
TAffine subAff = TTranslation(param.subOffset) * TScale(param.subScaling) *
TRotation(-param.subRotation);
TAffine offsetAff =
TTranslation((double)outDim.lx * 0.5, (double)outDim.ly * 0.5);
TAffine genAff;
// for cyclic evolution, rotate the sample position in ZW space instead of
// using the periodic noise in Z space so that it can cycle in arbitral
// period.
double evolution_z = param.evolution;
TPointD evolution_zw;
if (param.cycleEvolution) {
double theta = 2.0 * M_PI * param.evolution / param.cycleEvolutionRange;
double d = param.cycleEvolutionRange / (2.0 * M_PI);
evolution_zw.x = d * cos(theta);
evolution_zw.y = d * sin(theta);
}
int genCount = (int)std::ceil(param.complexity);
// accumulate base noise pattern for each generation
for (int gen = 0; gen < genCount; gen++) {
// affine transformation for the current generation
TAffine currentAff =
(globalAff * parentOffsetAff * parentAff * genAff * offsetAff).inv();
// scale of the current pattern ( used for the Dynamic / Dynamic Twist
// offset )
double scale = sqrt(std::abs(currentAff.det()));
// for each pixel
double *buf_p = work_buf;
for (int y = 0; y < outDim.ly; y++) {
for (int x = 0; x < outDim.lx; x++, buf_p++) {
// obtain sampling position
// For Dynamic and Dynamic Twist patterns, the position offsets using
// gradient / rotation of the parent pattern
TPointD samplePos =
getSamplePos(x, y, outDim, out_buf, gen, scale, param);
// multiply affine transformation
samplePos = currentAff * samplePos;
// adjust postion for the block pattern
if (param.noiseType == Block)
samplePos = TPointD(std::floor(samplePos.x) + 0.5,
std::floor(samplePos.y) + 0.5);
// calculate the base noise
if (param.cycleEvolution)
*buf_p = (pn.noise(samplePos.x, samplePos.y, evolution_zw.x,
evolution_zw.y) +
1.0) *
0.5;
else
*buf_p =
(pn.noise(samplePos.x, samplePos.y, evolution_z) + 1.0) * 0.5;
// convert the noise
convert(buf_p, param);
}
}
// just copy the values for the first generation
if (gen == 0) {
memcpy(out_buf, work_buf, outDim.lx * outDim.ly * sizeof(double));
} else {
// intensity of the last generation will take the fraction part of
// complexity
double genIntensity = std::min(1.0, param.complexity - (double)gen);
// influence of the current generation
double influence =
genIntensity * std::pow(param.subInfluence, (double)gen);
// composite the base noise pattern
buf_p = work_buf;
double *out_p = out_buf;
for (int i = 0; i < outDim.lx * outDim.ly; i++, buf_p++, out_p++)
composite(out_p, buf_p, influence, param);
}
// update affine transformations (for the next generation loop)
genAff *= subAff;
// When the "Perspective Offset" option is ON, reduce the offset amount
// according to the sub scale
if (param.perspectiveOffset)
parentOffsetAff = TScale(param.subScaling) *
TRotation(-param.subRotation) * parentOffsetAff *
TRotation(param.subRotation) *
TScale(1 / param.subScaling);
if (param.cycleEvolution)
evolution_zw.x += evolutionOffsetStep;
else
evolution_z += evolutionOffsetStep;
}
work_buf_ras->unlock();
// finalize pattern (coverting the color space)
if (param.fractalType == TurbulentSmooth ||
param.fractalType == TurbulentBasic ||
param.fractalType == TurbulentSharp) {
double *out_p = out_buf;
for (int i = 0; i < outDim.lx * outDim.ly; i++, out_p++)
finalize(out_p, param);
}
tile.getRaster()->clear();
// convert to RGB channel values
TRaster32P ras32 = (TRaster32P)tile.getRaster();
TRaster64P ras64 = (TRaster64P)tile.getRaster();
if (ras32)
outputRaster<TRaster32P, TPixel32>(ras32, out_buf, param);
else if (ras64)
outputRaster<TRaster64P, TPixel64>(ras64, out_buf, param);
out_buf_ras->unlock();
}
//------------------------------------------------------------------
// obtain current parameters
void Iwa_FractalNoiseFx::obtainParams(FNParam &param, const double frame,
const TAffine &aff) {
param.fractalType = (FractalType)m_fractalType->getValue();
param.noiseType = (NoiseType)m_noiseType->getValue();
param.invert = m_invert->getValue();
param.rotation = m_rotation->getValue(frame); // in degree, not radian
if (m_uniformScaling->getValue()) { // uniform case
double s = m_scale->getValue(frame);
param.scale = TDimensionD(s, s);
} else { // non-uniform case
param.scale.lx = m_scaleW->getValue(frame);
param.scale.ly = m_scaleH->getValue(frame);
}
assert(param.scale.lx != 0.0 && param.scale.ly != 0.0);
if (param.scale.lx == 0.0) param.scale.lx = 1e-8;
if (param.scale.ly == 0.0) param.scale.ly = 1e-8;
param.offsetTurbulence = m_offsetTurbulence->getValue(frame);
param.perspectiveOffset = m_perspectiveOffset->getValue();
param.complexity = m_complexity->getValue(frame);
if (param.complexity < 1.0)
param.complexity =
1.0; // at least the first generation is rendered in full opacity
param.subInfluence =
m_subInfluence->getValue(frame) / 100.0; // normalize to 0 - 1
param.subScaling =
m_subScaling->getValue(frame) / 100.0; // normalize to 0 - 1
param.subRotation = m_subRotation->getValue(frame); // in degree, not radian
param.subOffset = m_subOffset->getValue(frame);
param.evolution = m_evolution->getValue(frame);
param.cycleEvolution = m_cycleEvolution->getValue();
param.cycleEvolutionRange = m_cycleEvolutionRange->getValue(frame);
param.dynamicIntensity = m_dynamicIntensity->getValue(frame) * 10.0;
param.alphaRendering = m_alphaRendering->getValue();
}
//------------------------------------------------------------------
template <typename RASTER, typename PIXEL>
void Iwa_FractalNoiseFx::outputRaster(const RASTER outRas, double *out_buf,
const FNParam &param) {
TDimension dim = outRas->getSize();
double *buf_p = out_buf;
for (int j = 0; j < dim.ly; j++) {
PIXEL *pix = outRas->pixels(j);
for (int i = 0; i < dim.lx; i++, pix++, buf_p++) {
double val = (param.invert) ? 1.0 - (*buf_p) : (*buf_p);
val = clamp(val, 0.0, 1.0);
typename PIXEL::Channel chan = static_cast<typename PIXEL::Channel>(
val * (double)PIXEL::maxChannelValue);
pix->r = chan;
pix->g = chan;
pix->b = chan;
pix->m = (param.alphaRendering) ? chan : PIXEL::maxChannelValue;
}
}
}
//------------------------------------------------------------------
void Iwa_FractalNoiseFx::getParamUIs(TParamUIConcept *&concepts, int &length) {
concepts = new TParamUIConcept[length = 2];
concepts[0].m_type = TParamUIConcept::POINT;
concepts[0].m_label = "Offset Turbulence";
concepts[0].m_params.push_back(m_offsetTurbulence);
concepts[1].m_type = TParamUIConcept::POINT;
concepts[1].m_label = "Sub Offset";
concepts[1].m_params.push_back(m_subOffset);
}
//------------------------------------------------------------------
// For Dynamic and Dynamic Twist patterns, the position offsets using gradient /
// rotation of the parent pattern
TPointD Iwa_FractalNoiseFx::getSamplePos(int x, int y, const TDimension outDim,
const double *out_buf, const int gen,
const double scale,
const FNParam &param) {
// the position does not offset in the first generation
if (gen == 0 || param.dynamicIntensity == 0.0 ||
(param.fractalType != Dynamic && param.fractalType != DynamicTwist))
return TPointD((double)x, (double)y);
auto clampPos = [&](int x, int y) {
if (x < 0)
x = 0;
else if (x >= outDim.lx)
x = outDim.lx - 1;
if (y < 0)
y = 0;
else if (y >= outDim.ly)
y = outDim.ly - 1;
return TPoint(x, y);
};
auto val = [&](const TPoint &p) { return out_buf[p.y * outDim.lx + p.x]; };
int range = std::max(2, (int)(0.1 / scale));
TPoint left = clampPos(x - range, y);
TPoint right = clampPos(x + range, y);
TPoint down = clampPos(x, y - range);
TPoint up = clampPos(x, y + range);
double dif_x = param.dynamicIntensity * (1 / scale) *
(val(left) - val(right)) / (left.x - right.x);
double dif_y = param.dynamicIntensity * (1 / scale) * (val(up) - val(down)) /
(up.y - down.y);
if (param.fractalType == Dynamic)
return TPointD((double)x + dif_x, (double)y + dif_y); // gradient
else // Dynamic_twist
return TPointD((double)x + dif_y, (double)y - dif_x); // rotation
}
//------------------------------------------------------------------
// convert the noise
void Iwa_FractalNoiseFx::convert(double *buf, const FNParam &param) {
if (param.fractalType == Basic || param.fractalType == Dynamic ||
param.fractalType == DynamicTwist)
return;
switch (param.fractalType) {
case TurbulentSmooth:
*buf = std::pow(std::abs(*buf - 0.5), 2.0) * 3.75;
*buf = to_linear_color_space(*buf, 1.0, turbulentGamma);
break;
case TurbulentBasic:
*buf = std::pow(std::abs(*buf - 0.5), 1.62) * 4.454;
*buf = to_linear_color_space(*buf, 1.0, turbulentGamma);
break;
case TurbulentSharp:
*buf = std::pow(std::abs(*buf - 0.5), 0.725) * 1.77;
*buf = to_linear_color_space(*buf, 1.0, turbulentGamma);
break;
case Max:
*buf = std::abs(*buf - 0.5) * 1.96;
break;
case Rocky:
// convertion LUT for the range from 0.43 to 0.57, every 0.01
static double table[15] = {
0.25, 0.256658635, 0.275550218, 0.30569519, 0.345275591,
0.392513494, 0.440512, 0.5, 0.555085147, 0.607486506,
0.654724409, 0.69430481, 0.724449782, 0.743341365, 0.75};
if (*buf <= 0.43)
*buf = 0.25;
else if (*buf >= 0.57)
*buf = 0.75;
else {
int id = (int)std::floor(*buf * 100.0) - 43;
double t = *buf * 100.0 - (double)(id + 43);
// linear interpolation the LUT values
*buf = (1 - t) * table[id] + t * table[id + 1];
}
break;
}
}
//------------------------------------------------------------------
// composite the base noise pattern
void Iwa_FractalNoiseFx::composite(double *out, double *buf,
const double influence,
const FNParam &param) {
switch (param.fractalType) {
case Basic:
case Dynamic:
case DynamicTwist:
case Rocky: {
// hard light composition
double val = hardlight(out, buf);
*out = (1.0 - influence) * (*out) + influence * val;
break;
}
case TurbulentSmooth:
case TurbulentBasic:
case TurbulentSharp:
// add composition in the linear color space
*out += (*buf) * influence;
break;
case Max:
// max composition
*out = std::max(*out, influence * (*buf));
break;
default: {
double val = hardlight(out, buf);
*out = (1.0 - influence) * (*out) + influence * val;
break;
}
}
}
//------------------------------------------------------------------
// finalize pattern (coverting the color space)
void Iwa_FractalNoiseFx::finalize(double *out, const FNParam &param) {
assert(param.fractalType == TurbulentSmooth ||
param.fractalType == TurbulentBasic ||
param.fractalType == TurbulentSharp);
// TurbulentSmooth / TurbulentBasic / TurbulentSharp
*out = to_nonlinear_color_space(*out, 1.0, turbulentGamma);
}
FX_PLUGIN_IDENTIFIER(Iwa_FractalNoiseFx, "iwa_FractalNoiseFx");

View file

@ -0,0 +1,142 @@
#pragma once
//******************************************************************
// Iwa FractalNoise Fx
// An Fx emulating Fractal Noise effect in Adobe AfterEffect
//******************************************************************
#ifndef IWA_FRACTALNOISEFX_H
#define IWA_FRACTALNOISEFX_H
#include "tfxparam.h"
#include "tparamset.h"
#include "stdfx.h"
class Iwa_FractalNoiseFx final : public TStandardZeraryFx {
FX_PLUGIN_DECLARATION(Iwa_FractalNoiseFx)
enum FractalType {
Basic = 0,
TurbulentSmooth,
TurbulentBasic,
TurbulentSharp,
Dynamic,
DynamicTwist,
Max,
Rocky,
FractalTypeCount
};
enum NoiseType { Block = 0, Smooth, NoiseTypeCount };
struct FNParam {
FractalType fractalType;
NoiseType noiseType;
bool invert;
double rotation;
TDimensionD scale;
TPointD offsetTurbulence;
bool perspectiveOffset;
double complexity;
double subInfluence;
double subScaling;
double subRotation;
TPointD subOffset;
double evolution;
bool cycleEvolution;
double cycleEvolutionRange;
double dynamicIntensity;
bool alphaRendering;
};
protected:
// Fractal Type フラクタルの種類
TIntEnumParamP m_fractalType;
// Noise Type ノイズの種類
TIntEnumParamP m_noiseType;
// Invert 反転
TBoolParamP m_invert;
/// Contrast コントラスト
/// Brightness 明るさ
/// Overflow オーバーフロー
//- - - Transform トランスフォーム - - -
// Rotation 回転
TDoubleParamP m_rotation;
// Uniform Scaling 縦横比を固定
TBoolParamP m_uniformScaling;
// Scale スケール
TDoubleParamP m_scale;
// Scale Width スケールの幅
TDoubleParamP m_scaleW;
// Scale Height スケールの高さ
TDoubleParamP m_scaleH;
// Offset Turbulence 乱気流のオフセット
TPointParamP m_offsetTurbulence;
// Perspective Offset 遠近オフセット
TBoolParamP m_perspectiveOffset;
// Complexity 複雑度
TDoubleParamP m_complexity;
//- - - Sub Settings サブ設定 - - -
// Sub Influence サブ影響(%)
TDoubleParamP m_subInfluence;
// Sub Scaling サブスケール
TDoubleParamP m_subScaling;
// Sub Rotation サブ回転
TDoubleParamP m_subRotation;
// Sub Offset サブのオフセット
TPointParamP m_subOffset;
// Center Subscale サブスケールを中心
/// TBoolParamP m_centerSubscale;
// Evolution 展開
TDoubleParamP m_evolution;
//- - - Evolution Options 展開のオプション - - -
// Cycle Evolution サイクル展開
TBoolParamP m_cycleEvolution;
// Cycle (in Evolution) サイクル(周期)
TDoubleParamP m_cycleEvolutionRange;
/// Random Seed ランダムシード
/// Opacity 不透明度
/// Blending Mode 描画モード
// ダイナミックの度合い
TDoubleParamP m_dynamicIntensity;
// - - - additional parameters - - -
TBoolParamP m_alphaRendering;
public:
Iwa_FractalNoiseFx();
bool canHandle(const TRenderSettings &info, double frame) override {
return true;
}
bool doGetBBox(double frame, TRectD &bBox,
const TRenderSettings &ri) override;
void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
void obtainParams(FNParam &param, const double frame, const TAffine &aff);
template <typename RASTER, typename PIXEL>
void outputRaster(const RASTER outRas, double *out_buf, const FNParam &param);
void getParamUIs(TParamUIConcept *&concepts, int &length) override;
// For Dynamic and Dynamic Twist patterns, the position offsets using gradient
// / rotation of the parent pattern
TPointD getSamplePos(int x, int y, const TDimension outDim,
const double *out_buf, const int gen, const double scale,
const FNParam &param);
// convert the noise
void convert(double *buf, const FNParam &param);
// composite the base noise pattern
void composite(double *out, double *buf, const double influence,
const FNParam &param);
// finalize pattern (coverting the color space)
void finalize(double *out, const FNParam &param);
};
#endif

View file

@ -237,14 +237,12 @@ public:
void onAdd() override {} void onAdd() override {}
int getSize() const override { int getSize() const override {
int size1 = m_regionFillInformation int size1 = m_regionFillInformation ? m_regionFillInformation->capacity() *
? m_regionFillInformation->capacity() * sizeof(m_regionFillInformation)
sizeof(m_regionFillInformation) : 0;
: 0; int size2 = m_strokeFillInformation ? m_strokeFillInformation->capacity() *
int size2 = m_strokeFillInformation sizeof(m_strokeFillInformation)
? m_strokeFillInformation->capacity() * : 0;
sizeof(m_strokeFillInformation)
: 0;
return sizeof(*this) + size1 + size2 + 500; return sizeof(*this) + size1 + size2 + 500;
} }
@ -640,11 +638,10 @@ public:
} }
int getSize() const override { int getSize() const override {
int size = int size = m_selectingStroke ? m_selectingStroke->getControlPointCount() *
m_selectingStroke sizeof(TThickPoint) +
? m_selectingStroke->getControlPointCount() * sizeof(TThickPoint) + 100
100 : 0;
: 0;
return sizeof(*this) + return sizeof(*this) +
m_regionFillInformation->capacity() * m_regionFillInformation->capacity() *
sizeof(m_regionFillInformation) + sizeof(m_regionFillInformation) +
@ -870,7 +867,7 @@ void fillAreaWithUndo(const TImageP &img, const TRectD &area, TStroke *stroke,
vi->findRegions(); vi->findRegions();
std::vector<TFilledRegionInf> *regionFillInformation = 0; std::vector<TFilledRegionInf> *regionFillInformation = 0;
std::vector<std::pair<int, int>> *strokeFillInformation = 0; std::vector<std::pair<int, int>> *strokeFillInformation = 0;
if (colorType != LINES) { if (colorType != LINES) {
regionFillInformation = new std::vector<TFilledRegionInf>; regionFillInformation = new std::vector<TFilledRegionInf>;
@ -1648,9 +1645,9 @@ public:
{ {
double k = dy / dx; /*-- 直線の傾き --*/ double k = dy / dx; /*-- 直線の傾き --*/
/*--- roundでは負値のときにうまく繋がらない ---*/ /*--- roundでは負値のときにうまく繋がらない ---*/
int start = std::min((int)floor(m_startPosition.x + 0.5), int start = std::min((int)floor(m_startPosition.x + 0.5),
(int)floor(m_mousePosition.x + 0.5)); (int)floor(m_mousePosition.x + 0.5));
int end = std::max((int)floor(m_startPosition.x + 0.5), int end = std::max((int)floor(m_startPosition.x + 0.5),
(int)floor(m_mousePosition.x + 0.5)); (int)floor(m_mousePosition.x + 0.5));
double start_x = (m_startPosition.x < m_mousePosition.x) double start_x = (m_startPosition.x < m_mousePosition.x)
? m_startPosition.x ? m_startPosition.x
@ -1673,9 +1670,9 @@ public:
{ {
double k = dx / dy; /*-- 直線の傾き --*/ double k = dx / dy; /*-- 直線の傾き --*/
/*--- roundでは負値のときにうまく繋がらない ---*/ /*--- roundでは負値のときにうまく繋がらない ---*/
int start = std::min((int)floor(m_startPosition.y + 0.5), int start = std::min((int)floor(m_startPosition.y + 0.5),
(int)floor(m_mousePosition.y + 0.5)); (int)floor(m_mousePosition.y + 0.5));
int end = std::max((int)floor(m_startPosition.y + 0.5), int end = std::max((int)floor(m_startPosition.y + 0.5),
(int)floor(m_mousePosition.y + 0.5)); (int)floor(m_mousePosition.y + 0.5));
double start_x = (m_startPosition.y < m_mousePosition.y) double start_x = (m_startPosition.y < m_mousePosition.y)
? m_startPosition.x ? m_startPosition.x
@ -1773,7 +1770,7 @@ int FillTool::getCursorId() const {
if (m_colorType.getValue() == LINES) if (m_colorType.getValue() == LINES)
ret = ToolCursor::FillCursorL; ret = ToolCursor::FillCursorL;
else { else {
ret = ToolCursor::FillCursor; ret = ToolCursor::FillCursor;
if (m_colorType.getValue() == AREAS) ret = ret | ToolCursor::Ex_Area; if (m_colorType.getValue() == AREAS) ret = ret | ToolCursor::Ex_Area;
if (!m_autopaintLines.getValue()) if (!m_autopaintLines.getValue())
ret = ret | ToolCursor::Ex_Fill_NoAutopaint; ret = ret | ToolCursor::Ex_Fill_NoAutopaint;
@ -2016,7 +2013,7 @@ bool FillTool::onPropertyChanged(std::string propertyName) {
// Onion Skin // Onion Skin
else if (propertyName == m_onion.getName()) { else if (propertyName == m_onion.getName()) {
if (m_onion.getValue()) FillType = ::to_string(m_fillType.getValue()); if (m_onion.getValue()) FillType = ::to_string(m_fillType.getValue());
FillOnion = (int)(m_onion.getValue()); FillOnion = (int)(m_onion.getValue());
} }
// Frame Range // Frame Range
else if (propertyName == m_frameRange.getName()) { else if (propertyName == m_frameRange.getName()) {
@ -2036,7 +2033,7 @@ bool FillTool::onPropertyChanged(std::string propertyName) {
// Segment // Segment
else if (propertyName == m_segment.getName()) { else if (propertyName == m_segment.getName()) {
if (m_segment.getValue()) FillType = ::to_string(m_fillType.getValue()); if (m_segment.getValue()) FillType = ::to_string(m_fillType.getValue());
FillSegment = (int)(m_segment.getValue()); FillSegment = (int)(m_segment.getValue());
} }
// Autopaint // Autopaint
@ -2291,9 +2288,9 @@ void FillTool::onActivate() {
bool ret = true; bool ret = true;
ret = ret && connect(TTool::m_application->getCurrentFrame(), ret = ret && connect(TTool::m_application->getCurrentFrame(),
SIGNAL(frameSwitched()), this, SLOT(onFrameSwitched())); SIGNAL(frameSwitched()), this, SLOT(onFrameSwitched()));
ret = ret && connect(TTool::m_application->getCurrentScene(), ret = ret && connect(TTool::m_application->getCurrentScene(),
SIGNAL(sceneSwitched()), this, SLOT(onFrameSwitched())); SIGNAL(sceneSwitched()), this, SLOT(onFrameSwitched()));
ret = ret && ret = ret &&
connect(TTool::m_application->getCurrentColumn(), connect(TTool::m_application->getCurrentColumn(),
SIGNAL(columnIndexSwitched()), this, SLOT(onFrameSwitched())); SIGNAL(columnIndexSwitched()), this, SLOT(onFrameSwitched()));
assert(ret); assert(ret);

View file

@ -923,9 +923,9 @@ void SelectionTool::updateAction(TPointD pos, const TMouseEvent &e) {
double pixelSize = getPixelSize(); double pixelSize = getPixelSize();
if (!bbox.isEmpty()) { if (!bbox.isEmpty()) {
double maxDist = 8 * pixelSize; double maxDist = 17 * pixelSize;
double maxDist2 = maxDist * maxDist; double maxDist2 = maxDist * maxDist;
double p = (12 * pixelSize) - 3 * pixelSize; double p = (15 * pixelSize);
m_selectedPoint = NONE; m_selectedPoint = NONE;
if (tdistance2(bbox.getP00(), pos) < maxDist2 + p) if (tdistance2(bbox.getP00(), pos) < maxDist2 + p)
m_selectedPoint = P00; m_selectedPoint = P00;

View file

@ -1240,7 +1240,7 @@ void MainWindow::onMenuCheckboxChanged() {
FieldGuideToggleAction = isChecked; FieldGuideToggleAction = isChecked;
else if (cm->getAction(MI_RasterizePli) == action) { else if (cm->getAction(MI_RasterizePli) == action) {
if (!QGLPixelBuffer::hasOpenGLPbuffers()) isChecked = 0; if (!QGLPixelBuffer::hasOpenGLPbuffers()) isChecked = 0;
RasterizePliToggleAction = isChecked; RasterizePliToggleAction = isChecked;
} else if (cm->getAction(MI_SafeArea) == action) } else if (cm->getAction(MI_SafeArea) == action)
SafeAreaToggleAction = isChecked; SafeAreaToggleAction = isChecked;
else if (cm->getAction(MI_ViewColorcard) == action) else if (cm->getAction(MI_ViewColorcard) == action)
@ -3304,7 +3304,7 @@ void MainWindow::clearCacheFolder() {
// 1. $CACHE/[Current ProcessID] // 1. $CACHE/[Current ProcessID]
// 2. $CACHE/temp/[Current scene folder] if the current scene is untitled // 2. $CACHE/temp/[Current scene folder] if the current scene is untitled
TFilePath cacheRoot = ToonzFolder::getCacheRootFolder(); TFilePath cacheRoot = ToonzFolder::getCacheRootFolder();
if (cacheRoot.isEmpty()) cacheRoot = TEnv::getStuffDir() + "cache"; if (cacheRoot.isEmpty()) cacheRoot = TEnv::getStuffDir() + "cache";
TFilePathSet filesToBeRemoved; TFilePathSet filesToBeRemoved;
@ -3438,9 +3438,9 @@ RecentFiles::~RecentFiles() {}
void RecentFiles::addFilePath(QString path, FileType fileType, void RecentFiles::addFilePath(QString path, FileType fileType,
QString projectName) { QString projectName) {
QList<QString> files = QList<QString> files =
(fileType == Scene) ? m_recentScenes : (fileType == Level) (fileType == Scene)
? m_recentLevels ? m_recentScenes
: m_recentFlipbookImages; : (fileType == Level) ? m_recentLevels : m_recentFlipbookImages;
int i; int i;
for (i = 0; i < files.size(); i++) for (i = 0; i < files.size(); i++)
if (files.at(i) == path) { if (files.at(i) == path) {
@ -3607,9 +3607,9 @@ void RecentFiles::saveRecentFiles() {
QList<QString> RecentFiles::getFilesNameList(FileType fileType) { QList<QString> RecentFiles::getFilesNameList(FileType fileType) {
QList<QString> files = QList<QString> files =
(fileType == Scene) ? m_recentScenes : (fileType == Level) (fileType == Scene)
? m_recentLevels ? m_recentScenes
: m_recentFlipbookImages; : (fileType == Level) ? m_recentLevels : m_recentFlipbookImages;
QList<QString> names; QList<QString> names;
int i; int i;
for (i = 0; i < files.size(); i++) { for (i = 0; i < files.size(); i++) {
@ -3636,9 +3636,9 @@ void RecentFiles::refreshRecentFilesMenu(FileType fileType) {
menu->setEnabled(false); menu->setEnabled(false);
else { else {
CommandId clearActionId = CommandId clearActionId =
(fileType == Scene) ? MI_ClearRecentScene : (fileType == Level) (fileType == Scene)
? MI_ClearRecentLevel ? MI_ClearRecentScene
: MI_ClearRecentImage; : (fileType == Level) ? MI_ClearRecentLevel : MI_ClearRecentImage;
menu->setActions(names); menu->setActions(names);
menu->addSeparator(); menu->addSeparator();
QAction *clearAction = CommandManager::instance()->getAction(clearActionId); QAction *clearAction = CommandManager::instance()->getAction(clearActionId);

View file

@ -2156,7 +2156,7 @@ double SceneViewer::projectToZ(const TPointD &delta) {
GLint viewport[4]; GLint viewport[4];
double modelview[16], projection[16]; double modelview[16], projection[16];
glGetIntegerv(GL_VIEWPORT, viewport); glGetIntegerv(GL_VIEWPORT, viewport);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
projection[i] = (double)m_projectionMatrix.constData()[i]; projection[i] = (double)m_projectionMatrix.constData()[i];
glGetDoublev(GL_MODELVIEW_MATRIX, modelview); glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
@ -2318,8 +2318,9 @@ void SceneViewer::zoomQt(bool forward, bool reset) {
if (reset || ((m_zoomScale3D < 500 || !forward) && if (reset || ((m_zoomScale3D < 500 || !forward) &&
(m_zoomScale3D > 0.01 || forward))) { (m_zoomScale3D > 0.01 || forward))) {
double oldZoomScale = m_zoomScale3D; double oldZoomScale = m_zoomScale3D;
m_zoomScale3D = reset ? 1 : ImageUtils::getQuantizedZoomFactor( m_zoomScale3D =
m_zoomScale3D, forward); reset ? 1
: ImageUtils::getQuantizedZoomFactor(m_zoomScale3D, forward);
m_pan3D = -(m_zoomScale3D / oldZoomScale) * -m_pan3D; m_pan3D = -(m_zoomScale3D / oldZoomScale) * -m_pan3D;
} }
@ -2340,17 +2341,18 @@ void SceneViewer::zoomQt(bool forward, bool reset) {
int i; int i;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
TAffine &viewAff = m_viewAff[i]; TAffine &viewAff = m_viewAff[i];
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1); if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1); if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
double scale2 = std::abs(viewAff.det()); double scale2 = std::abs(viewAff.det());
if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1); if (m_isFlippedX) viewAff = viewAff * TScale(-1, 1);
if (m_isFlippedX) viewAff = viewAff * TScale(1, -1); if (m_isFlippedX) viewAff = viewAff * TScale(1, -1);
if (reset || ((scale2 < 100000 || !forward) && if (reset || ((scale2 < 100000 || !forward) &&
(scale2 > 0.001 * 0.05 || forward))) { (scale2 > 0.001 * 0.05 || forward))) {
double oldZoomScale = sqrt(scale2) * dpiFactor; double oldZoomScale = sqrt(scale2) * dpiFactor;
double zoomScale = reset ? 1 : ImageUtils::getQuantizedZoomFactor( double zoomScale =
oldZoomScale, forward); reset ? 1
: ImageUtils::getQuantizedZoomFactor(oldZoomScale, forward);
// threshold value -0.001 is intended to absorb the error of calculation // threshold value -0.001 is intended to absorb the error of calculation
if ((oldZoomScale - zoomScaleFittingWithScreen) * if ((oldZoomScale - zoomScaleFittingWithScreen) *
@ -2653,9 +2655,9 @@ void SceneViewer::fitToCamera() {
TPointD P11 = cameraAff * cameraRect.getP11(); TPointD P11 = cameraAff * cameraRect.getP11();
TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}), TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}),
std::min({P00.y, P01.y, P10.y, P11.y})); std::min({P00.y, P01.y, P10.y, P11.y}));
TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}), TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
std::max({P00.y, P01.y, P10.y, P11.y})); std::max({P00.y, P01.y, P10.y, P11.y}));
cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y); cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
// Pan // Pan
if (!is3DView()) { if (!is3DView()) {
@ -2698,9 +2700,9 @@ void SceneViewer::fitToCameraOutline() {
TPointD P11 = cameraAff * cameraRect.getP11(); TPointD P11 = cameraAff * cameraRect.getP11();
TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}), TPointD p0 = TPointD(std::min({P00.x, P01.x, P10.x, P11.x}),
std::min({P00.y, P01.y, P10.y, P11.y})); std::min({P00.y, P01.y, P10.y, P11.y}));
TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}), TPointD p1 = TPointD(std::max({P00.x, P01.x, P10.x, P11.x}),
std::max({P00.y, P01.y, P10.y, P11.y})); std::max({P00.y, P01.y, P10.y, P11.y}));
cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y); cameraRect = TRectD(p0.x, p0.y, p1.x, p1.y);
// Pan // Pan
if (!is3DView()) { if (!is3DView()) {
@ -2750,8 +2752,8 @@ void SceneViewer::resetZoom() {
TPointD realCenter(m_viewAff[m_viewMode].a13, m_viewAff[m_viewMode].a23); TPointD realCenter(m_viewAff[m_viewMode].a13, m_viewAff[m_viewMode].a23);
TAffine aff = TAffine aff =
getNormalZoomScale() * TRotation(realCenter, m_rotationAngle[m_viewMode]); getNormalZoomScale() * TRotation(realCenter, m_rotationAngle[m_viewMode]);
aff.a13 = realCenter.x; aff.a13 = realCenter.x;
aff.a23 = realCenter.y; aff.a23 = realCenter.y;
if (m_isFlippedX) aff = aff * TScale(-1, 1); if (m_isFlippedX) aff = aff * TScale(-1, 1);
if (m_isFlippedY) aff = aff * TScale(1, -1); if (m_isFlippedY) aff = aff * TScale(1, -1);
setViewMatrix(aff, m_viewMode); setViewMatrix(aff, m_viewMode);
@ -2808,16 +2810,17 @@ void SceneViewer::setActualPixelSize() {
} else } else
dpi = sl->getDpi(fid); dpi = sl->getDpi(fid);
const double inch = Stage::inch; const double inch = Stage::inch;
TAffine tempAff = getNormalZoomScale(); TAffine tempAff = getNormalZoomScale();
if (m_isFlippedX) tempAff = tempAff * TScale(-1, 1); if (m_isFlippedX) tempAff = tempAff * TScale(-1, 1);
if (m_isFlippedY) tempAff = tempAff * TScale(1, -1); if (m_isFlippedY) tempAff = tempAff * TScale(1, -1);
TPointD tempScale = dpi; TPointD tempScale = dpi;
if (m_isFlippedX) tempScale.x = -tempScale.x; if (m_isFlippedX) tempScale.x = -tempScale.x;
if (m_isFlippedY) tempScale.y = -tempScale.y; if (m_isFlippedY) tempScale.y = -tempScale.y;
for (int i = 0; i < m_viewAff.size(); ++i) for (int i = 0; i < m_viewAff.size(); ++i)
setViewMatrix(dpi == TPointD(0, 0) ? tempAff : TScale(tempScale.x / inch, setViewMatrix(dpi == TPointD(0, 0)
tempScale.y / inch), ? tempAff
: TScale(tempScale.x / inch, tempScale.y / inch),
i); i);
m_pos = QPoint(0, 0); m_pos = QPoint(0, 0);
@ -3100,7 +3103,7 @@ void drawSpline(const TAffine &viewMatrix, const TRect &clipRect, bool camera3d,
TStageObject *pegbar = TStageObject *pegbar =
objId != TStageObjectId::NoneId ? xsh->getStageObject(objId) : 0; objId != TStageObjectId::NoneId ? xsh->getStageObject(objId) : 0;
const TStroke *stroke = 0; const TStroke *stroke = 0;
if (pegbar && pegbar->getSpline()) stroke = pegbar->getSpline()->getStroke(); if (pegbar && pegbar->getSpline()) stroke = pegbar->getSpline()->getStroke();
if (!stroke) return; if (!stroke) return;

View file

@ -3009,6 +3009,7 @@ void CellArea::mouseDoubleClickEvent(QMouseEvent *event) {
int k0, k1; int k0, k1;
bool isKeyframeFrame = pegbar && pegbar->getKeyframeRange(k0, k1) && bool isKeyframeFrame = pegbar && pegbar->getKeyframeRange(k0, k1) &&
k0 <= row && row <= k1 + 1; k0 <= row && row <= k1 + 1;
// If you are in the keyframe area, open a function editor // If you are in the keyframe area, open a function editor
if (isKeyframeFrame && isKeyFrameArea(col, row, mouseInCell)) { if (isKeyframeFrame && isKeyFrameArea(col, row, mouseInCell)) {
QAction *action = QAction *action =

View file

@ -258,8 +258,8 @@ bool setKeyframe(const TDoubleParamP &param, const TDoubleKeyframe &kf,
TDoubleKeyframe kfCopy = kf; TDoubleKeyframe kfCopy = kf;
kfCopy.m_frame = frame; kfCopy.m_frame = frame;
if (easeIn >= 0.0) kfCopy.m_speedIn = TPointD(-easeIn, kfCopy.m_speedIn.y); if (easeIn >= 0.0) kfCopy.m_speedIn = TPointD(-easeIn, kfCopy.m_speedIn.y);
if (easeOut >= 0.0) kfCopy.m_speedOut = TPointD(easeOut, kfCopy.m_speedOut.y); if (easeOut >= 0.0) kfCopy.m_speedOut = TPointD(easeOut, kfCopy.m_speedOut.y);
param->setKeyframe(kfCopy); param->setKeyframe(kfCopy);
@ -773,7 +773,7 @@ void TStageObject::setCenterAndOffset(const TPointD &center,
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void TStageObject::setHandle(const std::string &s) { void TStageObject::setHandle(const std::string &s) {
m_handle = s; m_handle = s;
if (!s.empty() && s[0] == 'H') m_offset = m_center = TPointD(); if (!s.empty() && s[0] == 'H') m_offset = m_center = TPointD();
invalidate(); invalidate();
@ -971,7 +971,7 @@ void TStageObject::removeKeyframeWithoutUndo(int frame) {
if (m_skeletonDeformation) m_skeletonDeformation->deleteKeyframe(frame); if (m_skeletonDeformation) m_skeletonDeformation->deleteKeyframe(frame);
time = -1; time = -1;
if ((int)keyframes.size() < 2) m_cycleEnabled = false; if ((int)keyframes.size() < 2) m_cycleEnabled = false;
invalidate(); invalidate();
@ -1304,17 +1304,17 @@ TAffine TStageObject::computeIkRootOffset(int t) {
TAffine placement = foot->getPlacement(t).inv(); TAffine placement = foot->getPlacement(t).inv();
int t0 = 0; int t0 = 0;
const TPinnedRangeSet::Range *range = foot->getPinnedRangeSet()->getRange(t); const TPinnedRangeSet::Range *range = foot->getPinnedRangeSet()->getRange(t);
if (range) t0 = range->first; if (range) t0 = range->first;
while (t0 > 0) { while (t0 > 0) {
TStageObject *oldFoot = getPinnedDescendant(t0 - 1); TStageObject *oldFoot = getPinnedDescendant(t0 - 1);
if (oldFoot == 0) break; // oldFoot = this; if (oldFoot == 0) break; // oldFoot = this;
assert(oldFoot != foot); assert(oldFoot != foot);
TAffine changeFootAff = TAffine changeFootAff =
oldFoot->getPlacement(t0).inv() * foot->getPlacement(t0); oldFoot->getPlacement(t0).inv() * foot->getPlacement(t0);
placement = changeFootAff * placement; placement = changeFootAff * placement;
foot = oldFoot; foot = oldFoot;
range = oldFoot->getPinnedRangeSet()->getRange(t0 - 1); range = oldFoot->getPinnedRangeSet()->getRange(t0 - 1);
t0 = 0; t0 = 0;
if (range) t0 = range->first; if (range) t0 = range->first;
} }
m_ikflag--; m_ikflag--;
@ -1412,7 +1412,7 @@ TAffine TStageObject::getPlacement(double t) {
if (m_parent) if (m_parent)
place = m_parent->getPlacement(t) * computeLocalPlacement(tt); place = m_parent->getPlacement(t) * computeLocalPlacement(tt);
else else
place = computeLocalPlacement(tt); place = computeLocalPlacement(tt);
m_absPlacement = place; m_absPlacement = place;
time = t; time = t;
return place; return place;
@ -1855,8 +1855,8 @@ TStageObjectParams *TStageObject::getParams() const {
data->m_cycleEnabled = m_cycleEnabled; data->m_cycleEnabled = m_cycleEnabled;
data->m_spline = m_spline; data->m_spline = m_spline;
data->m_handle = m_handle; data->m_handle = m_handle;
data->m_parentHandle = m_parentHandle; data->m_parentHandle = m_parentHandle;
if (m_pinnedRangeSet) data->m_pinnedRangeSet = m_pinnedRangeSet->clone(); if (m_pinnedRangeSet) data->m_pinnedRangeSet = m_pinnedRangeSet->clone();
return data; return data;
@ -1922,7 +1922,7 @@ void TStageObject::assignParams(const TStageObjectParams *src,
m_handle = src->m_handle; m_handle = src->m_handle;
m_parentHandle = src->m_parentHandle; m_parentHandle = src->m_parentHandle;
m_cycleEnabled = src->m_cycleEnabled; m_cycleEnabled = src->m_cycleEnabled;
if (m_pinnedRangeSet) *m_pinnedRangeSet = *src->m_pinnedRangeSet; if (m_pinnedRangeSet) *m_pinnedRangeSet = *src->m_pinnedRangeSet;
updateKeyframes(); updateKeyframes();
if (m_spline && isUppkEnabled()) m_spline->addParam(m_posPath.getPointer()); if (m_spline && isUppkEnabled()) m_spline->addParam(m_posPath.getPointer());

View file

@ -102,8 +102,8 @@ bool checkCreatorString(const QString &creator) {
if (pos >= 0 && len >= 4) { if (pos >= 0 && len >= 4) {
QString v; QString v;
if (len > 4) v = creator.mid(pos + 3, len - 4); if (len > 4) v = creator.mid(pos + 3, len - 4);
bool ok = true; bool ok = true;
mask = v.toInt(&ok, 16); mask = v.toInt(&ok, 16);
} }
} }
return (mask & compatibility.neededMask) == compatibility.neededMask && return (mask & compatibility.neededMask) == compatibility.neededMask &&
@ -169,8 +169,8 @@ void getIndexesRangefromFids(TXshSimpleLevel *level,
std::set<TFrameId>::const_iterator it; std::set<TFrameId>::const_iterator it;
for (it = fids.begin(); it != fids.end(); ++it) { for (it = fids.begin(); it != fids.end(); ++it) {
int index = level->guessIndex(*it); int index = level->guessIndex(*it);
if (index > toIndex) toIndex = index; if (index > toIndex) toIndex = index;
if (index < fromIndex) fromIndex = index; if (index < fromIndex) fromIndex = index;
} }
} }
@ -917,13 +917,13 @@ void TXshSimpleLevel::loadData(TIStream &is) {
if (is.getTagParam("dpix", v)) xdpi = std::stod(v); if (is.getTagParam("dpix", v)) xdpi = std::stod(v);
if (is.getTagParam("dpiy", v)) ydpi = std::stod(v); if (is.getTagParam("dpiy", v)) ydpi = std::stod(v);
if (xdpi != 0 && ydpi != 0) dpiPolicy = LevelProperties::DP_CustomDpi; if (xdpi != 0 && ydpi != 0) dpiPolicy = LevelProperties::DP_CustomDpi;
std::string dpiType = is.getTagAttribute("dpiType"); std::string dpiType = is.getTagAttribute("dpiType");
if (dpiType == "image") dpiPolicy = LevelProperties::DP_ImageDpi; if (dpiType == "image") dpiPolicy = LevelProperties::DP_ImageDpi;
if (is.getTagParam("type", v) && v == "s") type = TZI_XSHLEVEL; if (is.getTagParam("type", v) && v == "s") type = TZI_XSHLEVEL;
if (is.getTagParam("subsampling", v)) subsampling = std::stoi(v); if (is.getTagParam("subsampling", v)) subsampling = std::stoi(v);
if (is.getTagParam("premultiply", v)) doPremultiply = std::stoi(v); if (is.getTagParam("premultiply", v)) doPremultiply = std::stoi(v);
if (is.getTagParam("antialias", v)) antialiasSoftness = std::stoi(v); if (is.getTagParam("antialias", v)) antialiasSoftness = std::stoi(v);
if (is.getTagParam("whiteTransp", v)) whiteTransp = std::stoi(v); if (is.getTagParam("whiteTransp", v)) whiteTransp = std::stoi(v);
if (is.getTagParam("isStopMotionLevel", v)) if (is.getTagParam("isStopMotionLevel", v))
isStopMotionLevel = std::stoi(v); isStopMotionLevel = std::stoi(v);
@ -1094,9 +1094,8 @@ static TFilePath getLevelPathAndSetNameWithPsdLevelName(
if (removeFileName) wLevelName = list[1].toStdWString(); if (removeFileName) wLevelName = list[1].toStdWString();
TLevelSet *levelSet = xshLevel->getScene()->getLevelSet(); TLevelSet *levelSet = xshLevel->getScene()->getLevelSet();
if (levelSet && if (levelSet && levelSet->hasLevel(
levelSet->hasLevel( wLevelName)) // levelSet should be asserted instead
wLevelName)) // levelSet should be asserted instead
levelSet->renameLevel(xshLevel, wLevelName); levelSet->renameLevel(xshLevel, wLevelName);
xshLevel->setName(wLevelName); xshLevel->setName(wLevelName);
@ -1654,8 +1653,8 @@ void TXshSimpleLevel::saveSimpleLevel(const TFilePath &decodedFp,
std::vector<TFrameId> fids; std::vector<TFrameId> fids;
getFids(fids); getFids(fids);
bool isLevelModified = getProperties()->getDirtyFlag(); bool isLevelModified = getProperties()->getDirtyFlag();
bool isPaletteModified = false; bool isPaletteModified = false;
if (getPalette()) isPaletteModified = getPalette()->getDirtyFlag(); if (getPalette()) isPaletteModified = getPalette()->getDirtyFlag();
if (isLevelModified || isPaletteModified) { if (isLevelModified || isPaletteModified) {
@ -1902,11 +1901,11 @@ void TXshSimpleLevel::saveSimpleLevel(const TFilePath &decodedFp,
std::string TXshSimpleLevel::getImageId(const TFrameId &fid, std::string TXshSimpleLevel::getImageId(const TFrameId &fid,
int frameStatus) const { int frameStatus) const {
if (frameStatus < 0) frameStatus = getFrameStatus(fid); if (frameStatus < 0) frameStatus = getFrameStatus(fid);
std::string prefix = "L"; std::string prefix = "L";
if (frameStatus & CleanupPreview) if (frameStatus & CleanupPreview)
prefix = "P"; prefix = "P";
else if ((frameStatus & (Scanned | Cleanupped)) == Scanned) else if ((frameStatus & (Scanned | Cleanupped)) == Scanned)
prefix = "S"; prefix = "S";
std::string imageId = m_idBase + "_" + prefix + fid.expand(); std::string imageId = m_idBase + "_" + prefix + fid.expand();
return imageId; return imageId;
} }
@ -2332,13 +2331,14 @@ TFilePath TXshSimpleLevel::getExistingHookFile(
int f, fCount = hookFiles.size(); int f, fCount = hookFiles.size();
for (f = 0; f != fCount; ++f) { for (f = 0; f != fCount; ++f) {
fPattern = locals::getPattern(hookFiles[f]); fPattern = locals::getPattern(hookFiles[f]);
if (fPattern < p) p = fPattern, h = f; if (fPattern < p) p = fPattern, h = f;
} }
assert(h >= 0); assert(h >= 0);
return (h < 0) ? TFilePath() : decodedLevelPath.getParentDir() + return (h < 0) ? TFilePath()
TFilePath(hookFiles[h].toStdWString()); : decodedLevelPath.getParentDir() +
TFilePath(hookFiles[h].toStdWString());
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -663,7 +663,7 @@ void updateMaximumPageSize(QGridLayout *layout, int &maxLabelWidth,
continue; continue;
} }
QSize itemSize = getItemSize(item); QSize itemSize = getItemSize(item);
if (maxWidgetWidth < itemSize.width()) maxWidgetWidth = itemSize.width(); if (maxWidgetWidth < itemSize.width()) maxWidgetWidth = itemSize.width();
fieldsHeight += itemSize.height(); fieldsHeight += itemSize.height();
} }

View file

@ -598,7 +598,6 @@ static void drawChipName(QPainter &p, const QRect &chipRect,
void PageViewer::paintEvent(QPaintEvent *e) { void PageViewer::paintEvent(QPaintEvent *e) {
QPainter p(this); QPainter p(this);
QColor textColor = p.pen().color(); QColor textColor = p.pen().color();
if (m_chipPerRow == 0) { if (m_chipPerRow == 0) {
p.drawText(QPoint(5, 25), tr("- No Styles -")); p.drawText(QPoint(5, 25), tr("- No Styles -"));
return; return;