From aec563e33a064dca78133a8a506016c14d363866 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 15 Oct 2026 18:21:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(scene3d):=20PI=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=9C=9F=20float=20=E5=8F=98=E9=87=8F=20-=20?= =?UTF-8?q?=E6=B6=88=E9=99=A4=20float=20=E5=AD=97=E9=9D=A2=E9=87=8F?= =?UTF-8?q?=E8=A2=AB=E6=8A=98=E5=8F=A0=E6=88=90=20double=20=E8=87=B4?= =?UTF-8?q?=E6=B3=A2=E5=BD=A2=E7=AE=97=E6=9C=AF=E6=8F=90=E5=8D=87=E4=B8=BA?= =?UTF-8?q?=20double(SIN=20=E6=B3=A2=E5=BD=A2=E5=A1=8C=E5=B9=B3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apps/Scene3D/gfx.vp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Apps/Scene3D/gfx.vp b/Apps/Scene3D/gfx.vp index 337c512..f7b027d 100644 --- a/Apps/Scene3D/gfx.vp +++ b/Apps/Scene3D/gfx.vp @@ -4,7 +4,13 @@ import string import t, c -define PI = float(3.14159265358979323846) +# [修复] 原为 `define PI = float(3.14159265358979323846)`:常量折叠后 IR 里是 **double** 常量 +# (`-PI` 生成 0xC00921FB54442D18),于是 `x0 = -PI + i*step` 整段被提升成 double 运算 +# (fpext → fadd(double) → fptrunc),与 _DrawSphere 的纯 float 路径不一致 —— +# 现场表现为 SIN 波形高度塌平(球体只用 i*step,不含 -PI,因此不受影响)。 +# 改成运行期全局变量:PI 参与的所有运算都在运行时按 float 进行,绕开该折叠路径。 +# 根因是编译器的 float 字面量折叠(已单独记录),编译器修好后可改回 define。 +PI: float = float(3.14159265358979323846) define SPHERE_SLICES = (24 * 1) define SPHERE_STACKS = (16 * 1)