local function B(B)if B.Magnitude==0 then return Vector3.zero end return B.Unit end return function(G,R,p)debug.profilebegin("\082\111\112\101 \067\111\110\115\116\114\097\105\110\116")local r=p.Bones[G.ParentIndex]if r then local p=G.FreeLength local c=R-r.Position local j=B(c)local y=c.Magnitude<p and c.Magnitude or p local W=r.Position+j*y debug.profileend()return W end debug.profileend()return end
local function SafeUnit(v3)
	if v3.Magnitude == 0 then
		return Vector3.zero
	end

	return v3.Unit
end

return function(self, Position, BoneTree)
	debug.profilebegin("Rope Constraint")
	local ParentBone = BoneTree.Bones[self.ParentIndex]

	if ParentBone then
		local RestLength = self.FreeLength
		local BoneSub = (Position - ParentBone.Position)
		local BoneDirection = SafeUnit(BoneSub)
		local BoneDistance = BoneSub.Magnitude < RestLength and BoneSub.Magnitude or RestLength

		local RestPosition = ParentBone.Position + (BoneDirection * BoneDistance)

		debug.profileend()
		return RestPosition
	end

	debug.profileend()
	return
end
