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

+25 -1
View File
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <Windows.h>
#ifndef MATH_ASM_AVAILABLE
#if !defined(MATH_ASM_AVAILABLE) || MATH_ASM_AVAILABLE == 0
typedef struct { float x, y, z; } Vec3;
typedef struct { float x, y, z, w; } Vec4;
@@ -37,6 +37,30 @@ static inline void quat_normalize(const Quat* q, Quat* o) { float l=sqrtf(q->x*q
static inline void quat_rotate_vec3(const Quat* q, const Vec3* v, Vec3* o) { Quat vq={v->x,v->y,v->z,0}; Quat qinv; quat_conjugate_raw(q,&qinv); Quat tmp; quat_multiply(q,&vq,&tmp); Quat result; quat_multiply(&tmp,&qinv,&result); o->x=result.x; o->y=result.y; o->z=result.z; }
static inline void quat_to_matrix(const Quat* q, Mat4* o) { float xx=q->x*q->x,yy=q->y*q->y,zz=q->z*q->z,xy=q->x*q->y,xz=q->x*q->z,yz=q->y*q->z,wx=q->w*q->x,wy=q->w*q->y,wz=q->w*q->z; mat4_identity(o); o->m[0][0]=1-2*(yy+zz); o->m[0][1]=2*(xy+wz); o->m[0][2]=2*(xz-wy); o->m[1][0]=2*(xy-wz); o->m[1][1]=1-2*(xx+zz); o->m[1][2]=2*(yz+wx); o->m[2][0]=2*(xz+wy); o->m[2][1]=2*(yz-wx); o->m[2][2]=1-2*(xx+yy); }
static inline void quat_from_euler(float x, float y, float z, Quat* o) {
float cx = cosf(x * 0.5f), sx = sinf(x * 0.5f);
float cy = cosf(y * 0.5f), sy = sinf(y * 0.5f);
float cz = cosf(z * 0.5f), sz = sinf(z * 0.5f);
o->w = cx * cy * cz + sx * sy * sz;
o->x = sx * cy * cz - cx * sy * sz;
o->y = cx * sy * cz + sx * cy * sz;
o->z = cx * cy * sz - sx * sy * cz;
}
static inline void quat_to_euler(const Quat* q, float* x, float* y, float* z) {
float sinr_cosp = 2.0f * (q->w * q->x + q->y * q->z);
float cosr_cosp = 1.0f - 2.0f * (q->x * q->x + q->y * q->y);
*x = atan2f(sinr_cosp, cosr_cosp);
float sinp = 2.0f * (q->w * q->y - q->z * q->x);
if (fabsf(sinp) >= 1.0f) *y = copysignf(1.57079633f, sinp);
else *y = asinf(sinp);
float siny_cosp = 2.0f * (q->w * q->z + q->x * q->y);
float cosy_cosp = 1.0f - 2.0f * (q->y * q->y + q->z * q->z);
*z = atan2f(siny_cosp, cosy_cosp);
}
static inline void* mem_aligned_alloc(uint64_t size, uint64_t alignment) { void* p; p = _aligned_malloc(size, alignment); return p; }
static inline void mem_aligned_free(void* ptr) { _aligned_free(ptr); }