Math funcs

This commit is contained in:
2025-02-08 11:37:27 +01:00
parent 040a5fa23a
commit adf9a57294
3 changed files with 18 additions and 1 deletions

View File

@@ -162,6 +162,14 @@ move_towards :: (origin: Vector3, target: Vector3, amount: float) -> Vector3 {
return result; return result;
} }
move_towards :: (origin: Vector2, target: Vector2, amount: float) -> Vector2 {
result : Vector2;
dir := normalize(target - origin);
result.x = move_towards(origin.x, target.x, abs(dir.x) * amount);
result.y = move_towards(origin.y, target.y, abs(dir.y) * amount);
return result;
}
smooth_damp :: (current: Vector3, target: Vector3, current_velocity: *Vector3, smooth_time: float, max_speed: float, delta_time: float) -> Vector3 { smooth_damp :: (current: Vector3, target: Vector3, current_velocity: *Vector3, smooth_time: float, max_speed: float, delta_time: float) -> Vector3 {
output_x := 0.0; output_x := 0.0;
output_y := 0.0; output_y := 0.0;
@@ -389,4 +397,4 @@ ease_in_out_sine :: (x: float) -> float {
#import "PCG"; #import "PCG";
#import "Math"; #import "Math";
#load "frustum.jai"; #load "frustum.jai";

View File

@@ -32,6 +32,10 @@ operator [] :: (static_array: Static_Array, index: int) -> static_array.Data_Typ
return static_array.data[index]; return static_array.data[index];
} }
operator [] :: (static_array: *Static_Array, index: int) -> *static_array.Data_Type {
return *static_array.data[index];
}
operator []= :: (static_array: *Static_Array, index: int, value: static_array.Data_Type) { operator []= :: (static_array: *Static_Array, index: int, value: static_array.Data_Type) {
static_array.data[index] = value; static_array.data[index] = value;
} }

View File

@@ -602,6 +602,10 @@ Renderer :: struct {
render_target_width: u32; render_target_width: u32;
render_target_height: u32; render_target_height: u32;
default_models : struct {
sphere: Model;
}
default_meshes : struct { default_meshes : struct {
plane : Mesh_Handle; plane : Mesh_Handle;
cube : Mesh_Handle; cube : Mesh_Handle;
@@ -805,6 +809,7 @@ init_default_meshes :: () {
{ {
sphere_model := load_fbx("../modules/Coven/assets/models/sphere.fbx"); sphere_model := load_fbx("../modules/Coven/assets/models/sphere.fbx");
engine.renderer.default_models.sphere = sphere_model;
sphere_mesh, success := get_first_mesh_from_model(sphere_model); sphere_mesh, success := get_first_mesh_from_model(sphere_model);
assert(success); assert(success);