if you want to use the “superior” poly cut for all object types then you handle it like this…
static PolyObject* GetPipeAsPoly(TimeValue t, Object *pipe)
{
PolyObject *poly = NULL;
if(pipe->IsSubClassOf (polyObjectClassID))
poly = static_cast<PolyObject *>(pipe);
else
{
if (pipe->CanConvertToType(polyObjectClassID))
poly = static_cast<PolyObject *>(pipe->ConvertToType(t, polyObjectClassID));
else
{
TriObject* tri = static_cast<TriObject *>(pipe->ConvertToType(t, triObjectClassID));
poly = static_cast<PolyObject *>(tri->ConvertToType(t, polyObjectClassID));
if (tri != pipe)
tri->DeleteThis();
}
}
return poly;
}
void TimberBoarding_mod::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{
Object *obj = os->obj;
if(!obj) return;
// get our params
Interval iv = FOREVER;
TimberBoarding_mod_params p;
GetParams(p, t, iv);
// start the validity
iv &= obj->ChannelValidity(t, TOPO_CHAN_NUM);
iv &= obj->ChannelValidity(t, GEOM_CHAN_NUM);
// we need the pipeline to be editable poly
PolyObject *polyobj = GetPipeAsPoly(t, os->obj);
if(polyobj != os->obj) // new object push it into the pipe
{
os->obj = polyobj;
os->obj->UnlockObject();
}
// get the mesh and slice
MNMesh& pmesh = polyobj->GetMesh();
pmesh.Slice(p.normal, p.offset, 0.0, false, true);
obj->UpdateValidity(GEOM_CHAN_NUM, iv);
obj->UpdateValidity(TOPO_CHAN_NUM, iv);
}

