X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_particle%2Fplant.cpp;h=1a89f1f446d41a49de12b382079ca7bd8d36d8f7;hb=c4fa0287b0920adf20f0a0339c8668cd988b993e;hp=7affc15b7dade3403d95f30c20eaa5bb16cb0ed7;hpb=6d12cf6d823b693ff8342752b00fdea813cff503;p=synfig.git diff --git a/synfig-core/trunk/src/modules/mod_particle/plant.cpp b/synfig-core/trunk/src/modules/mod_particle/plant.cpp index 7affc15..1a89f1f 100644 --- a/synfig-core/trunk/src/modules/mod_particle/plant.cpp +++ b/synfig-core/trunk/src/modules/mod_particle/plant.cpp @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file plant.cpp -** \brief Template +** \brief Implementation of the "Plant" layer ** ** $Id$ ** @@ -65,9 +65,9 @@ using namespace etl; SYNFIG_LAYER_INIT(Plant); SYNFIG_LAYER_SET_NAME(Plant,"plant"); -SYNFIG_LAYER_SET_LOCAL_NAME(Plant,_("Plant")); -SYNFIG_LAYER_SET_CATEGORY(Plant,_("Other")); -SYNFIG_LAYER_SET_VERSION(Plant,"0.1"); +SYNFIG_LAYER_SET_LOCAL_NAME(Plant,N_("Plant")); +SYNFIG_LAYER_SET_CATEGORY(Plant,N_("Other")); +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)); @@ -461,6 +487,9 @@ Plant::accelerated_render(Context context,Surface *surface,int quality, const Re const Real pw = (br[0] - tl[0]) / w; const Real ph = (br[1] - tl[1]) / h; + if (isinf(pw) || isinf(ph)) + return true; + if(needs_sync_==true) sync();