From 0395514261f9ab95377771b808a733f973c8a562 Mon Sep 17 00:00:00 2001 From: dooglus Date: Tue, 15 Jan 2008 23:30:24 +0000 Subject: [PATCH] =?utf8?q?Fix=201831897:=20Use=20the=20'width'=20of=20each?= =?utf8?q?=20blinepoint=20in=20the=20plant=20layer=20to=20affect=20the=20v?= =?utf8?q?elocities.=20=20Adapted=20from=20a=20patch=20by=20Carlos=20L?= =?utf8?q?=C3=B3pez=20Gonz=C3=A1lez=20(genete).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.voria.com/code@1385 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/AUTHORS | 1 + .../trunk/src/modules/mod_particle/plant.cpp | 32 ++++++++++++++++++++-- synfig-core/trunk/src/modules/mod_particle/plant.h | 4 +++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/synfig-core/trunk/AUTHORS b/synfig-core/trunk/AUTHORS index 4c74324..c13f918 100644 --- a/synfig-core/trunk/AUTHORS +++ b/synfig-core/trunk/AUTHORS @@ -12,6 +12,7 @@ Luka Pravica Andreas Jochens Chris Moore (dooglus) Martin Michlmayr +Carlos López González (genete) Translators: diff --git a/synfig-core/trunk/src/modules/mod_particle/plant.cpp b/synfig-core/trunk/src/modules/mod_particle/plant.cpp index 29dab46..1a89f1f 100644 --- a/synfig-core/trunk/src/modules/mod_particle/plant.cpp +++ b/synfig-core/trunk/src/modules/mod_particle/plant.cpp @@ -67,7 +67,7 @@ SYNFIG_LAYER_INIT(Plant); SYNFIG_LAYER_SET_NAME(Plant,"plant"); SYNFIG_LAYER_SET_LOCAL_NAME(Plant,N_("Plant")); SYNFIG_LAYER_SET_CATEGORY(Plant,N_("Other")); -SYNFIG_LAYER_SET_VERSION(Plant,"0.1"); +SYNFIG_LAYER_SET_VERSION(Plant,"0.2"); SYNFIG_LAYER_SET_CVS_ID(Plant,"$Id$"); /* === P R O C E D U R E S ================================================= */ @@ -81,7 +81,9 @@ Plant::Plant(): velocity(0.3), perp_velocity(0.0), step(0.01), - sprouts(10) + sprouts(10), + version(version__), + use_width(true) { bounding_rect=Rect::zero(); random_factor=0.2; @@ -208,6 +210,9 @@ Plant::sync()const // loop through the bline; seg counts the blines as we do so; stop before iter is the last bline in the list for(;next!=bline.end();iter=next++,seg++) { + float iterw=iter->get_width(); // the width value of the iter vertex + float nextw=next->get_width(); // the width value of the next vertex + float width; // the width at an intermediate position curve.p1()=iter->get_vertex(); curve.t1()=iter->get_tangent2(); curve.p2()=next->get_vertex(); @@ -238,6 +243,14 @@ Plant::sync()const branch_velocity[0] += random_factor * random(Random::SMOOTH_COSINE, 1, f*splits, 0.0f, 0.0f); branch_velocity[1] += random_factor * random(Random::SMOOTH_COSINE, 2, f*splits, 0.0f, 0.0f); + if (use_width) + { + width = iterw+(nextw-iterw)*f; // calculate the width based on the current position + + branch_velocity[0] *= width; // scale the velocity accordingly to the current width + branch_velocity[1] *= width; + } + branch_count++; branch(i, 0, 0, // time stunt_growth, // stunt growth @@ -345,7 +358,9 @@ Plant::get_param(const String& param)const EXPORT(reverse); EXPORT_NAME(); - EXPORT_VERSION(); + + if(param=="Version" || param=="version" || param=="version__") + return version; return Layer_Composite::get_param(param); } @@ -438,6 +453,17 @@ Plant::get_param_vocab()const } bool +Plant::set_version(const String &ver) +{ + version = ver; + + if (version == "0.1") + use_width = false; + + return true; +} + +bool Plant::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const { bool ret(context.accelerated_render(surface,quality,renddesc,cb)); diff --git a/synfig-core/trunk/src/modules/mod_particle/plant.h b/synfig-core/trunk/src/modules/mod_particle/plant.h index 8f60e94..e43818c 100644 --- a/synfig-core/trunk/src/modules/mod_particle/plant.h +++ b/synfig-core/trunk/src/modules/mod_particle/plant.h @@ -90,6 +90,8 @@ private: void branch(int n, int depth,float t, float stunt_growth, synfig::Point position,synfig::Vector velocity)const; void sync()const; + String version; + bool use_width; public: @@ -101,6 +103,8 @@ public: virtual ValueBase get_param(const String & param)const; + virtual bool set_version(const synfig::String &ver); + virtual Vocab get_param_vocab()const; virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const;\ -- 2.7.4