[Bf-blender-cvs] [bb39e33d253] blender2.8: Fix: draw_circle_2d not using the segment count from parameter list
Jacques Lucke
noreply at git.blender.org
Mon Nov 12 17:55:21 CET 2018
Commit: bb39e33d2537befd54d8ddda54669749855ba7a3
Author: Jacques Lucke
Date: Mon Nov 12 17:54:20 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBbb39e33d2537befd54d8ddda54669749855ba7a3
Fix: draw_circle_2d not using the segment count from parameter list
===================================================================
M release/scripts/modules/gpu_extras/presets.py
===================================================================
diff --git a/release/scripts/modules/gpu_extras/presets.py b/release/scripts/modules/gpu_extras/presets.py
index ad623c456e0..46c79c61d4d 100644
--- a/release/scripts/modules/gpu_extras/presets.py
+++ b/release/scripts/modules/gpu_extras/presets.py
@@ -16,7 +16,7 @@
#
# ***** END GPL LICENSE BLOCK *****
-def draw_circle_2d(position, color, radius, segments):
+def draw_circle_2d(position, color, radius, segments = 32):
from math import sin, cos, pi
import gpu
from gpu.types import (
@@ -25,12 +25,14 @@ def draw_circle_2d(position, color, radius, segments):
GPUVertFormat,
)
+ if segments <= 0:
+ raise ValueError("Amount of segments must be greater than 0.")
+
with gpu.matrix.push_pop():
gpu.matrix.translate(position)
gpu.matrix.scale_uniform(radius)
- seg = 32
- mul = (1.0 / (seg - 1)) * (pi * 2)
- verts = [(sin(i * mul), cos(i * mul)) for i in range(seg)]
+ mul = (1.0 / (segments - 1)) * (pi * 2)
+ verts = [(sin(i * mul), cos(i * mul)) for i in range(segments)]
fmt = GPUVertFormat()
pos_id = fmt.attr_add(id="pos", comp_type='F32', len=2, fetch_mode='FLOAT')
vbo = GPUVertBuf(len=len(verts), format=fmt)
More information about the Bf-blender-cvs
mailing list