true 16-bit color... glorious

This commit is contained in:
asrael 2025-11-28 14:41:35 -06:00
parent 3dccce8a81
commit b1e8525c3e
30 changed files with 678 additions and 652 deletions

View file

@ -4,8 +4,9 @@
#include <string.h>
#include "pxl8_bsp.h"
#include "pxl8_gen.h"
#include "pxl8_macros.h"
#include "pxl8_procgen.h"
#include "pxl8_math.h"
struct pxl8_world {
pxl8_bsp bsp;
@ -221,22 +222,6 @@ bool pxl8_world_is_loaded(const pxl8_world* world) {
return world && world->loaded;
}
static inline f32 vec3_dot(pxl8_vec3 a, pxl8_vec3 b) {
return a.x * b.x + a.y * b.y + a.z * b.z;
}
static inline pxl8_vec3 vec3_cross(pxl8_vec3 a, pxl8_vec3 b) {
return (pxl8_vec3){
a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x
};
}
static inline f32 vec3_length(pxl8_vec3 v) {
return sqrtf(v.x * v.x + v.y * v.y + v.z * v.z);
}
pxl8_vec3 pxl8_world_resolve_collision(const pxl8_world* world, pxl8_vec3 from, pxl8_vec3 to, f32 radius) {
if (!world || !world->loaded) return to;
@ -294,7 +279,7 @@ pxl8_vec3 pxl8_world_resolve_collision(const pxl8_world* world, pxl8_vec3 from,
bool is_new_plane = true;
for (u32 p = 0; p < num_planes; p++) {
if (vec3_dot(push_dir, clip_planes[p]) > 0.99f) {
if (pxl8_vec3_dot(push_dir, clip_planes[p]) > 0.99f) {
is_new_plane = false;
break;
}
@ -327,8 +312,8 @@ pxl8_vec3 pxl8_world_resolve_collision(const pxl8_world* world, pxl8_vec3 from,
original_velocity.z * original_velocity.z;
if (orig_vel_len_sq > 0.000001f) {
f32 vdot0 = vec3_dot(original_velocity, clip_planes[0]);
f32 vdot1 = vec3_dot(original_velocity, clip_planes[1]);
f32 vdot0 = pxl8_vec3_dot(original_velocity, clip_planes[0]);
f32 vdot1 = pxl8_vec3_dot(original_velocity, clip_planes[1]);
f32 dot0 = fabsf(vdot0);
f32 dot1 = fabsf(vdot1);
@ -350,11 +335,11 @@ pxl8_vec3 pxl8_world_resolve_collision(const pxl8_world* world, pxl8_vec3 from,
pos.y += slide_vel.y;
pos.z += slide_vel.z;
pxl8_vec3 crease_dir = vec3_cross(clip_planes[0], clip_planes[1]);
f32 crease_len = vec3_length(crease_dir);
pxl8_vec3 crease_dir = pxl8_vec3_cross(clip_planes[0], clip_planes[1]);
f32 crease_len = pxl8_vec3_length(crease_dir);
if (crease_len > 0.01f && fabsf(crease_dir.y / crease_len) > 0.9f) {
f32 bias0 = vec3_dot(original_velocity, clip_planes[0]);
f32 bias1 = vec3_dot(original_velocity, clip_planes[1]);
f32 bias0 = pxl8_vec3_dot(original_velocity, clip_planes[0]);
f32 bias1 = pxl8_vec3_dot(original_velocity, clip_planes[1]);
if (bias0 < 0 && bias1 < 0) {
const f32 corner_push = 0.1f;