Blocky Fill Error

The Problem is when i create the lines in the preview as you can see it’s correct
a shape that i’ve drawn but when the shape is done (BTW it’s a plugin i am working on)
it give me this blocky shape i want this to be smooth not that blocks!

-- Function to create a shape based on points and fill it
local function finalizeShape()
	if #points < 3 then
		warn("Need at least 3 points to create a filled shape.")
		return
	end

	-- Create the polygon from points
	local polygon = CreatePolygonFromPoints(points)

	-- Create the shape using parts to fill it
	local model = Instance.new("Model")
	model.Name = "FilledShape" .. shapeIndex
	model.Parent = Workspace
	shapeIndex = shapeIndex + 1 -- Increment shape index for next shape

	-- Determine the bounding box of the polygon
	local minX, minZ = math.huge, math.huge
	local maxX, maxZ = -math.huge, -math.huge

	for _, point in ipairs(points) do
		minX = math.min(minX, point.X)
		minZ = math.min(minZ, point.Z)
		maxX = math.max(maxX, point.X)
		maxZ = math.max(maxZ, point.Z)
	end

	-- Fill the polygon by creating parts inside it
	for x = minX, maxX, gridSize do
		for z = minZ, maxZ, gridSize do
			local testPoint = Vector3.new(x, points[1].Y, z)
			if PointInPolygon(testPoint, polygon) then
				local part = Instance.new("Part")
				part.Size = Vector3.new(gridSize, extrusionSize, gridSize) -- Use grid size and extrusion size
				part.CFrame = CFrame.new(testPoint.X, points[1].Y, testPoint.Z)
				part.Anchored = true
				part.BrickColor = currentColor
				part.Material = Enum.Material.SmoothPlastic
				part.Parent = model
			end
		end
	end


Does it need to be filled with individual block Parts for a specific reason?

You should be able to fill any triangle with 1 or 2 wedges to make any triangle shape.

1 Like

i tried this

-- Function to create a shape based on points and fill it using wedges
local function finalizeShape()
	if #points < 3 then
		warn("Need at least 3 points to create a filled shape.")
		return
	end

	-- Create the polygon from points
	local polygon = CreatePolygonFromPoints(points)

	-- Create the shape using parts to fill it
	local model = Instance.new("Model")
	model.Name = "FilledShape" .. shapeIndex
	model.Parent = Workspace
	shapeIndex = shapeIndex + 1 -- Increment shape index for the next shape

	-- Calculate distances and place wedges
	local function createWedge(p1, p2, p3)
		local a = (p2 - p1).Magnitude
		local b = (p3 - p2).Magnitude
		local c = (p1 - p3).Magnitude

		-- Calculate angles using the law of cosines
		local angle1 = math.acos((b^2 + c^2 - a^2) / (2 * b * c))
		local angle2 = math.acos((a^2 + c^2 - b^2) / (2 * a * c))

		-- Create the first wedge
		local wedge1 = Instance.new("WedgePart")
		wedge1.Size = Vector3.new(gridSize, extrusionSize, (p3 - p2).Magnitude)
		wedge1.CFrame = CFrame.new((p2 + p3) / 2, p1)
		wedge1.Anchored = true
		wedge1.BrickColor = currentColor
		wedge1.Material = Enum.Material.SmoothPlastic
		wedge1.Parent = model

		-- Create the second wedge
		local wedge2 = Instance.new("WedgePart")
		wedge2.Size = Vector3.new(gridSize, extrusionSize, (p1 - p2).Magnitude)
		wedge2.CFrame = CFrame.new((p1 + p2) / 2, p3)
		wedge2.Anchored = true
		wedge2.BrickColor = currentColor
		wedge2.Material = Enum.Material.SmoothPlastic
		wedge2.Parent = model
	end

	-- Fill the polygon with wedges
	createWedge(points[1], points[2], points[3])

	-- Update last created model reference
	lastCreatedModel = model

	-- Clear the points after finishing
	points = {}
	clearPreview()
end

and the result is


that’s the drawing ubove

that’s what a got?

Might just be a rotational issue. Try grabbing the Wedges and Moving them up (or look through the baseplate. You may see that you have to rotate 2 of the axes by 90 degrees so the wedges align.

I’ve seen other posts about doing this before. Most mention the Gapfill plugin as a reference for how it works.
The brilliant guru @EgoMoose wrote this article explaining how to create any triangle using no more than 2 WedgeParts:
Articles/3d triangles/3D triangles.md at master · EgoMoose/Articles · GitHub