Compiles again

This commit is contained in:
2024-10-13 00:54:26 +02:00
parent 8f2dad9cec
commit 9939c84f09
9 changed files with 172 additions and 147 deletions

View File

@@ -81,6 +81,10 @@ operator - :: inline (a: Vector3i, b: Vector3i) -> Vector3i {
return .{a.x - b.x, a.y - b.y, a.z - b.z};
}
transform_position :: (position: Vector3, matrix: Matrix4) -> Vector3 {
return to_v3(matrix * to_v4(position));
}
to_v4 :: (v3: Vector3) -> Vector4 {
v4 : Vector4;
v4.x = v3.x;

View File

@@ -36,7 +36,7 @@ Particle_System :: struct {
}
create_particle_system :: (pipeline: Pipeline_State_Handle, update_func: (*Particle_System, float), owning_entity: *Entity = null, scene: *Scene = null) -> *Particle_System {
lvl := ifx scene == null then game_state.current_scene else scene;
lvl := ifx scene == null then current_scene else scene;
particle_system, locator := find_and_occupy_empty_slot(*scene.particle_systems);
particle_system._locator = locator;
particle_system.vertex_buffer = create_vertex_buffer(renderer, null, size_of(Particle_Vertex) * MAX_PARTICLES, stride=size_of(Particle_Vertex), mappable=true);
@@ -60,7 +60,7 @@ spawn_particle :: (system: *Particle_System, position: Vector3, velocity: Vector
}
update_particle_systems :: (dt: float) {
for *system: game_state.current_scene.particle_systems {
for *system: current_scene.particle_systems {
if system.on_particle_update != null {
system.on_particle_update(system, dt);
}
@@ -71,9 +71,9 @@ update_particle_system :: (system: *Particle_System, dt: float) {
}
prepare_particle_system_for_rendering :: (system: Particle_System) {
up := game_state.camera.up;
right := game_state.camera.right;
forward := game_state.camera.forward;
up := current_scene.camera.up;
right := current_scene.camera.right;
forward := current_scene.camera.forward;
rendering_data : [..] Particle_Vertex;
rendering_data.allocator = temp;
@@ -140,7 +140,7 @@ prepare_particle_system_for_rendering :: (system: Particle_System) {
}
render_particle_systems :: () {
for system: game_state.current_scene.particle_systems {
for system: current_scene.particle_systems {
prepare_particle_system_for_rendering(system);
if system.particles.count > 0 {

View File

@@ -2,6 +2,8 @@
#load "particles.jai";
#placeholder Entity_Storage;
#placeholder serialize_entity;
#placeholder deserialize_entity;
MAX_CACHED_PILES :: 8;
@@ -12,8 +14,6 @@ Scene :: struct {
particle_systems : Bucket_Array(Particle_System, 64);
bullet_impact_particle_systems : [..] *Particle_System;
by_type : Entity_Storage;
pool : Flat_Pool;
@@ -58,7 +58,6 @@ load_scene :: (path: string) -> *Scene {
}
save_scene :: (scene: *Scene, path: string) {
scene.camera = game_state.camera;
builder : String_Builder;
builder.allocator = temp;
@@ -99,7 +98,6 @@ create_scene :: (name: string, max_entities: s64 = 256) -> *Scene {
// Assign allocator to everything that needs allocations
scene.entities.allocator = scene.allocator;
scene.particle_systems.allocator = scene.allocator;
scene.bullet_impact_particle_systems.allocator = scene.allocator;
array_reserve(*scene.entities, max_entities);
@@ -111,12 +109,6 @@ create_scene :: (name: string, max_entities: s64 = 256) -> *Scene {
dir_light_data.direction = scene.directional_light.direction;
upload_data_to_buffer(renderer, directional_light_buffer, *dir_light_data, size_of(Directional_Light_Buffer_Data));
array_resize(*scene.bullet_impact_particle_systems, 32);
for 0..31 {
scene.bullet_impact_particle_systems[it] = create_particle_system(particle_pipeline, on_update_bullet_hit_particles, null, scene);
}
return scene;
}