THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/09/2010 at 15:25, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
---------
Hey everyone. I am trying to do some edge cuts on an object. I am using the following code to do so... The problem is when I leave the labeled piece of code in the code, the plugin crashes. When I comment it out, it works fine but thge edge cuts do not work right. I am sure that the cuts are not working right because I am making cuts on edges that have already been cut.
Any thoughts on why the code labeled "<-- THIS CODE CAUSES THE CRASH" is causing c4d to crash?
Thanks,
Shawn
BaseDocument *doc = mdat.doc;
BaseObject *op = doc->GetActiveObject();
BaseContainer *bc = mdat.bc;
PolygonObject *objPoly = (PolygonObject * )op;
if(!objPoly) return FALSE;
AutoAlloc<Modeling> mod;
if (!mod || !mod->InitObject(objPoly)) return FALSE;
LONG pointCount = objPoly->GetPointCount();
LONG polyCount = objPoly->GetPolygonCount();
CPolygon * polys = objPoly->GetPolygonW();
Real width = bc->GetReal(CHAMFER_WIDTH);
PolyInfo *pli = NULL;
Neighbor n;
LONG pointA = 0, pointB = 0;
//Iterate Through Edges
for ( int i=0; i < polyCount; i++)
{
pli = n.GetPolyInfo(i);
for (int side = 0; side < 4; side++) // test all 4 sides of a polygon
{
// only proceed if edge has not already been processed
// and edge really exists (for triangles side 2 from c..d does not exist as c==d)
if (pli->mark[side] || side==2 && polys[i].c == polys[i].d) continue; <-- THIS CODE IS CAUSING THE CRASH
switch (side)
{
case 0: pointA = polys[i].a; pointB = polys[i].d; break;
case 1: pointA = polys[i].d; pointB = polys[i].c; break;
case 2: pointA = polys[i].c; pointB = polys[i].b; break;
case 3: pointA = polys[i].b; pointB = polys[i].a; break;
}
//Split Edges
mod->SplitEdge(objPoly, pointA, pointB, width);
EventAdd();
}
}
//Delete Original Points
for (int i=0; i < pointCount; i++)
{
mod->DeletePoint(objPoly, i);
}
if (!mod->Commit()) return FALSE;
EventAdd();
return TRUE;