feat: major engine overhaul - scene demo with lighting, sphere, ground

- Scene Demo: cube + sphere + ground plane with proper lighting
- Audio: XAudio2 dynamic loading + WAV playback
- Physics: expanded collision system
- Renderer: improved pipeline with materials
- UI: extended widget system
- VisualScript: enhanced serializer + block interactions
- ASM: optimized math/memory/profiling routines
- Window: mouse input + scroll support
This commit is contained in:
shuiyu1123 committed 2026-07-12 08:21:07 +08:00
1 parent 2653926d85
commit 0669d102ce
35 files changed
+1844 -314

No files matched your search

+79 -40
View File
@@ -514,9 +514,13 @@ mat4_scale_f ENDP
mat4_rotate_x PROC
; cos(angle), sin(angle)
movss xmm0, dword ptr [rcx] ; angle
movss xmm1, xmm0
cosss xmm0 ; cos
sinss xmm1 ; sin
movss xmm1, xmm0 ; save angle
call cosf ; xmm0 = cos
movss xmm2, xmm0 ; save cos
movss xmm0, xmm1 ; restore angle
call sinf ; xmm0 = sin
movss xmm1, xmm0 ; xmm1 = sin
movss xmm0, xmm2 ; xmm0 = cos
mov rax, rdx ; out
movss dword ptr [rax], 3F800000h ; m[0][0] = 1.0
@@ -550,9 +554,13 @@ mat4_rotate_x ENDP
; void mat4_rotate_y(float angle, Mat4* out)
mat4_rotate_y PROC
movss xmm0, dword ptr [rcx]
movss xmm1, xmm0
cosss xmm0
sinss xmm1
movss xmm1, xmm0 ; save angle
call cosf ; xmm0 = cos
movss xmm2, xmm0 ; save cos
movss xmm0, xmm1 ; restore angle
call sinf ; xmm0 = sin
movss xmm1, xmm0 ; xmm1 = sin
movss xmm0, xmm2 ; xmm0 = cos
mov rax, rdx
movss dword ptr [rax], xmm0 ; m[0][0] = cos
@@ -583,9 +591,13 @@ mat4_rotate_y ENDP
; void mat4_rotate_z(float angle, Mat4* out)
mat4_rotate_z PROC
movss xmm0, dword ptr [rcx]
movss xmm1, xmm0
cosss xmm0
sinss xmm1
movss xmm1, xmm0 ; save angle
call cosf ; xmm0 = cos
movss xmm2, xmm0 ; save cos
movss xmm0, xmm1 ; restore angle
call sinf ; xmm0 = sin
movss xmm1, xmm0 ; xmm1 = sin
movss xmm0, xmm2 ; xmm0 = cos
mov rax, rdx
movss dword ptr [rax], xmm0 ; m[0][0] = cos
@@ -621,7 +633,9 @@ mat4_perspective PROC
; tan(fovY/2)
movss xmm4, xmm0
mulss xmm4, dword ptr [_half] ; fovY/2
tanss xmm4, xmm4 ; tan(fovY/2)
movss xmm0, xmm4
call tanf
movss xmm4, xmm0 ; xmm4 = tan(fovY/2)
; 1 / (aspect * tan)
movss xmm5, xmm1
@@ -970,7 +984,8 @@ quat_slerp PROC
subss xmm1, dword ptr [rdx]
movss dword ptr [rsp - 16], xmm1
; ... (需要保存到临时空间)
negss xmm0 ; dot = -dot
movss xmm1, dword ptr [_negate_mask] ; 0x80000000
xorps xmm0, xmm1 ; dot = -dot
slerp_no_flip:
; 简化: 线性插值 + 归一化
@@ -1040,7 +1055,10 @@ quat_from_axis_angle PROC
mulss xmm0, dword ptr [_half] ; halfAngle
; s = sin(halfAngle)
sinss xmm1, xmm0
movss xmm2, xmm0 ; save halfAngle
call sinf
movss xmm1, xmm0 ; xmm1 = sin
movss xmm0, xmm2 ; restore halfAngle
; 归一化轴
movss xmm2, dword ptr [rcx]
@@ -1074,9 +1092,7 @@ quat_from_axis_angle PROC
movss dword ptr [r8 + 8], xmm0
; out.w = cos(halfAngle)
movss xmm0, dword ptr [rdx]
mulss xmm0, dword ptr [_half]
cosss xmm0, xmm0
call cosf
movss dword ptr [r8 + 12], xmm0
ret
@@ -1090,21 +1106,42 @@ quat_from_euler PROC
mulss xmm1, dword ptr [_half] ; yaw/2
mulss xmm2, dword ptr [_half] ; roll/2
; cos/sin
cosss xmm3, xmm0 ; cp
sinss xmm4, xmm0 ; sp
cosss xmm5, xmm1 ; cy
sinss xmm6, xmm1 ; sy
cosss xmm7, xmm2 ; cr
; sr 需要额外寄存器
sub rsp, 8
sinss xmm0, xmm2 ; sr
movss dword ptr [rsp], xmm0
; 保存半角并计算 cos/sin
sub rsp, 48
movss dword ptr [rsp + 0], xmm0 ; pitch/2
movss dword ptr [rsp + 4], xmm1 ; yaw/2
movss dword ptr [rsp + 8], xmm2 ; roll/2
call cosf
movss dword ptr [rsp + 12], xmm0 ; cp
movss xmm0, dword ptr [rsp + 0]
call sinf
movss dword ptr [rsp + 16], xmm0 ; sp
movss xmm0, dword ptr [rsp + 4]
call cosf
movss dword ptr [rsp + 20], xmm0 ; cy
movss xmm0, dword ptr [rsp + 4]
call sinf
movss dword ptr [rsp + 24], xmm0 ; sy
movss xmm0, dword ptr [rsp + 8]
call cosf
movss dword ptr [rsp + 28], xmm0 ; cr
movss xmm0, dword ptr [rsp + 8]
call sinf
movss dword ptr [rsp + 32], xmm0 ; sr
movss xmm3, dword ptr [rsp + 12] ; cp
movss xmm4, dword ptr [rsp + 16] ; sp
movss xmm5, dword ptr [rsp + 20] ; cy
movss xmm6, dword ptr [rsp + 24] ; sy
movss xmm7, dword ptr [rsp + 28] ; cr
movss xmm2, dword ptr [rsp + 32] ; xmm2 = sr
add rsp, 48
; out.x = sr*cp*cy - cr*sp*sy
movss xmm0, xmm7 ; cr... 需要重新组织
; 简化: 使用栈
movss xmm0, dword ptr [rsp] ; sr
movss xmm0, xmm2 ; sr
mulss xmm0, xmm3 ; sr*cp
mulss xmm0, xmm5 ; sr*cp*cy
movss xmm1, xmm7 ; cr
@@ -1117,9 +1154,10 @@ quat_from_euler PROC
movss xmm0, xmm7
mulss xmm0, xmm4
mulss xmm0, xmm5
movss xmm1, dword ptr [rsp]
mulss xmm1, xmm3
mulss xmm1, xmm6
movss xmm1, xmm0 ; cr*sp*cy
movss xmm0, xmm2 ; sr (saved above in xmm2)
mulss xmm0, xmm3
mulss xmm0, xmm6
addss xmm0, xmm1
movss dword ptr [rcx + 4], xmm0
@@ -1127,23 +1165,24 @@ quat_from_euler PROC
movss xmm0, xmm7
mulss xmm0, xmm3
mulss xmm0, xmm6
movss xmm1, dword ptr [rsp]
mulss xmm1, xmm4
mulss xmm1, xmm5
subss xmm0, xmm1
movss dword ptr [rcx + 8], xmm0
movss xmm1, xmm0 ; cr*cp*sy
movss xmm0, xmm2 ; sr
mulss xmm0, xmm4
mulss xmm0, xmm5
subss xmm1, xmm0
movss dword ptr [rcx + 8], xmm1
; out.w = cr*cp*cy + sr*sp*sy
movss xmm0, xmm7
mulss xmm0, xmm3
mulss xmm0, xmm5
movss xmm1, dword ptr [rsp]
mulss xmm1, xmm4
mulss xmm1, xmm6
movss xmm1, xmm0 ; cr*cp*cy
movss xmm0, xmm2 ; sr
mulss xmm0, xmm4
mulss xmm0, xmm6
addss xmm0, xmm1
movss dword ptr [rcx + 12], xmm0
add rsp, 8
ret
quat_from_euler ENDP