From aed108d4a328dd25c3ca360cc9702c6a2d3a9bd5 Mon Sep 17 00:00:00 2001 From: Andrew Hale <TrumanBlending@gmail.com> Date: Wed, 10 Aug 2011 10:13:22 +0000 Subject: [PATCH] Fixed a memory access issue on OSX due to getting bezier point's coordinates after a new point was added to the spline. This caused corruption of the tree model. --- add_curve_sapling/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/add_curve_sapling/utils.py b/add_curve_sapling/utils.py index 59b792193..14401a021 100644 --- a/add_curve_sapling/utils.py +++ b/add_curve_sapling/utils.py @@ -266,10 +266,14 @@ def growSpline(stem,numSplit,splitAng,splitAngV,splineList,attractUp,hType,splin # Make the growth vec the length of a stem segment dirVec.normalize() dirVec *= stem.segL + + # Get the end point position + end_co = stem.p.co.copy() + # Add the new point and adjust its coords, handles and radius newSpline.bezier_points.add() newPoint = newSpline.bezier_points[-1] - (newPoint.co,newPoint.handle_left_type,newPoint.handle_right_type) = (stem.p.co + dirVec,hType,hType) + (newPoint.co,newPoint.handle_left_type,newPoint.handle_right_type) = (end_co + dirVec,hType,hType) newPoint.radius = stem.radS*(1 - (stem.seg + 1)/stem.segMax) + stem.radE*((stem.seg + 1)/stem.segMax) # If this isn't the last point on a stem, then we need to add it to the list of stems to continue growing if stem.seg != stem.segMax: @@ -298,9 +302,13 @@ def growSpline(stem,numSplit,splitAng,splitAngV,splineList,attractUp,hType,splin dirVec.rotate(upRotMat) dirVec.normalize() dirVec *= stem.segL + + # Get the end point position + end_co = stem.p.co.copy() + stem.spline.bezier_points.add() newPoint = stem.spline.bezier_points[-1] - (newPoint.co,newPoint.handle_left_type,newPoint.handle_right_type) = (stem.p.co + dirVec,hType,hType) + (newPoint.co,newPoint.handle_left_type,newPoint.handle_right_type) = (end_co + dirVec,hType,hType) newPoint.radius = stem.radS*(1 - (stem.seg + 1)/stem.segMax) + stem.radE*((stem.seg + 1)/stem.segMax) # There are some cases where a point cannot have handles as VECTOR straight away, set these now. if numSplit != 0: -- GitLab