bool Clipping::SutherlandHodgmanPolygonClip(Object* p){ auto &input = p->getNCoords(); Coordinates tmp; clipLeft(input, tmp); clipRight(tmp, input); clipBottom(input, tmp); clipTop(tmp, input); return (input.size() != 0); }
bool Clipping::SutherlandHodgmanPolygonClip(Object* p){ auto input = p->getNCoords(); Coordinates tmp; Coordinates output; clipLeft(input, tmp); clipRight(tmp, output); clipTop(output, tmp); clipBottom(tmp, output); if(output.size() == 0) return false; p->setNCoord(output); return true; }
void Triangle2HeightField::clipTriangleAgainstHeightField(const osg::Vec2d& v1, const osg::Vec2d& v2, const osg::Vec2d& v3, std::vector<osg::Vec2d>& result) { std::vector<osg::Vec2d>& in = result; in.clear(); in.push_back(v1); in.push_back(v2); in.push_back(v3); std::vector<osg::Vec2d> out; clipRight(in, out, _heightField->getNumColumns()-1); in.clear(); clipLeft(out, in, 0); out.clear(); clipTop(in, out, _heightField->getNumRows()-1); in.clear(); clipBottom(out, in, 0); }
bool Clipper::clip(Polygon &polygon, int clipFlagsOr, const DrawCall &draw) { if(clipFlagsOr & CLIP_FRUSTUM) { if(clipFlagsOr & CLIP_NEAR) clipNear(polygon); if(polygon.n >= 3) { if(clipFlagsOr & CLIP_FAR) clipFar(polygon); if(polygon.n >= 3) { if(clipFlagsOr & CLIP_LEFT) clipLeft(polygon); if(polygon.n >= 3) { if(clipFlagsOr & CLIP_RIGHT) clipRight(polygon); if(polygon.n >= 3) { if(clipFlagsOr & CLIP_TOP) clipTop(polygon); if(polygon.n >= 3) { if(clipFlagsOr & CLIP_BOTTOM) clipBottom(polygon); }}}}} } return polygon.n >= 3; }