X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fdocument.cpp;h=1383906acd16d96c2b014393cf20882a4a72d527;hp=0428aa9c21d26b59a6ab00e272f7a50d6c6d7c5a;hb=a69d8466e4ad4dd92488798582e680ae31029038;hpb=b04b227b04626afb2a8bf665dbcbf035bfa1cef8 diff --git a/src/document.cpp b/src/document.cpp index 0428aa9..1383906 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -132,34 +132,23 @@ int Document::ClipObjectToQuadChild(int object_id, QuadTreeNodeChildren type) } case BEZIER: { - Rect obj_bounds = TransformToQuadChild(m_objects.bounds[object_id], type); - if (obj_bounds.x < 0) + // If we're entirely within the quadtree node, no clipping need occur. + if (ContainedInQuadChild(m_objects.bounds[object_id], type)) { - obj_bounds.w += obj_bounds.x; - obj_bounds.x = 0; - } - if (obj_bounds.y < 0) - { - obj_bounds.h += obj_bounds.y; - obj_bounds.y = 0; - } - if (obj_bounds.x + obj_bounds.w > 1) - { - obj_bounds.w += (1 - (obj_bounds.x + obj_bounds.w)); - } - if (obj_bounds.y + obj_bounds.h > 1) - { - obj_bounds.h += (1 - (obj_bounds.y + obj_bounds.h)); + m_objects.bounds.push_back(TransformToQuadChild(m_objects.bounds[object_id], type)); + m_objects.types.push_back(m_objects.types[object_id]); + m_objects.data_indices.push_back(m_objects.data_indices[object_id]); + return 1; } - Rect child_node_bounds = TransformFromQuadChild(obj_bounds, type); - Rect clip_bezier_bounds = TransformRectCoordinates(m_objects.bounds[object_id], child_node_bounds); - std::vector new_curves = Bezier(m_objects.beziers[m_objects.data_indices[object_id]], child_node_bounds).ClipToRectangle(clip_bezier_bounds); + Rect clip_bezier_bounds = TransformRectCoordinates(m_objects.bounds[object_id], TransformFromQuadChild(Rect{0,0,1,1}, type)); + std::vector new_curves = m_objects.beziers[m_objects.data_indices[object_id]].ClipToRectangle(clip_bezier_bounds); for (size_t i = 0; i < new_curves.size(); ++i) { Rect new_bounds = TransformToQuadChild(m_objects.bounds[object_id], type); - //new_bounds = TransformToQuadChild(new_curves[i].SolveBounds(), type); - //Bezier new_curve_data = new_curves[i].ToRelative(new_bounds); - unsigned index = AddBezierData(new_curves[i]); + Bezier new_curve_data = new_curves[i].ToAbsolute(TransformToQuadChild(m_objects.bounds[object_id],type)); + new_bounds = new_curve_data.SolveBounds(); + new_curve_data = new_curve_data.ToRelative(new_bounds); + unsigned index = AddBezierData(new_curve_data); m_objects.bounds.push_back(new_bounds); m_objects.types.push_back(BEZIER); m_objects.data_indices.push_back(index);