This article explains how to clone a custom Circle entity. Custom entities can be easily cloned by adding the protected copy constructor and overriding the Clone() and CloneWithTessellation() methods. A complete example follows.
class MyCircle : Circle
{
private float price;
public MyCircle(Plane plane, double radius, float thePrice)
: base(plane, radius)
{
price = thePrice;
}
protected MyCircle(MyCircle another, bool keepTessellation = false)
: base(another, keepTessellation)
{
price = another.price;
}
public override object Clone()
{
return new MyCircle(this);
}
public override object CloneWithTessellation()
{
// keep the tessellation only if the entity does not need to be regenerated.
return new MyCircle(this, RegenMode != regenType.RegenAndCompile);
}
}
Comments
Please sign in to leave a comment.