type==ValueBase::TYPE_TIME ||
type==ValueBase::TYPE_VECTOR ;
}
+
+ValueNode*
+ValueNode_Random::clone(const GUID& deriv_guid)const
+{
+ ValueNode_Random* ret = (ValueNode_Random*)LinkableValueNode::clone(deriv_guid);
+ ret->randomize_seed();
+ return ret;
+}
+
+void
+ValueNode_Random::randomize_seed()
+{
+ int i = get_link_index_from_name("seed");
+ ValueNode::Handle link = get_link_vfunc(i);
+ if(!link->is_exported() && link->get_name() == "constant")
+ {
+ int seed = time(NULL) + rand();
+ if (seed < 0) seed = -seed;
+ random.set_seed(seed);
+ set_link(i, ValueNode_Const::create(seed));
+ }
+}
virtual String link_local_name(int i)const;
virtual int get_link_index_from_name(const String &name)const;
+ virtual ValueNode* clone(const GUID& deriv_guid=GUID())const;
+
+ void randomize_seed();
+
protected:
LinkableValueNode* create_new()const;
virtual bool set_link_vfunc(int i,ValueNode::Handle x);